Skip to content
This repository
Browse code

Merge pull request #9 from Phally/model-field

Fixed usage of Model::field().
  • Loading branch information...
commit 2b2a6e767ec032a165326861eadc4f6489b85b4b 2 parents c8da44d + 391f3d5
Graham Weldon authored
10  models/datasources/array_source.php
@@ -143,7 +143,7 @@ public function read(&$model, $queryData = array()) {
143 143
 		// Filter fields
144 144
 		if (!empty($queryData['fields'])) {
145 145
 			$listOfFields = array();
146  
-			foreach ($queryData['fields'] as $field) {
  146
+			foreach ((array)$queryData['fields'] as $field) {
147 147
 				if (strpos($field, '.') !== false) {
148 148
 					list($alias, $field) = explode('.', $field, 2);
149 149
 					if ($alias !== $model->alias) {
@@ -196,10 +196,10 @@ public function read(&$model, $queryData = array()) {
196 196
 /**
197 197
  * Conditions Filter
198 198
  *
199  
- * @param Model $model 
200  
- * @param string $record 
201  
- * @param array $conditions 
202  
- * @param boolean $or 
  199
+ * @param Model $model
  200
+ * @param string $record
  201
+ * @param array $conditions
  202
+ * @param boolean $or
203 203
  * @return void
204 204
  */
205 205
 	public function conditionsFilter(&$model, $record, $conditions, $or = false) {
20  tests/cases/models/datasources/array_source.test.php
@@ -225,6 +225,26 @@ function testFindFields() {
225 225
 	}
226 226
 
227 227
 /**
  228
+ * testField
  229
+ *
  230
+ * @return void
  231
+ * @access public
  232
+ */
  233
+	function testField() {
  234
+		$expected = 2;
  235
+		$result = $this->Model->field('id', array('name' => 'Brazil'));
  236
+		$this->assertEqual($result, $expected);
  237
+
  238
+		$expected = 'Germany';
  239
+		$result = $this->Model->field('name', array('relate_id' => 2));
  240
+		$this->assertEqual($result, $expected);
  241
+
  242
+		$expected = 'USA';
  243
+		$result = $this->Model->field('name', array('relate_id' => 1));
  244
+		$this->assertEqual($result, $expected);
  245
+	}
  246
+
  247
+/**
228 248
  * testFindLimit
229 249
  *
230 250
  * @return void

0 notes on commit 2b2a6e7

Please sign in to comment.
Something went wrong with that request. Please try again.