diff --git a/tests/TestCase/ORM/TableTest.php b/tests/TestCase/ORM/TableTest.php index ef0c58a78f3..7a087419ba0 100644 --- a/tests/TestCase/ORM/TableTest.php +++ b/tests/TestCase/ORM/TableTest.php @@ -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. *