/**
  * Run test validate
  *
  * @param $commentDataMap
  * @param $commentData
  * @param $expectedWarnings
  * @dataProvider providerCommentData
  */
 public function testValidate($commentDataMap, $commentData, $expectedWarnings)
 {
     $this->commentModelMock->expects($this->any())->method('hasData')->will($this->returnValueMap($commentDataMap));
     $this->commentModelMock->expects($this->once())->method('getData')->will($this->returnValue($commentData));
     $actualWarnings = $this->validator->validate($this->commentModelMock);
     $this->assertEquals($expectedWarnings, $actualWarnings);
 }
 /**
  * Test _beforeSaveMethod via save()
  */
 public function testSave()
 {
     $this->validatorMock->expects($this->once())->method('validate')->with($this->equalTo($this->commentModelMock))->will($this->returnValue([]));
     $this->commentModelMock->expects($this->any())->method('getData')->willReturn([]);
     $this->commentResource->save($this->commentModelMock);
     $this->assertTrue(true);
 }
Beispiel #3
0
 /**
  * Set up
  */
 protected function setUp()
 {
     $this->commentModelMock = $this->getMock('Magento\\Sales\\Model\\Order\\Shipment\\Comment', [], [], '', false);
     $this->appResourceMock = $this->getMock('Magento\\Framework\\App\\Resource', [], [], '', false);
     $this->adapterMock = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', [], [], '', false);
     $this->validatorMock = $this->getMock('Magento\\Sales\\Model\\Order\\Shipment\\Comment\\Validator', [], [], '', false);
     $this->appResourceMock->expects($this->any())->method('getConnection')->will($this->returnValue($this->adapterMock));
     $this->adapterMock->expects($this->any())->method('describeTable')->will($this->returnValue([]));
     $this->adapterMock->expects($this->any())->method('insert');
     $this->adapterMock->expects($this->any())->method('lastInsertId');
     $this->commentModelMock->expects($this->any())->method('hasDataChanges')->will($this->returnValue(true));
     $this->commentModelMock->expects($this->any())->method('isSaveAllowed')->will($this->returnValue(true));
     $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
     $this->commentResource = $objectManager->getObject('Magento\\Sales\\Model\\Resource\\Order\\Shipment\\Comment', ['resource' => $this->appResourceMock, 'validator' => $this->validatorMock]);
 }
Beispiel #4
0
 /**
  * Test shipment add comment service
  */
 public function testInvoke()
 {
     $this->commentConverterMock->expects($this->once())->method('getModel')->with($this->equalTo($this->dataObjectMock))->will($this->returnValue($this->dataModelMock));
     $this->dataModelMock->expects($this->once())->method('save');
     $this->assertTrue($this->shipmentAddComment->invoke($this->dataObjectMock));
 }