Exemple #1
0
 public function testPopulatePopulatesProduct()
 {
     $this->markTestIncomplete('Tests was broken/obsoleted');
     $service = $this->getService();
     $optionService = $this->getMock('\\SpeckCatalog\\Service\\Option');
     $optionService->expects($this->once())->method('getByProductId')->will($this->returnValue(array(new \SpeckCatalog\Model\Option\Relational())));
     $service->setOptionService($optionService);
     $imageService = $this->getMock('\\SpeckCatalog\\Service\\Image');
     $imageService->expects($this->once())->method('getImages')->will($this->returnValue(array(new \SpeckCatalog\Model\ProductImage\Relational())));
     $service->setImageService($imageService);
     $documentService = $this->getMock('\\SpeckCatalog\\Service\\Document');
     $documentService->expects($this->once())->method('getDocuments')->will($this->returnValue(array(new \SpeckCatalog\Model\Document\Relational())));
     $service->setDocumentService($documentService);
     $productUomService = $this->getMock('\\SpeckCatalog\\Service\\ProductUom');
     $productUomService->expects($this->once())->method('getByProductId')->will($this->returnValue(array(new \SpeckCatalog\Model\ProductUom\Relational())));
     $service->setProductUomService($productUomService);
     $specService = $this->getMock('\\SpeckCatalog\\Service\\Spec');
     $specService->expects($this->once())->method('getByProductId')->will($this->returnValue(array(new \SpeckCatalog\Model\Spec\Relational())));
     $service->setSpecService($specService);
     $companyService = $this->getMock('\\SpeckCatalog\\Service\\Company');
     $companyService->expects($this->once())->method('findById')->will($this->returnValue(new \SpeckCatalog\Model\Company\Relational()));
     $service->setCompanyService($companyService);
     $product = new \SpeckCatalog\Model\Product\Relational();
     $product->setProductId('111');
     $service->populate($product);
     $options = $product->getOptions();
     $this->assertTrue(is_array($options));
     $this->assertTrue(count($options) === 1);
     $images = $product->getImages();
     $this->assertTrue(is_array($images));
     $this->assertTrue(count($images) === 1);
     $documents = $product->getDocuments();
     $this->assertTrue(is_array($documents));
     $this->assertTrue(count($documents) === 1);
     $uoms = $product->getUoms();
     $this->assertTrue(is_array($uoms));
     $this->assertTrue(count($uoms) === 1);
     $specs = $product->getSpecs();
     $this->assertTrue(is_array($specs));
     $this->assertTrue(count($specs) === 1);
     $manufacturer = $product->getManufacturer();
     $this->assertInstanceOf('\\SpeckCatalog\\Model\\Company', $manufacturer);
 }
 public function testCreateCartItemCreatesAndPopulatesMetadataObject()
 {
     $service = $this->getService();
     $mockProductUomService = $this->getMockProductUomService();
     $service->setProductUomService($mockProductUomService);
     $testItem = new \SpeckCatalog\Model\Product\Relational();
     $testItem->setName('foo');
     $return = $service->createCartItem($testItem, null, '1:EA:1');
     $meta = $return->getMetadata();
     $this->assertInstanceOf('\\SpeckCatalog\\Model\\CartItemMeta', $meta);
     $this->assertEquals($meta->getUom(), '1:EA:1');
 }