/** * @return void */ public function testValidateWithNoValue() { $this->product->setData('attribute', 'color'); $this->product->setData('value_parsed', '1'); $this->product->setData('operator', '!='); $this->productModel->expects($this->once())->method('getData')->with('color')->willReturn(null); $this->assertFalse($this->product->validate($this->productModel)); }
/** * @dataProvider validateDataProvider * * @param string $attributeValue * @param string|array $parsedValue * @param string $newValue * @param string $operator * @param array $input */ public function testValidateWithDatetimeValue($attributeValue, $parsedValue, $newValue, $operator, $input) { $this->product->setData('attribute', 'attribute_key'); $this->product->setData('value_parsed', $parsedValue); $this->product->setData('operator', $operator); $this->config->expects($this->any())->method('getAttribute')->will($this->returnValue($this->eavAttributeResource)); $this->eavAttributeResource->expects($this->any())->method('isScopeGlobal')->will($this->returnValue(false)); $this->eavAttributeResource->expects($this->any())->method($input['method'])->will($this->returnValue($input['type'])); $this->productModel->expects($this->any())->method('hasData')->will($this->returnValue(true)); $this->productModel->expects($this->at(0))->method('getData')->will($this->returnValue(['1' => ['1' => $attributeValue]])); $this->productModel->expects($this->any())->method('getData')->will($this->returnValue($newValue)); $this->productModel->expects($this->any())->method('getId')->will($this->returnValue('1')); $this->productModel->expects($this->once())->method('getStoreId')->will($this->returnValue('1')); $this->productModel->expects($this->any())->method('getResource')->will($this->returnValue($this->productResource)); $this->productResource->expects($this->any())->method('getAttribute')->will($this->returnValue($this->eavAttributeResource)); $this->product->collectValidatedAttributes($this->productModel); $this->assertTrue($this->product->validate($this->productModel)); }