Exemplo n.º 1
0
 public function testAddOptionWithIdsCallsAddOptionAndReturnsOption()
 {
     $mockMapper = $this->getMock('\\SpeckCatalog\\Mapper\\Product');
     $mockMapper->expects($this->once())->method('addOption')->with(1, 2);
     $mockOptionService = $this->getMock('\\SpeckCatalog\\Service\\Option');
     $mockOptionService->expects($this->once())->method('find')->with(array('option_id' => 2))->will($this->returnValue(new \SpeckCatalog\Model\Option()));
     $service = $this->getService();
     $service->setEntityMapper($mockMapper);
     $service->setOptionService($mockOptionService);
     $product = new \SpeckCatalog\Model\Product();
     $product->setProductId(1);
     $option = new \SpeckCatalog\Model\Option();
     $option->setOptionId(2);
     $return = $service->addOption($product, $option);
     $this->assertInstanceOf('\\SpeckCatalog\\Model\\Option', $return);
 }
Exemplo n.º 2
0
 public function testUpdateWithModelGeneratesOriginalValuesAndCallsUpdateOnMapper()
 {
     $option = new \SpeckCatalog\Model\Option();
     $option->setOptionId(1);
     $mockMapper = $this->getMock('\\SpeckCatalog\\Mapper\\Option');
     $mockMapper->expects($this->once())->method('update')->with($option, array('option_id' => 1))->will($this->returnValue($option));
     $service = $this->getService();
     $service->setEntityMapper($mockMapper);
     $service->update($option);
 }