Beispiel #1
0
 public function testSavingClonedPersistentCollection()
 {
     $product = new ECommerceProduct();
     $category = new ECommerceCategory();
     $category->setName('foo');
     $product->addCategory($category);
     $this->_em->persist($product);
     $this->_em->persist($category);
     $this->_em->flush();
     $newProduct = clone $product;
     $this->_em->persist($newProduct);
     $this->_em->flush();
     $this->_em->clear();
     $product1 = $this->_em->find('Doctrine\\Tests\\Models\\ECommerce\\ECommerceProduct', $product->getId());
     $product2 = $this->_em->find('Doctrine\\Tests\\Models\\ECommerce\\ECommerceProduct', $newProduct->getId());
     $this->assertCount(1, $product1->getCategories());
     $this->assertCount(1, $product2->getCategories());
     $this->assertSame($product1->getCategories()->get(0), $product2->getCategories()->get(0));
 }
 public function assertForeignKeyIs($value, ECommerceCategory $child)
 {
     $foreignKey = $this->_em->getConnection()->executeQuery('SELECT parent_id FROM ecommerce_categories WHERE id=?', array($child->getId()))->fetchColumn();
     $this->assertEquals($value, $foreignKey);
 }
 public function addChild(ECommerceCategory $child)
 {
     $this->children[] = $child;
     $child->setParent($this);
 }