public function testAroundValidateWithVariationsAndRequiredAttributes() { $matrix = [['data1', 'data2', 'configurable_attribute' => ['data1']], ['data3', 'data4', 'configurable_attribute' => ['data3']], ['data5', 'data6', 'configurable_attribute' => ['data5']]]; $this->productMock->expects($this->any())->method('getData')->will($this->returnValueMap([['code1', null, 'value_code_1'], ['code2', null, 'value_code_2'], ['code3', null, 'value_code_3'], ['code4', null, 'value_code_4'], ['code5', null, 'value_code_5']])); $this->requestMock->expects($this->once())->method('getPost')->with('variations-matrix')->will($this->returnValue($matrix)); $attribute1 = $this->createAttribute('code1', true, true); $attribute2 = $this->createAttribute('code2', true, false); $attribute3 = $this->createAttribute('code3', false, true); $attribute4 = $this->createAttribute('code4', false, false); $attribute5 = $this->createAttribute('code5', true, true); $attributes = [$attribute1, $attribute2, $attribute3, $attribute4, $attribute5]; $requiredAttributes = ['code1' => 'value_code_1', 'code5' => 'value_code_5']; $product1 = $this->createProduct(0, 1); $product1->expects($this->at(1))->method('addData')->with($requiredAttributes)->will($this->returnSelf()); $product1->expects($this->at(2))->method('addData')->with($matrix[0])->will($this->returnSelf()); $product2 = $this->createProduct(1, 2); $product2->expects($this->at(1))->method('addData')->with($requiredAttributes)->will($this->returnSelf()); $product2->expects($this->at(2))->method('addData')->with($matrix[1])->will($this->returnSelf()); $product3 = $this->createProduct(2, 3); $product3->expects($this->at(1))->method('addData')->with($requiredAttributes)->will($this->returnSelf()); $product3->expects($this->at(2))->method('addData')->with($matrix[2])->will($this->returnSelf()); $this->productMock->expects($this->exactly(3))->method('getAttributes')->will($this->returnValue($attributes)); $this->responseMock->expects($this->never())->method('setError'); $result = $this->plugin->aroundValidate($this->subjectMock, $this->closureMock, $this->productMock, $this->requestMock, $this->responseMock); $this->assertEquals($this->proceedResult, $result); }
public function testAroundValidateIfVariationsNotExist() { $this->requestMock->expects($this->once())->method('getPost')->with('variations-matrix')->will($this->returnValue(null)); $this->eventManagerMock->expects($this->never())->method('dispatch'); $this->plugin->aroundValidate($this->subjectMock, $this->closureMock, $this->productMock, $this->requestMock, $this->responseMock); }