public function testValidationNegativePrice()
 {
     $this->valueMock->expects($this->once())->method('getTitle')->will($this->returnValue('option_title'));
     $this->valueMock->expects($this->exactly(2))->method('getType')->will($this->returnValue('name 1.1'));
     $this->valueMock->expects($this->once())->method('getPriceType')->will($this->returnValue('fixed'));
     $this->valueMock->expects($this->once())->method('getPrice')->will($this->returnValue(-12));
     $messages = ['option values' => 'Invalid option value'];
     $this->assertFalse($this->validator->isValid($this->valueMock));
     $this->assertEquals($messages, $this->validator->getMessages());
 }
Exemplo n.º 2
0
 /**
  * @param $title
  * @param $type
  * @param $priceType
  * @param $price
  * @param $product
  * @dataProvider validationNegativePriceDataProvider
  */
 public function testValidationNegativePrice($title, $type, $priceType, $price, $product)
 {
     $methods = ['getTitle', 'getType', 'getPriceType', 'getPrice', '__wakeup', 'getProduct'];
     $valueMock = $this->getMock('Magento\\Catalog\\Model\\Product\\Option', $methods, [], '', false);
     $valueMock->expects($this->once())->method('getTitle')->will($this->returnValue($title));
     $valueMock->expects($this->exactly(2))->method('getType')->will($this->returnValue($type));
     $valueMock->expects($this->once())->method('getPriceType')->will($this->returnValue($priceType));
     $valueMock->expects($this->once())->method('getPrice')->will($this->returnValue($price));
     $valueMock->expects($this->once())->method('getProduct')->will($this->returnValue($product));
     $messages = ['option values' => 'Invalid option value'];
     $this->assertFalse($this->validator->isValid($valueMock));
     $this->assertEquals($messages, $this->validator->getMessages());
 }