public function testGetValues() { $expected = [1, 2, 3]; $this->source->expects($this->once())->method('getAllOptions')->with(true, true)->willReturn($expected); $this->attribute->expects($this->once())->method('getSource')->willReturn($this->source); $this->swatch->expects($this->once())->method('getData')->with('entity_attribute')->willReturn($this->attribute); $method = new \ReflectionMethod('Magento\\Swatches\\Model\\Form\\Element\\AbstractSwatch', 'getValues'); $method->setAccessible(true); $this->assertEquals($expected, $method->invoke($this->swatch)); }
public function testAfterAfterSaveNotSwatchAttribute() { $this->abstractSource->expects($this->once())->method('getAllOptions')->willReturn($this->allOptions); $this->swatch->expects($this->once())->method('getId')->willReturn(1); $this->swatch->expects($this->once())->method('save'); $this->swatch->expects($this->once())->method('isDeleted')->with(false); $this->swatch->expects($this->exactly(2))->method('setData')->withConsecutive(['type', Swatch::SWATCH_TYPE_TEXTUAL], ['value', null]); $this->collection->expects($this->exactly(2))->method('addFieldToFilter')->withConsecutive(['option_id', self::OPTION_ID], ['store_id', self::OPTION_ID])->willReturnSelf(); $this->collection->expects($this->once())->method('getFirstItem')->willReturn($this->swatch); $this->collectionFactory->expects($this->once())->method('create')->willReturn($this->collection); $this->attribute->expects($this->at(0))->method('getData')->with('option')->willReturn($this->optionIds); $this->attribute->expects($this->at(1))->method('getSource')->willReturn($this->abstractSource); $this->attribute->expects($this->at(2))->method('getData')->with('swatch/value')->willReturn([self::STORE_ID => [self::OPTION_ID => null]]); $this->attribute->expects($this->at(3))->method('getData')->with('option/delete/' . self::OPTION_ID)->willReturn(false); $this->swatchHelper->expects($this->exactly(2))->method('isSwatchAttribute')->with($this->attribute)->will($this->onConsecutiveCalls(true, false)); $this->swatchHelper->expects($this->once())->method('isVisualSwatch')->with($this->attribute)->willReturn(false); $this->swatchHelper->expects($this->once())->method('isTextSwatch')->with($this->attribute)->willReturn(true); $this->eavAttribute->afterAfterSave($this->attribute); }