DispatchModelTest.php 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /**
  3. * Refer to LICENSE.txt distributed with the Temando Shipping module for notice of license
  4. */
  5. namespace Temando\Shipping\Model;
  6. use Magento\TestFramework\Helper\Bootstrap;
  7. /**
  8. * Temando Dispatch Model Test
  9. *
  10. * @package Temando\Shipping\Test\Integration
  11. * @author Christoph Aßmann <christoph.assmann@netresearch.de>
  12. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  13. * @link http://www.temando.com/
  14. */
  15. class DispatchModelTest extends \PHPUnit\Framework\TestCase
  16. {
  17. /**
  18. * @test
  19. */
  20. public function dataIsSetThroughConstructorArgument()
  21. {
  22. $dispatchId = '03df240e-969d-4549-bf10-ea7cd22f3070';
  23. $status = 'processing';
  24. $carrierName = 'UPS';
  25. $createdAtDate = '2017-03-03T04:35:42.022Z';
  26. $readyAtDate = '2017-01-01T00:00:01Z';
  27. $shipmentCount = 3;
  28. $documentation = [];
  29. /** @var Dispatch $dispatch */
  30. $dispatch = Bootstrap::getObjectManager()->create(Dispatch::class, ['data' => [
  31. Dispatch::DISPATCH_ID => $dispatchId,
  32. Dispatch::STATUS => $status,
  33. Dispatch::CARRIER_NAME => $carrierName,
  34. Dispatch::CREATED_AT_DATE => $createdAtDate,
  35. Dispatch::READY_AT_DATE => $readyAtDate,
  36. Dispatch::INCLUDED_SHIPMENTS => $shipmentCount,
  37. Dispatch::DOCUMENTATION => $documentation,
  38. ]]);
  39. $this->assertEquals($dispatchId, $dispatch->getDispatchId());
  40. $this->assertEquals($status, $dispatch->getStatus());
  41. $this->assertEquals($carrierName, $dispatch->getCarrierName());
  42. $this->assertEquals($createdAtDate, $dispatch->getCreatedAtDate());
  43. $this->assertEquals($readyAtDate, $dispatch->getReadyAtDate());
  44. $this->assertEquals($shipmentCount, $dispatch->getIncludedShipments());
  45. $this->assertEquals($documentation, $dispatch->getDocumentation());
  46. }
  47. /**
  48. * @test
  49. */
  50. public function dataIsSetThroughSetters()
  51. {
  52. $dispatchId = '03df240e-969d-4549-bf10-ea7cd22f3070';
  53. $status = 'processing';
  54. $carrierName = 'UPS';
  55. $createdAtDate = '2017-03-03T04:35:42.022Z';
  56. $readyAtDate = '2017-01-01T00:00:01Z';
  57. $shipmentCount = 3;
  58. $documentation = [];
  59. /** @var Dispatch $dispatch */
  60. $dispatch = Bootstrap::getObjectManager()->create(Dispatch::class);
  61. $this->assertEmpty($dispatch->getDispatchId());
  62. $dispatch->setData(Dispatch::DISPATCH_ID, $dispatchId);
  63. $this->assertEquals($dispatchId, $dispatch->getDispatchId());
  64. $dispatch->setData(Dispatch::STATUS, $status);
  65. $this->assertEquals($status, $dispatch->getStatus());
  66. $dispatch->setData(Dispatch::CARRIER_NAME, $carrierName);
  67. $this->assertEquals($carrierName, $dispatch->getCarrierName());
  68. $dispatch->setData(Dispatch::CREATED_AT_DATE, $createdAtDate);
  69. $this->assertEquals($createdAtDate, $dispatch->getCreatedAtDate());
  70. $dispatch->setData(Dispatch::READY_AT_DATE, $readyAtDate);
  71. $this->assertEquals($readyAtDate, $dispatch->getReadyAtDate());
  72. $dispatch->setData(Dispatch::INCLUDED_SHIPMENTS, $shipmentCount);
  73. $this->assertEquals($shipmentCount, $dispatch->getIncludedShipments());
  74. $dispatch->setData(Dispatch::DOCUMENTATION, $documentation);
  75. $this->assertEquals($documentation, $dispatch->getDocumentation());
  76. }
  77. }