Example #1
0
 /**
  * Attention: this test depends on mock of "is_uploaded_file" function in ./FileTest.php,
  * so validates method successfully in batch run of directory tests, separately will fail.
  *
  * @covers \Magento\Eav\Model\Attribute\Data\Image::_validateByRules
  *
  * @param mixed $value
  * @param mixed $originalValue
  * @param bool $isRequired
  * @param bool $isAjaxRequest
  * @param array $rules
  * @param array $expectedResult
  * @dataProvider validateValueDataProvider
  */
 public function testValidateValue($value, $originalValue, $isRequired, $isAjaxRequest, $rules, $expectedResult)
 {
     $entityMock = $this->getMock('\\Magento\\Framework\\Model\\AbstractModel', [], [], '', false);
     $entityMock->expects($this->any())->method('getData')->will($this->returnValue($originalValue));
     $attributeMock = $this->getMock('\\Magento\\Eav\\Model\\Attribute', [], [], '', false);
     $attributeMock->expects($this->any())->method('getStoreLabel')->will($this->returnValue('Label'));
     $attributeMock->expects($this->any())->method('getIsRequired')->will($this->returnValue($isRequired));
     $attributeMock->expects($this->any())->method('getIsAjaxRequest')->will($this->returnValue($isAjaxRequest));
     $attributeMock->expects($this->any())->method('getValidateRules')->will($this->returnValue($rules));
     $this->model->setEntity($entityMock);
     $this->model->setAttribute($attributeMock);
     $this->model->setIsAjaxRequest($isAjaxRequest);
     $this->assertEquals($expectedResult, $this->model->validateValue($value));
 }
Example #2
0
 /**
  * @covers \Magento\Eav\Model\Attribute\Data\File::validateValue
  * @covers \Magento\Eav\Model\Attribute\Data\File::_validateByRules
  *
  * @param mixed $value
  * @param mixed $originalValue
  * @param bool $isRequired
  * @param bool $isAjaxRequest
  * @param array $rules
  * @param bool $fileIsValid
  * @param array $expectedResult
  * @dataProvider validateValueDataProvider
  */
 public function testValidateValue($value, $originalValue, $isRequired, $isAjaxRequest, $rules, $fileIsValid, $expectedResult)
 {
     $this->markTestSkipped('MAGETWO-34751: Test fails after being moved.  Might have hidden dependency.');
     $entityMock = $this->getMock('\\Magento\\Framework\\Model\\AbstractModel', [], [], '', false);
     $entityMock->expects($this->any())->method('getData')->will($this->returnValue($originalValue));
     $attributeMock = $this->getMock('\\Magento\\Eav\\Model\\Attribute', [], [], '', false);
     $attributeMock->expects($this->any())->method('getStoreLabel')->will($this->returnValue('Label'));
     $attributeMock->expects($this->any())->method('getIsRequired')->will($this->returnValue($isRequired));
     $attributeMock->expects($this->any())->method('getIsAjaxRequest')->will($this->returnValue($isAjaxRequest));
     $attributeMock->expects($this->any())->method('getValidateRules')->will($this->returnValue($rules));
     $this->fileValidatorMock->expects($this->any())->method('isValid')->will($this->returnValue($fileIsValid));
     $this->fileValidatorMock->expects($this->any())->method('getMessages')->will($this->returnValue(['m1', 'm2']));
     $this->model->setEntity($entityMock);
     $this->model->setAttribute($attributeMock);
     $this->model->setIsAjaxRequest($isAjaxRequest);
     $this->assertEquals($expectedResult, $this->model->validateValue($value));
 }