diff --git a/tests/TestCase/Factory/BaseFactoryAssociationsTest.php b/tests/TestCase/Factory/BaseFactoryAssociationsTest.php index 440c5042..5375559a 100644 --- a/tests/TestCase/Factory/BaseFactoryAssociationsTest.php +++ b/tests/TestCase/Factory/BaseFactoryAssociationsTest.php @@ -682,4 +682,28 @@ public function testAssociationWithVirtualFieldNamedIdentically() $this->assertSame(1, $this->CitiesTable->find()->count()); $this->assertSame(1, $this->CountriesTable->find()->count()); } + + /** + * Reproduce the issue reported here: https://github.com/vierge-noire/cakephp-fixture-factories/issues/84 + */ + public function testReproduceIssue84() + { + $articles = ArticleFactory::make(2) + ->with('Authors[5]', ['biography' => 'Foo']) + ->with('Bills') + ->persist(); + + $this->assertSame(2, count($articles)); + foreach ($articles as $article) { + $this->assertSame(5, count($article->authors)); + foreach ($article->authors as $author) { + $this->assertSame('Foo', $author->biography); + } + $this->assertSame(1, count($article->bills)); + } + + $this->assertSame(2, $this->ArticlesTable->find()->count()); + $this->assertSame(10, $this->AuthorsTable->find()->count()); + $this->assertSame(2, $this->BillsTable->find()->count()); + } }