Exemplo n.º 1
0
 public function testShouldSaveNotLoadedReference()
 {
     $category = new Category();
     $category->setName('Category 1');
     $category->setDesc('Category 1 desc');
     $category->save();
     $product = new Product();
     $product->setCategory($category);
     $product->setName('Product 1');
     $product->setPrice(100);
     $product->setIsActive(true);
     $product->setCreatedAt(time());
     $product->save();
     $product = Product::findById($product->getId());
     $product->save();
     $product = Product::findById($product->getId());
     $category1 = $product->getCategory();
     $category2 = $product->getCategory();
     $this->assertInstanceOf('Fixtures\\Collection\\Category', $category1);
     $this->assertInstanceOf('Fixtures\\Collection\\Category', $category2);
     $this->assertSame($category2->getName(), $category1->getName());
 }