36 protected function setUp()
40 $fileSize = $this->objectManager->create(\
Magento\Framework\
File\Size::class);
41 $this->maxFileSizeInMb = $fileSize->getMaxFileSizeInMb();
43 $this->validateFactoryMock = $this->createPartialMock(
47 $this->model = $this->objectManager->create(
50 'validateFactory' => $this->validateFactoryMock,
60 $this->expectException(\
Magento\Framework\
Exception\LocalizedException::class);
61 $this->expectExceptionMessage(
62 "The file 'test.jpg' for 'MediaOption' has an invalid extension.\n" 63 .
"The file 'test.jpg' for 'MediaOption' has an invalid extension.\n" 64 .
"The maximum allowed image size for 'MediaOption' is 2000x2000 px.\n" 66 "The file 'test.jpg' you uploaded is larger than the %s megabytes allowed by our server.",
67 $this->maxFileSizeInMb
71 $validateMock = $this->createPartialMock(\Zend_Validate::class, [
'isValid',
'getErrors']);
72 $validateMock->expects($this->once())->method(
'isValid')->will($this->returnValue(
false));
73 $validateMock->expects($this->exactly(2))->method(
'getErrors')->will($this->returnValue([
79 $this->validateFactoryMock->expects($this->once())
81 ->will($this->returnValue($validateMock));
83 $this->model->validate(
84 $this->getOptionValue(),
94 $this->expectException(\
Magento\Framework\
Exception\LocalizedException::class);
95 $this->expectExceptionMessage(
96 "The product's required option(s) weren't entered. Make sure the options are entered and try again." 99 $validateMock = $this->createPartialMock(\Zend_Validate::class, [
'isValid',
'getErrors']);
100 $validateMock->expects($this->once())->method(
'isValid')->will($this->returnValue(
false));
101 $validateMock->expects($this->exactly(1))->method(
'getErrors')->will($this->returnValue(
false));
102 $this->validateFactoryMock->expects($this->once())
104 ->will($this->returnValue($validateMock));
106 $this->model->validate(
107 $this->getOptionValue(),
118 $validate = $this->objectManager->create(\Zend_Validate::class);
119 $this->validateFactoryMock->expects($this->once())
121 ->will($this->returnValue($validate));
123 $this->model->validate(
124 $this->getOptionValue(),
142 'max_characters' =>
null,
143 'file_extension' =>
null,
144 'image_size_x' =>
'2000',
145 'image_size_y' =>
'2000',
147 'default_title' =>
'MediaOption',
148 'store_title' =>
null,
149 'title' =>
'MediaOption',
150 'default_price' =>
'5.0000',
151 'default_price_type' =>
'fixed',
152 'store_price' =>
null,
153 'store_price_type' =>
null,
155 'price_type' =>
'fixed',
157 $option = $this->objectManager->create(
170 protected function getOptionValue()
174 $file =
$config->getBaseTmpMediaPath() .
'/magento_small_image.jpg';
182 'title' =>
'test.jpg',
183 'quote_path' => $file,
184 'order_path' => $file,
getProductOption(array $options=[])
testExceptionWithErrors()
testExceptionWithoutErrors()
static getObjectManager()