/**
  * @expectedException \InvalidArgumentException
  */
 public function testAddToBasketThrowsException()
 {
     $ay = $this->getAYWithResultFile('result/basket1.json');
     $variant = Variant::createFromJson(json_decode('{"id":123}'), $ay->getResultFactory(), $this->getProduct());
     $ay->addItemToBasket($this->sessionId, $variant);
 }
 /**
  * {@inheritdoc}
  *
  * @return Model\Variant
  */
 public function createVariant(stdClass $jsonObject, Model\Product $product)
 {
     return Model\Variant::createFromJson($jsonObject, $this, $product);
 }
 private function checkVariant(Model\Variant $variant)
 {
     $this->assertInternalType('int', $variant->getId());
     $this->assertGreaterThan(0, count($variant->getFacetIds()));
 }
 public function testGetMaterials()
 {
     $jsonObject = $this->getJsonObject('variant.json');
     $variant = Variant::createFromJson($jsonObject, $this->getModelFactory(), $this->getProduct());
     $materials = $variant->getMaterials();
     $this->assertNull($materials);
     $jsonObject = $this->getJsonObject('variant-with-materials.json');
     $variant = Variant::createFromJson($jsonObject, $this->getModelFactory(), $this->getProduct());
     $materials = $variant->getMaterials();
     $this->assertInternalType('array', $materials);
     $this->assertCount(4, $materials);
     foreach ($materials as $index => $material) {
         $this->assertInstanceOf('\\AboutYou\\SDK\\Model\\Material', $material);
         if ($index === 3) {
             $this->assertNull($material->getName());
         } else {
             $this->assertInternalType('string', $material->getName());
         }
         $compositions = $material->getCompositions();
         $this->assertInternalType('array', $compositions);
         $this->assertContainsOnlyInstancesOf('\\AboutYou\\SDK\\Model\\Composition', $compositions);
     }
     $this->assertEquals('Obermaterial', $materials[0]->getName());
     $this->assertEquals('shell', $materials[0]->getType());
     $this->assertEquals('Futter 1', $materials[1]->getName());
     $this->assertEquals('lining', $materials[1]->getType());
     $this->assertEquals('Füllung', $materials[2]->getName());
     $this->assertNull($materials[2]->getType());
     $compositions = $materials[0]->getCompositions();
     $this->assertCount(2, $compositions);
     $this->assertEquals('baumwolle', $compositions[0]->getName());
     $this->assertEquals(35.0, $compositions[0]->getPercentage());
     $this->assertInternalType('float', $compositions[0]->getPercentage());
     $this->assertEquals('polyester', $compositions[1]->getName());
     $this->assertEquals(65.0, $compositions[1]->getPercentage());
 }