/**
  * Test related methods
  */
 public function testGuessUpdates()
 {
     $category = new Category();
     $productOne = new Product();
     $productTwo = new Product();
     $category->addProduct($productOne);
     $category->addProduct($productTwo);
     $guesser = new ContainsProductsUpdateGuesser();
     $em = $this->getEntityManagerMock();
     $updates = $guesser->guessUpdates($em, $category, UpdateGuesserInterface::ACTION_UPDATE_ENTITY);
     $this->assertEquals(2, count($updates));
     $this->assertEquals($productOne, $updates[0]);
     $this->assertEquals($productTwo, $updates[1]);
 }
 /**
  * Test add/remove/get products methods
  */
 public function testGetProducts()
 {
     $product1 = $this->createProduct();
     $product2 = $this->createProduct();
     $this->assertFalse($this->category->hasProducts());
     $this->assertEquals(0, $this->category->getProductsCount());
     // assert adding
     $this->assertEntity($this->category->addProduct($product1));
     $this->category->addProduct($product2);
     $this->assertCount(2, $this->category->getProducts());
     $this->assertEquals(2, $this->category->getProductsCount());
     $this->assertTrue($this->category->hasProducts());
     // assert removing
     $this->assertEntity($this->category->removeProduct($product1));
     $this->assertCount(1, $this->category->getProducts());
     $this->assertEquals(1, $this->category->getProductsCount());
     $this->assertTrue($this->category->hasProducts());
     // assert product entity
     $products = $this->category->getProducts();
     foreach ($products as $product) {
         $this->assertProductEntity($product);
     }
 }