26 $configMock = $this->createMock(\
Magento\Catalog\Model\ProductOptions\ConfigInterface::class);
27 $storeManagerMock = $this->createMock(\
Magento\
Store\Model\StoreManagerInterface::class);
28 $priceConfigMock = new \Magento\Catalog\Model\Config\Source\Product\Options\Price($storeManagerMock);
31 'label' =>
'group label 1',
34 'label' =>
'label 1.1',
41 'label' =>
'group label 2',
44 'label' =>
'label 2.2',
51 $configMock->expects($this->once())->method(
'getAll')->will($this->returnValue(
$config));
52 $this->validator = new \Magento\Catalog\Model\Product\Option\Validator\DefaultValidator(
64 $mess = [
'option required fields' =>
'Missed values for option required fields'];
66 [
'option_title',
'name 1.1',
'fixed', new \Magento\Framework\DataObject([
'store_id' => 1]), [],
true],
67 [
'option_title',
'name 1.1',
'fixed', new \Magento\Framework\DataObject([
'store_id' => 0]), [],
true],
68 [
null,
'name 1.1',
'fixed', new \Magento\Framework\DataObject([
'store_id' => 1]), [],
true],
69 [
null,
'name 1.1',
'fixed', new \Magento\Framework\DataObject([
'store_id' => 0]), $mess,
false],
84 $methods = [
'getTitle',
'getType',
'getPriceType',
'__wakeup',
'getProduct'];
86 $valueMock->expects($this->once())->method(
'getTitle')->will($this->returnValue(
$title));
87 $valueMock->expects($this->any())->method(
'getType')->will($this->returnValue(
$type));
88 $valueMock->expects($this->once())->method(
'getPriceType')->will($this->returnValue(
$priceType));
90 $valueMock->expects($this->once())->method(
'getProduct')->will($this->returnValue(
$product));
92 $this->assertEquals($messages, $this->validator->getMessages());
103 [new \Magento\Framework\DataObject([
'store_id' => 1])],
104 [new \Magento\Framework\DataObject([
'store_id' => 0])],
114 $methods = [
'getTitle',
'getType',
'getPriceType',
'getPrice',
'__wakeup',
'getProduct'];
116 $valueMock->expects($this->once())->method(
'getProduct')->will($this->returnValue(
$product));
117 $valueMock->expects($this->once())->method(
'getTitle');
118 $valueMock->expects($this->any())->method(
'getType');
119 $valueMock->expects($this->once())->method(
'getPriceType')->will($this->returnValue(
'some_new_value'));
120 $valueMock->expects($this->never())->method(
'getPrice');
122 'option required fields' =>
'Missed values for option required fields',
123 'option type' =>
'Invalid option type',
124 'option values' =>
'Invalid option value',
126 $this->assertFalse($this->validator->isValid(
$valueMock));
127 $this->assertEquals($messages, $this->validator->getMessages());
testIsValidTitle($title, $type, $priceType, $product, $messages, $result)
isValidFailDataProvider()
isValidTitleDataProvider()
testIsValidFail($product)