diff --git a/tests/TestCase/ORM/AssociationProxyTest.php b/tests/TestCase/ORM/AssociationProxyTest.php new file mode 100644 index 00000000000..0b0b7a02393 --- /dev/null +++ b/tests/TestCase/ORM/AssociationProxyTest.php @@ -0,0 +1,66 @@ +hasMany('comments'); + $articles->belongsTo('authors'); + $this->assertTrue(isset($articles->authors)); + $this->assertTrue(isset($articles->comments)); + $this->assertFalse(isset($articles->posts)); + $this->assertSame($articles->association('authors'), $articles->authors); + $this->assertSame($articles->association('comments'), $articles->comments); + } + +/** + * Tests that getting a bad property throws exception + * + * @expectedException \RuntimeException + * @expectedExceptionMessage Table "TestApp\Model\Table\ArticlesTable" is not associated with "posts" + * @return void + */ + public function testGetBadAssociation() { + $articles = TableRegistry::get('articles'); + $articles->posts; + } + +} diff --git a/tests/TestCase/ORM/TableTest.php b/tests/TestCase/ORM/TableTest.php index c240fb94118..dc7f1271202 100644 --- a/tests/TestCase/ORM/TableTest.php +++ b/tests/TestCase/ORM/TableTest.php @@ -3308,31 +3308,4 @@ public function testDebugInfo() { $this->assertEquals($expected, $result); } -/** - * Tests that it is possible to get associations as a property - * - * @return void - */ - public function testAssociationAsProperty() { - $articles = TableRegistry::get('articles'); - $articles->hasMany('comments'); - $articles->belongsTo('authors'); - $this->assertTrue(isset($articles->authors)); - $this->assertTrue(isset($articles->comments)); - $this->assertFalse(isset($articles->posts)); - $this->assertSame($articles->association('authors'), $articles->authors); - $this->assertSame($articles->association('comments'), $articles->comments); - } - -/** - * Tests that getting a bad property throws exception - * - * @expectedException \RuntimeException - * @expectedExceptionMessage Table "TestApp\Model\Table\ArticlesTable" is not associated with "posts" - * @return void - */ - public function testGetBadAssociation() { - $articles = TableRegistry::get('articles'); - $articles->posts; - } }