コード例 #1
0
 /**
  * Run test validate
  *
  * @param $trackDataMap
  * @param $trackData
  * @param $expectedWarnings
  * @dataProvider providerTrackData
  */
 public function testValidate($trackDataMap, $trackData, $expectedWarnings)
 {
     $this->trackModelMock->expects($this->any())->method('hasData')->will($this->returnValueMap($trackDataMap));
     $this->trackModelMock->expects($this->once())->method('getData')->will($this->returnValue($trackData));
     $actualWarnings = $this->validator->validate($this->trackModelMock);
     $this->assertEquals($expectedWarnings, $actualWarnings);
 }
コード例 #2
0
 /**
  * Test _beforeSaveMethod via save() with failed validation
  *
  * @expectedException \Magento\Framework\Exception\LocalizedException
  * @expectedExceptionMessage Cannot save track:
  */
 public function testSaveValidationFailed()
 {
     $this->validatorMock->expects($this->once())->method('validate')->with($this->equalTo($this->trackModelMock))->will($this->returnValue(['warning message']));
     $this->trackModelMock->expects($this->any())->method('getData')->willReturn([]);
     $this->trackResource->save($this->trackModelMock);
     $this->assertTrue(true);
 }
コード例 #3
0
 /**
  * Set up
  */
 protected function setUp()
 {
     $this->trackModelMock = $this->getMock('Magento\\Sales\\Model\\Order\\Shipment\\Track', [], [], '', 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\\Track\\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->trackModelMock->expects($this->any())->method('hasDataChanges')->will($this->returnValue(true));
     $this->trackModelMock->expects($this->any())->method('isSaveAllowed')->will($this->returnValue(true));
     $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
     $this->trackResource = $objectManager->getObject('Magento\\Sales\\Model\\Resource\\Order\\Shipment\\Track', ['resource' => $this->appResourceMock, 'validator' => $this->validatorMock]);
 }
コード例 #4
0
 /**
  * Run test execute method (delete exception)
  */
 public function testExecuteDeleteFail()
 {
     $errors = ['error' => true, 'message' => 'Cannot delete tracking number.'];
     $this->shipmentLoad();
     $this->shipmentLoaderMock->expects($this->once())->method('load')->will($this->returnValue($this->shipmentMock));
     $this->shipmentTrackMock->expects($this->once())->method('delete')->will($this->throwException(new \Exception()));
     $this->representJson($errors);
     $this->assertNull($this->controller->execute());
 }
コード例 #5
0
 /**
  * Test shipment add track service
  */
 public function testInvoke()
 {
     $this->trackConverterMock->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->shipmentAddTrack->invoke($this->dataObjectMock));
 }
コード例 #6
0
 /**
  * Test shipment remove track
  */
 public function testInvoke()
 {
     $this->trackRepositoryMock->expects($this->once())->method('get')->with($this->equalTo(1))->will($this->returnValue($this->trackMock));
     $this->trackMock->expects($this->once())->method('delete');
     $this->assertTrue($this->shipmentRemoveTrack->invoke(1));
 }