From 81f97e92d3ce7e3aa04dc401095a2254ca29c84d Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 19 Jul 2012 22:00:56 +0200 Subject: [PATCH] Adding tests for DDC-1925 --- .../Tests/Models/DDC1925/DDC1925Product.php | 97 +++++++++++++++++++ .../Tests/Models/DDC1925/DDC1925User.php | 56 +++++++++++ .../ORM/Functional/Ticket/DDC1925Test.php | 54 +++++++++++ 3 files changed, 207 insertions(+) create mode 100644 tests/Doctrine/Tests/Models/DDC1925/DDC1925Product.php create mode 100644 tests/Doctrine/Tests/Models/DDC1925/DDC1925User.php create mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1925Test.php diff --git a/tests/Doctrine/Tests/Models/DDC1925/DDC1925Product.php b/tests/Doctrine/Tests/Models/DDC1925/DDC1925Product.php new file mode 100644 index 000000000..16ddffa9d --- /dev/null +++ b/tests/Doctrine/Tests/Models/DDC1925/DDC1925Product.php @@ -0,0 +1,97 @@ +buyers = new ArrayCollection(); + } + + /** + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * @param string $title + */ + public function setTitle($title) + { + $this->title = $title; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * @param string $buyers + */ + public function setBuyers($buyers) + { + $this->buyers = $buyers; + } + + /** + * @return string + */ + public function getBuyers() + { + return $this->buyers; + } + + /** + * @param DDC1925User $buyer + */ + public function addBuyer(DDC1925User $buyer) + { + $this->buyers[] = $buyer; + } +} \ No newline at end of file diff --git a/tests/Doctrine/Tests/Models/DDC1925/DDC1925User.php b/tests/Doctrine/Tests/Models/DDC1925/DDC1925User.php new file mode 100644 index 000000000..abbdddaa1 --- /dev/null +++ b/tests/Doctrine/Tests/Models/DDC1925/DDC1925User.php @@ -0,0 +1,56 @@ +id; + } + + /** + * Set title + * + * @param string $title + */ + public function setTitle($title) + { + $this->title = $title; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } +} diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1925Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1925Test.php new file mode 100644 index 000000000..d6c0bf133 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1925Test.php @@ -0,0 +1,54 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata('Doctrine\Tests\Models\DDC1925\DDC1925User'), + $this->_em->getClassMetadata('Doctrine\Tests\Models\DDC1925\DDC1925Product'), + )); + //} catch(\Exception $e) { + //} + + } + + public function testIssue() + { + $user = new DDC1925User(); + $user->setTitle("Test User"); + $this->_em->persist($user); + + $product = new DDC1925Product(); + $product->setTitle("Test product"); + $this->_em->persist($product); + $this->_em->flush(); + + $product->addBuyer($user); + + $this->_em->getUnitOfWork()->computeChangeSets(); + + $this->_em->persist($product); + $this->_em->flush(); + } +} \ No newline at end of file