Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
EavAttributeTest.php
Go to the documentation of this file.
1 <?php
8 
11 
12 class EavAttributeTest extends \PHPUnit\Framework\TestCase
13 {
14  const ATTRIBUTE_ID = 123;
15  const OPTION_ID = 'option 12';
16  const STORE_ID = 'option 89';
20 
22  private $eavAttribute;
23 
25  private $attribute;
26 
28  private $swatchFactory;
29 
31  private $collectionFactory;
32 
34  private $swatchHelper;
35 
37  private $abstractSource;
38 
40  private $swatch;
41 
43  private $resource;
44 
46  private $collection;
47 
49  private $optionIds = [];
50 
52  private $allOptions = [];
53 
55  private $dependencyArray = [];
56 
57  protected function setUp()
58  {
59  $this->attribute = $this->createMock(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class);
60  $this->swatchFactory = $this->createPartialMock(\Magento\Swatches\Model\SwatchFactory::class, ['create']);
61  $this->swatchHelper = $this->createMock(\Magento\Swatches\Helper\Data::class);
62  $this->swatch = $this->createMock(\Magento\Swatches\Model\Swatch::class);
63  $this->resource = $this->createMock(\Magento\Swatches\Model\ResourceModel\Swatch::class);
64  $this->collection =
65  $this->createMock(\Magento\Swatches\Model\ResourceModel\Swatch\Collection::class);
66  $this->collectionFactory = $this->createPartialMock(
67  \Magento\Swatches\Model\ResourceModel\Swatch\CollectionFactory::class,
68  ['create']
69  );
70  $this->abstractSource = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Source\AbstractSource::class);
71 
72  $serializer = $this->createPartialMock(
73  \Magento\Framework\Serialize\Serializer\Json::class,
74  ['serialize', 'unserialize']
75  );
76 
77  $serializer->expects($this->any())
78  ->method('serialize')->willReturnCallback(function ($parameter) {
79  return json_encode($parameter);
80  });
81 
82  $serializer->expects($this->any())
83  ->method('unserialize')->willReturnCallback(function ($parameter) {
84  return json_decode($parameter, true);
85  });
86 
87  $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
88  $this->eavAttribute = $objectManager->getObject(
89  \Magento\Swatches\Model\Plugin\EavAttribute::class,
90  [
91  'collectionFactory' => $this->collectionFactory,
92  'swatchFactory' => $this->swatchFactory,
93  'swatchHelper' => $this->swatchHelper,
94  'serializer' => $serializer,
95  ]
96  );
97 
98  $this->optionIds = [
99  'value' => ['option 89' => 'test 1', 'option 114' => 'test 2', 'option 170' => 'test 3'],
100  'delete' => ['option 89' => 0, 'option 114' => 1, 'option 170' => 0],
101  ];
102  $this->allOptions = [null, ['value' => 'option 12'], ['value' => 'option 154']];
103  $this->dependencyArray = ['option 89', 'option 170'];
104  }
105 
106  public function testBeforeSaveVisualSwatch()
107  {
108  $option = [
109  'value' => [
110  0 => 'option value',
111  ]
112  ];
113  $this->attribute->expects($this->exactly(6))->method('getData')->withConsecutive(
114  ['defaultvisual'],
115  ['optionvisual'],
116  ['swatchvisual'],
117  ['optionvisual'],
118  ['option/delete/0']
119  )->will($this->onConsecutiveCalls(
120  self::ATTRIBUTE_DEFAULT_VALUE,
121  self::ATTRIBUTE_OPTION_VALUE,
122  self::ATTRIBUTE_SWATCH_VALUE,
123  $option,
124  false
125  ));
126 
127  $this->attribute->expects($this->exactly(3))->method('setData')
128  ->withConsecutive(
129  ['option', self::ATTRIBUTE_OPTION_VALUE],
130  ['default', self::ATTRIBUTE_DEFAULT_VALUE],
131  ['swatch', self::ATTRIBUTE_SWATCH_VALUE]
132  );
133 
134  $this->swatchHelper->expects($this->once())->method('assembleAdditionalDataEavAttribute')
135  ->with($this->attribute);
136  $this->swatchHelper->expects($this->atLeastOnce())->method('isVisualSwatch')
137  ->with($this->attribute)
138  ->willReturn(true);
139  $this->swatchHelper->expects($this->once())->method('isSwatchAttribute')
140  ->with($this->attribute)
141  ->willReturn(true);
142  $this->swatchHelper->expects($this->never())->method('isTextSwatch');
143 
144  $this->eavAttribute->beforeBeforeSave($this->attribute);
145  }
146 
147  public function testBeforeSaveTextSwatch()
148  {
149  $option = [
150  'value' => [
151  0 => 'option value',
152  ]
153  ];
154  $this->attribute->expects($this->exactly(6))->method('getData')->withConsecutive(
155  ['defaulttext'],
156  ['optiontext'],
157  ['swatchtext'],
158  ['optiontext'],
159  ['option/delete/0']
160  )->will(
161  $this->onConsecutiveCalls(
162  self::ATTRIBUTE_DEFAULT_VALUE,
163  self::ATTRIBUTE_OPTION_VALUE,
164  self::ATTRIBUTE_SWATCH_VALUE,
165  $option,
166  false
167  )
168  );
169 
170  $this->attribute->expects($this->exactly(3))->method('setData')
171  ->withConsecutive(
172  ['option', self::ATTRIBUTE_OPTION_VALUE],
173  ['default', self::ATTRIBUTE_DEFAULT_VALUE],
174  ['swatch', self::ATTRIBUTE_SWATCH_VALUE]
175  );
176 
177  $this->swatchHelper->expects($this->once())->method('assembleAdditionalDataEavAttribute')
178  ->with($this->attribute);
179  $this->swatchHelper->expects($this->atLeastOnce())->method('isVisualSwatch')
180  ->with($this->attribute)
181  ->willReturn(false);
182  $this->swatchHelper->expects($this->atLeastOnce())->method('isTextSwatch')
183  ->with($this->attribute)
184  ->willReturn(true);
185  $this->swatchHelper->expects($this->once())->method('isSwatchAttribute')
186  ->with($this->attribute)
187  ->willReturn(true);
188 
189  $this->eavAttribute->beforeBeforeSave($this->attribute);
190  }
191 
197  {
198  $optionText = [
199  'value' => [
200  0 => '',
201  ]
202  ];
203  $this->swatchHelper->expects($this->once())
204  ->method('isSwatchAttribute')
205  ->with($this->attribute)
206  ->willReturn(true);
207 
208  $this->swatchHelper->expects($this->atLeastOnce())
209  ->method('isVisualSwatch')
210  ->willReturn(true);
211  $this->attribute->expects($this->exactly(5))
212  ->method('getData')
213  ->withConsecutive(
214  ['defaultvisual'],
215  ['optionvisual'],
216  ['swatchvisual'],
217  ['optionvisual'],
218  ['option/delete/0']
219  )
220  ->will(
221  $this->onConsecutiveCalls(
222  self::ATTRIBUTE_DEFAULT_VALUE,
223  self::ATTRIBUTE_OPTION_VALUE,
224  self::ATTRIBUTE_SWATCH_VALUE,
225  $optionText,
226  false
227  )
228  );
229 
230  $this->eavAttribute->beforeBeforeSave($this->attribute);
231  }
232 
237  {
238  $optionText = [
239  'value' => [
240  0 => '',
241  ]
242  ];
243 
244  $this->swatchHelper->expects($this->once())
245  ->method('isSwatchAttribute')
246  ->with($this->attribute)
247  ->willReturn(true);
248 
249  $this->swatchHelper->expects($this->atLeastOnce())
250  ->method('isVisualSwatch')
251  ->willReturn(true);
252  $this->attribute->expects($this->exactly(6))
253  ->method('getData')
254  ->withConsecutive(
255  ['defaultvisual'],
256  ['optionvisual'],
257  ['swatchvisual'],
258  ['optionvisual'],
259  ['option/delete/0'],
260  ['swatch_input_type']
261  )
262  ->will(
263  $this->onConsecutiveCalls(
264  self::ATTRIBUTE_DEFAULT_VALUE,
265  self::ATTRIBUTE_OPTION_VALUE,
266  self::ATTRIBUTE_SWATCH_VALUE,
267  $optionText,
268  true,
269  false
270  )
271  );
272  $this->eavAttribute->beforeBeforeSave($this->attribute);
273  }
274 
275  public function testBeforeSaveNotSwatch()
276  {
277  $additionalData = [
278  'swatch_input_type' => 'visual',
279  'update_product_preview_image' => 1,
280  'use_product_image_for_swatch' => 0
281  ];
282 
283  $shortAdditionalData = [
284  'update_product_preview_image' => 1,
285  'use_product_image_for_swatch' => 0
286  ];
287 
288  $this->attribute->expects($this->exactly(2))->method('getData')->withConsecutive(
290  ['additional_data']
291  )->willReturnOnConsecutiveCalls(
293  json_encode($additionalData)
294  );
295 
296  $this->attribute
297  ->expects($this->once())
298  ->method('setData')
299  ->with('additional_data', json_encode($shortAdditionalData))
300  ->will($this->returnSelf());
301 
302  $this->swatchHelper->expects($this->never())->method('assembleAdditionalDataEavAttribute');
303  $this->swatchHelper->expects($this->never())->method('isVisualSwatch');
304  $this->swatchHelper->expects($this->never())->method('isTextSwatch');
305 
306  $this->swatchHelper->expects($this->once())->method('isSwatchAttribute')
307  ->with($this->attribute)
308  ->willReturn(false);
309 
310  $this->eavAttribute->beforeBeforeSave($this->attribute);
311  }
312 
316  public function visualSwatchProvider()
317  {
318  return [
322  ];
323  }
324 
331  public function testAfterAfterSaveVisualSwatch($swatchType, $swatchValue)
332  {
333  $this->abstractSource->expects($this->once())->method('getAllOptions')
334  ->willReturn($this->allOptions);
335  $this->resource->expects($this->once())->method('saveDefaultSwatchOption')
336  ->with(self::ATTRIBUTE_ID, self::OPTION_ID);
337 
338  $this->swatch->expects($this->once())->method('getResource')
339  ->willReturn($this->resource);
340  $this->swatch->expects($this->once())->method('getId')
341  ->willReturn(EavAttribute::DEFAULT_STORE_ID);
342  $this->swatch->expects($this->once())->method('save');
343  $this->swatch->expects($this->exactly(4))->method('setData')
344  ->withConsecutive(
345  ['option_id', self::OPTION_ID],
346  ['store_id', EavAttribute::DEFAULT_STORE_ID],
347  ['type', $swatchType],
348  ['value', $swatchValue]
349  );
350 
351  $this->collection->expects($this->exactly(2))->method('addFieldToFilter')
352  ->withConsecutive(
353  ['option_id', self::OPTION_ID],
354  ['store_id', EavAttribute::DEFAULT_STORE_ID]
355  )->willReturnSelf();
356 
357  $this->collection->expects($this->once())->method('getFirstItem')
358  ->willReturn($this->swatch);
359  $this->collectionFactory->expects($this->once())->method('create')
360  ->willReturn($this->collection);
361 
362  $this->attribute->expects($this->at(0))->method('getData')
363  ->willReturn($this->optionIds);
364  $this->attribute->expects($this->at(1))->method('getSource')
365  ->willReturn($this->abstractSource);
366  $this->attribute->expects($this->at(2))->method('getData')
367  ->with('default/0')
368  ->willReturn($this->dependencyArray[0]);
369  $this->attribute->expects($this->at(3))->method('getId')
370  ->willReturn(self::ATTRIBUTE_ID);
371  $this->attribute->expects($this->at(4))->method('getData')
372  ->with('swatch/value')
373  ->willReturn([self::STORE_ID => $swatchValue]);
374  $this->attribute->expects($this->at(5))->method('getData')
375  ->with('option/delete/' . self::OPTION_ID)
376  ->willReturn(false);
377 
378  $this->swatchFactory->expects($this->exactly(1))->method('create')
379  ->willReturn($this->swatch);
380  $this->swatchHelper->expects($this->exactly(2))->method('isSwatchAttribute')
381  ->with($this->attribute)
382  ->willReturn(true);
383  $this->swatchHelper->expects($this->once())->method('isVisualSwatch')
384  ->with($this->attribute)
385  ->willReturn(true);
386  $this->swatchHelper->expects($this->never())->method('isTextSwatch');
387 
388  $this->eavAttribute->afterAfterSave($this->attribute);
389  }
390 
392  {
393  $this->abstractSource->expects($this->once())->method('getAllOptions')
394  ->willReturn($this->allOptions);
395 
396  $this->swatch->expects($this->any())->method('getId')
397  ->willReturn(EavAttribute::DEFAULT_STORE_ID);
398  $this->swatch->expects($this->any())->method('save');
399  $this->swatch->expects($this->any())->method('isDeleted')
400  ->with(false);
401 
402  $this->collection->expects($this->any())->method('addFieldToFilter')
403  ->willReturnSelf();
404  $this->collection->expects($this->any())->method('getFirstItem')
405  ->willReturn($this->swatch);
406  $this->collectionFactory->expects($this->any())->method('create')
407  ->willReturn($this->collection);
408 
409  $this->attribute->expects($this->at(0))->method('getData')
410  ->willReturn($this->optionIds);
411  $this->attribute->expects($this->at(1))->method('getSource')
412  ->willReturn($this->abstractSource);
413  $this->attribute->expects($this->at(2))->method('getData')
414  ->with('default/0')
415  ->willReturn(null);
416 
417  $this->attribute->expects($this->at(3))->method('getData')
418  ->with('swatch/value')
419  ->willReturn(
420  [
421  self::STORE_ID => [
422  1 => "test",
423  2 => false,
424  3 => null,
425  4 => "",
426  ]
427  ]
428  );
429 
430  $this->swatchHelper->expects($this->exactly(2))->method('isSwatchAttribute')
431  ->with($this->attribute)
432  ->willReturn(true);
433  $this->swatchHelper->expects($this->once())->method('isVisualSwatch')
434  ->with($this->attribute)
435  ->willReturn(false);
436  $this->swatchHelper->expects($this->once())->method('isTextSwatch')
437  ->with($this->attribute)
438  ->willReturn(true);
439 
440  $this->swatch->expects($this->any())->method('setData')
441  ->withConsecutive(
442  ['option_id', self::OPTION_ID],
443  ['store_id', 1],
444  ['type', Swatch::SWATCH_TYPE_TEXTUAL],
445  ['value', "test"]
446  );
447 
448  $this->eavAttribute->afterAfterSave($this->attribute);
449  }
450 
452  {
453  $this->abstractSource->expects($this->once())->method('getAllOptions')
454  ->willReturn($this->allOptions);
455  $this->resource->expects($this->once())->method('saveDefaultSwatchOption')
456  ->with(self::ATTRIBUTE_ID, self::OPTION_ID);
457 
458  $this->swatch->expects($this->once())->method('getResource')
459  ->willReturn($this->resource);
460  $this->swatch->expects($this->once())->method('getId')
461  ->willReturn(EavAttribute::DEFAULT_STORE_ID);
462  $this->swatch->expects($this->once())->method('save');
463  $this->swatch->expects($this->once())->method('isDeleted')
464  ->with(false);
465  $this->swatch->expects($this->exactly(4))->method('setData')
466  ->withConsecutive(
467  ['option_id', self::OPTION_ID],
468  ['store_id', self::OPTION_ID],
469  ['type', Swatch::SWATCH_TYPE_TEXTUAL],
470  ['value', null]
471  );
472 
473  $this->collection->expects($this->exactly(2))->method('addFieldToFilter')
474  ->withConsecutive(
475  ['option_id', self::OPTION_ID],
476  ['store_id', self::OPTION_ID]
477  )->willReturnSelf();
478  $this->collection->expects($this->once())->method('getFirstItem')
479  ->willReturn($this->swatch);
480  $this->collectionFactory->expects($this->once())->method('create')
481  ->willReturn($this->collection);
482 
483  $this->attribute->expects($this->at(0))->method('getData')
484  ->willReturn($this->optionIds);
485  $this->attribute->expects($this->at(1))->method('getSource')
486  ->willReturn($this->abstractSource);
487  $this->attribute->expects($this->at(2))->method('getData')
488  ->with('default/0')
489  ->willReturn($this->dependencyArray[0]);
490  $this->attribute->expects($this->at(3))->method('getId')
491  ->willReturn(self::ATTRIBUTE_ID);
492  $this->attribute->expects($this->at(4))->method('getData')
493  ->with('swatch/value')
494  ->willReturn([self::STORE_ID => [self::OPTION_ID => null]]);
495  $this->attribute->expects($this->at(5))->method('getData')
496  ->with('option/delete/' . self::OPTION_ID)
497  ->willReturn(false);
498 
499  $this->swatchFactory->expects($this->exactly(1))->method('create')
500  ->willReturn($this->swatch);
501  $this->swatchHelper->expects($this->exactly(2))->method('isSwatchAttribute')
502  ->with($this->attribute)
503  ->willReturn(true);
504  $this->swatchHelper->expects($this->once())->method('isVisualSwatch')
505  ->with($this->attribute)
506  ->willReturn(false);
507  $this->swatchHelper->expects($this->once())->method('isTextSwatch')
508  ->with($this->attribute)
509  ->willReturn(true);
510 
511  $this->eavAttribute->afterAfterSave($this->attribute);
512  }
513 
515  {
516  $this->abstractSource->expects($this->once())->method('getAllOptions')
517  ->willReturn($this->allOptions);
518  $this->resource->expects($this->once())->method('saveDefaultSwatchOption')
519  ->with(self::ATTRIBUTE_ID, self::OPTION_ID);
520 
521  $this->swatch->expects($this->once())->method('getResource')
522  ->willReturn($this->resource);
523 
524  $this->attribute->expects($this->at(0))->method('getData')
525  ->willReturn($this->optionIds);
526  $this->attribute->expects($this->at(1))->method('getSource')
527  ->willReturn($this->abstractSource);
528  $this->attribute->expects($this->at(2))->method('getData')
529  ->with('default/0')
530  ->willReturn($this->dependencyArray[0]);
531  $this->attribute->expects($this->at(3))->method('getId')
532  ->willReturn(self::ATTRIBUTE_ID);
533  $this->attribute->expects($this->at(4))->method('getData')
534  ->with('swatch/value')
535  ->willReturn([self::STORE_ID => null]);
536  $this->attribute->expects($this->at(5))->method('getData')
537  ->with('option/delete/' . self::OPTION_ID)
538  ->willReturn(true);
539 
540  $this->swatchFactory->expects($this->once())->method('create')
541  ->willReturn($this->swatch);
542  $this->swatchHelper->expects($this->exactly(2))->method('isSwatchAttribute')
543  ->with($this->attribute)
544  ->willReturn(true);
545  $this->swatchHelper->expects($this->once())->method('isVisualSwatch')
546  ->with($this->attribute)
547  ->willReturn(true);
548  $this->swatchHelper->expects($this->never())->method('isTextSwatch');
549 
550  $this->eavAttribute->afterAfterSave($this->attribute);
551  }
552 
554  {
555  $this->abstractSource->expects($this->once())->method('getAllOptions')
556  ->willReturn($this->allOptions);
557  $this->resource->expects($this->once())->method('saveDefaultSwatchOption')
558  ->with(self::ATTRIBUTE_ID, self::OPTION_ID);
559 
560  $this->swatch->expects($this->once())->method('getResource')
561  ->willReturn($this->resource);
562 
563  $this->attribute->expects($this->at(0))->method('getData')
564  ->willReturn($this->optionIds);
565  $this->attribute->expects($this->at(1))->method('getSource')
566  ->willReturn($this->abstractSource);
567  $this->attribute->expects($this->at(2))->method('getData')
568  ->with('default/0')
569  ->willReturn($this->dependencyArray[0]);
570  $this->attribute->expects($this->at(3))->method('getId')
571  ->willReturn(self::ATTRIBUTE_ID);
572  $this->attribute->expects($this->at(4))->method('getData')
573  ->with('swatch/value')
574  ->willReturn([self::STORE_ID => [self::OPTION_ID => null]]);
575  $this->attribute->expects($this->at(5))->method('getData')
576  ->with('option/delete/' . self::OPTION_ID)
577  ->willReturn(true);
578 
579  $this->swatchFactory->expects($this->once())->method('create')
580  ->willReturn($this->swatch);
581  $this->swatchHelper->expects($this->exactly(2))->method('isSwatchAttribute')
582  ->with($this->attribute)
583  ->willReturn(true);
584  $this->swatchHelper->expects($this->once())->method('isVisualSwatch')
585  ->with($this->attribute)
586  ->willReturn(false);
587  $this->swatchHelper->expects($this->once())->method('isTextSwatch')
588  ->with($this->attribute)
589  ->willReturn(true);
590 
591  $this->eavAttribute->afterAfterSave($this->attribute);
592  }
593 
595  {
596  $this->abstractSource->expects($this->once())->method('getAllOptions')
597  ->willReturn($this->allOptions);
598  $this->resource->expects($this->once())->method('saveDefaultSwatchOption')
599  ->with(self::ATTRIBUTE_ID, self::OPTION_ID);
600 
601  $this->swatch->expects($this->once())->method('getResource')
602  ->willReturn($this->resource);
603  $this->swatch->expects($this->once())->method('getId')
604  ->willReturn(1);
605  $this->swatch->expects($this->once())->method('save');
606  $this->swatch->expects($this->once())->method('isDeleted')
607  ->with(false);
608  $this->swatch->expects($this->exactly(2))->method('setData')
609  ->withConsecutive(
610  ['type', Swatch::SWATCH_TYPE_TEXTUAL],
611  ['value', null]
612  );
613 
614  $this->collection->expects($this->exactly(2))->method('addFieldToFilter')
615  ->withConsecutive(
616  ['option_id', self::OPTION_ID],
617  ['store_id', self::OPTION_ID]
618  )->willReturnSelf();
619  $this->collection->expects($this->once())->method('getFirstItem')
620  ->willReturn($this->swatch);
621  $this->collectionFactory->expects($this->once())->method('create')
622  ->willReturn($this->collection);
623 
624  $this->attribute->expects($this->at(0))->method('getData')
625  ->willReturn($this->optionIds);
626  $this->attribute->expects($this->at(1))->method('getSource')
627  ->willReturn($this->abstractSource);
628  $this->attribute->expects($this->at(2))->method('getData')
629  ->with('default/0')
630  ->willReturn($this->dependencyArray[0]);
631  $this->attribute->expects($this->at(3))->method('getId')
632  ->willReturn(self::ATTRIBUTE_ID);
633  $this->attribute->expects($this->at(4))->method('getData')
634  ->with('swatch/value')
635  ->willReturn([self::STORE_ID => [self::OPTION_ID => null]]);
636  $this->attribute->expects($this->at(5))->method('getData')
637  ->with('option/delete/' . self::OPTION_ID)
638  ->willReturn(false);
639 
640  $this->swatchFactory->expects($this->exactly(1))->method('create')
641  ->willReturn($this->swatch);
642  $this->swatchHelper->expects($this->exactly(2))->method('isSwatchAttribute')
643  ->with($this->attribute)
644  ->willReturn(true);
645  $this->swatchHelper->expects($this->once())->method('isVisualSwatch')
646  ->with($this->attribute)
647  ->willReturn(false);
648  $this->swatchHelper->expects($this->once())->method('isTextSwatch')
649  ->with($this->attribute)
650  ->willReturn(true);
651 
652  $this->eavAttribute->afterAfterSave($this->attribute);
653  }
654 
656  {
657  $this->abstractSource->expects($this->once())->method('getAllOptions')
658  ->willReturn($this->allOptions);
659 
660  $this->swatch->expects($this->once())->method('getId')
661  ->willReturn(1);
662  $this->swatch->expects($this->once())->method('save');
663  $this->swatch->expects($this->once())->method('isDeleted')
664  ->with(false);
665  $this->swatch->expects($this->exactly(2))->method('setData')
666  ->withConsecutive(
667  ['type', Swatch::SWATCH_TYPE_TEXTUAL],
668  ['value', null]
669  );
670 
671  $this->collection->expects($this->exactly(2))->method('addFieldToFilter')
672  ->withConsecutive(
673  ['option_id', self::OPTION_ID],
674  ['store_id', self::OPTION_ID]
675  )->willReturnSelf();
676  $this->collection->expects($this->once())->method('getFirstItem')
677  ->willReturn($this->swatch);
678  $this->collectionFactory->expects($this->once())->method('create')
679  ->willReturn($this->collection);
680 
681  $this->attribute->expects($this->at(0))->method('getData')
682  ->with('option')
683  ->willReturn($this->optionIds);
684  $this->attribute->expects($this->at(1))->method('getSource')
685  ->willReturn($this->abstractSource);
686  $this->attribute->expects($this->at(2))->method('getData')
687  ->with('swatch/value')
688  ->willReturn([self::STORE_ID => [self::OPTION_ID => null]]);
689  $this->attribute->expects($this->at(3))->method('getData')
690  ->with('option/delete/' . self::OPTION_ID)
691  ->willReturn(false);
692 
693  $this->swatchHelper->expects($this->exactly(2))->method('isSwatchAttribute')
694  ->with($this->attribute)
695  ->will($this->onConsecutiveCalls(true, false));
696  $this->swatchHelper->expects($this->once())->method('isVisualSwatch')
697  ->with($this->attribute)
698  ->willReturn(false);
699  $this->swatchHelper->expects($this->once())->method('isTextSwatch')
700  ->with($this->attribute)
701  ->willReturn(true);
702 
703  $this->eavAttribute->afterAfterSave($this->attribute);
704  }
705 }
$objectManager
Definition: bootstrap.php:17