Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #9 from Phally/model-field

Fixed usage of Model::field().
  • Loading branch information...
commit 2b2a6e767ec032a165326861eadc4f6489b85b4b 2 parents c8da44d + 391f3d5
Graham Weldon predominant authored
10 models/datasources/array_source.php
View
@@ -143,7 +143,7 @@ public function read(&$model, $queryData = array()) {
// Filter fields
if (!empty($queryData['fields'])) {
$listOfFields = array();
- foreach ($queryData['fields'] as $field) {
+ foreach ((array)$queryData['fields'] as $field) {
if (strpos($field, '.') !== false) {
list($alias, $field) = explode('.', $field, 2);
if ($alias !== $model->alias) {
@@ -196,10 +196,10 @@ public function read(&$model, $queryData = array()) {
/**
* Conditions Filter
*
- * @param Model $model
- * @param string $record
- * @param array $conditions
- * @param boolean $or
+ * @param Model $model
+ * @param string $record
+ * @param array $conditions
+ * @param boolean $or
* @return void
*/
public function conditionsFilter(&$model, $record, $conditions, $or = false) {
20 tests/cases/models/datasources/array_source.test.php
View
@@ -225,6 +225,26 @@ function testFindFields() {
}
/**
+ * testField
+ *
+ * @return void
+ * @access public
+ */
+ function testField() {
+ $expected = 2;
+ $result = $this->Model->field('id', array('name' => 'Brazil'));
+ $this->assertEqual($result, $expected);
+
+ $expected = 'Germany';
+ $result = $this->Model->field('name', array('relate_id' => 2));
+ $this->assertEqual($result, $expected);
+
+ $expected = 'USA';
+ $result = $this->Model->field('name', array('relate_id' => 1));
+ $this->assertEqual($result, $expected);
+ }
+
+/**
* testFindLimit
*
* @return void
Please sign in to comment.
Something went wrong with that request. Please try again.