Skip to content

Commit

Permalink
Add test for find('list') with assocaited table
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Apr 27, 2015
1 parent 099e76c commit 8e1bf95
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/TestCase/ORM/TableTest.php
Expand Up @@ -1250,6 +1250,32 @@ public function testFindListWithVirtualField()
$this->assertEmpty($query->clause('select'));
}

/**
* Test find('list') with value field from associated table
*
* @return void
*/
public function testFindListWithAssociatedTable()
{
$articles = new Table([
'table' => 'articles',
'connection' => $this->connection,
]);

$articles->belongsTo('Authors');
$query = $articles->find('list', ['valueField' => 'author.name'])
->contain(['Authors'])
->order('Articles.id');
$this->assertEmpty($query->clause('select'));

$expected = [
1 => 'mariano',
2 => 'larry',
3 => 'mariano',
];
$this->assertSame($expected, $query->toArray());
}

/**
* Test the default entityClass.
*
Expand Down

0 comments on commit 8e1bf95

Please sign in to comment.