/** * Test getters and setters. */ public function testGettersAndSetters() { $variant = new VariantObject(); $this->document->setActive(true)->setOldPrice(20.5)->setStock(10)->setVendor('testVendor')->setManufacturer('testManufacturer')->setCategories([1, 3, 2])->setVariants([$variant]); $expectedAttributes = []; $expectedAttributes[0] = new AttributeObject(); $expectedAttributes[0]->setPos(1); $expectedAttributes[0]->setTitle('testTitle1'); $this->document->setAttributes($expectedAttributes); $this->assertEquals(true, $this->document->isActive()); $this->assertEquals(true, $this->document->getActive()); $this->assertEquals(20.5, $this->document->getOldPrice()); $this->assertEquals(10, $this->document->getStock()); $this->assertEquals('testVendor', $this->document->getVendor()); $this->assertEquals('testManufacturer', $this->document->getManufacturer()); $this->assertEquals([1, 3, 2], $this->document->getCategories()); $this->assertSame([$variant], $this->document->getVariants()); $actualAttributes = $this->document->getAttributes(); foreach ($actualAttributes as $idx => $actualAttribute) { $this->assertSame($expectedAttributes[$idx], $actualAttribute); } $this->document->setAttributes(null)->setCategories(null); $this->assertEquals(null, $this->document->getAttributes()); $this->assertEquals(null, $this->document->getCategories()); }