From e36c7b0c2a11f87738186214d2ae7805ac90a951 Mon Sep 17 00:00:00 2001 From: Pavel Batanov Date: Thu, 22 Jan 2015 17:32:03 +0300 Subject: [PATCH] DDC-3346 failing test example --- .../Tests/Models/DDC3346/DDC3346Article.php | 31 +++++++++ .../Tests/Models/DDC3346/DDC3346Author.php | 32 ++++++++++ .../ORM/Functional/Ticket/DDC3346Test.php | 64 +++++++++++++++++++ 3 files changed, 127 insertions(+) create mode 100644 tests/Doctrine/Tests/Models/DDC3346/DDC3346Article.php create mode 100644 tests/Doctrine/Tests/Models/DDC3346/DDC3346Author.php create mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3346Test.php diff --git a/tests/Doctrine/Tests/Models/DDC3346/DDC3346Article.php b/tests/Doctrine/Tests/Models/DDC3346/DDC3346Article.php new file mode 100644 index 000000000..0f57011db --- /dev/null +++ b/tests/Doctrine/Tests/Models/DDC3346/DDC3346Article.php @@ -0,0 +1,31 @@ +user = $author; + } +} diff --git a/tests/Doctrine/Tests/Models/DDC3346/DDC3346Author.php b/tests/Doctrine/Tests/Models/DDC3346/DDC3346Author.php new file mode 100644 index 000000000..8fa87ca5e --- /dev/null +++ b/tests/Doctrine/Tests/Models/DDC3346/DDC3346Author.php @@ -0,0 +1,32 @@ +setUpEntitySchema( + array( + 'Doctrine\Tests\Models\DDC3346\DDC3346Article', + 'Doctrine\Tests\Models\DDC3346\DDC3346Author', + ) + ); + } + + public function testFindOneByWithEagerFetch() + { + $user = new DDC3346Author(); + $user->name = "Buggy Woogy"; + $user->username = "bwoogy"; + $user->status = "active"; + + $article1 = new DDC3346Article(); + $article1->text = "First content"; + $article1->setAuthor($user); + + $article2 = new DDC3346Article(); + $article2->text = "Second content"; + $article2->setAuthor($user); + + $this->_em->persist($user); + $this->_em->persist($article1); + $this->_em->persist($article2); + $this->_em->flush(); + $this->_em->close(); + + /** @var DDC3346Author[] $authors */ + $authors = $this->_em->getRepository('Doctrine\Tests\Models\DDC3346\DDC3346Author')->findBy( + array('username' => "bwoogy") + ); + + $this->assertCount(1, $authors); + + $this->assertCount(2, $authors[0]->articles); + + $this->_em->close(); + + /** @var DDC3346Author $author */ + $author = $this->_em->getRepository('Doctrine\Tests\Models\DDC3346\DDC3346Author')->findOneBy( + array('username' => "bwoogy") + ); + + $this->assertCount(2, $author->articles); + } +}