Exemple #1
0
 public function testSetAndSaveItemOptions()
 {
     $this->assertEmpty($this->model->getOptions());
     $firstOptionMock = $this->getMockBuilder('Magento\\Wishlist\\Model\\Item\\Option')->disableOriginalConstructor()->setMethods(['getCode', 'isDeleted', 'delete', '__wakeup'])->getMock();
     $firstOptionMock->expects($this->any())->method('getCode')->willReturn('first_code');
     $firstOptionMock->expects($this->any())->method('isDeleted')->willReturn(true);
     $firstOptionMock->expects($this->once())->method('delete');
     $secondOptionMock = $this->getMockBuilder('Magento\\Wishlist\\Model\\Item\\Option')->disableOriginalConstructor()->setMethods(['getCode', 'save', '__wakeup'])->getMock();
     $secondOptionMock->expects($this->any())->method('getCode')->willReturn('second_code');
     $secondOptionMock->expects($this->once())->method('save');
     $this->model->setOptions([$firstOptionMock, $secondOptionMock]);
     $this->assertNull($this->model->isOptionsSaved());
     $this->model->saveItemOptions();
     $this->assertTrue($this->model->isOptionsSaved());
 }