/** * @test */ public function shouldNotCompareRelations() { $cars = Category::create(array('name' => 'phones')); $product = Product::create(array('name' => 'Reno', 'id_category' => $cars->getId())); $productWithoutLoadedCategory = Product::findById($product->getId()); // when relation is loaded $product->category; //then Assert::thatModel($product)->hasSameAttributesAs($productWithoutLoadedCategory); }
/** * @test */ public function updateShouldUpdateOnlyChangedFieldsWhenObjectWasCreatedByHandAndIdWasSet() { //given $product = Product::create(array('name' => 'Sport', 'price' => '123')); $id = $product->getId(); $product = new Product(array('name' => 'Water', 'price' => '123', 'id' => $id)); // when $product->update(); // then $actual = Product::findById($product->getId()); $this->assertEquals('Water', $actual->name); }