ShipmentReferenceTest.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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\ObjectManager;
  7. use Magento\TestFramework\Helper\Bootstrap;
  8. use Temando\Shipping\Api\Data\Shipment\ShipmentReferenceInterface;
  9. /**
  10. * Temando Shipment Reference Test
  11. *
  12. * @package Temando\Shipping\Test\Integration
  13. * @author Benjamin Heuer <benjamin.heuer@netresearch.de>
  14. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  15. * @link http://www.temando.com/
  16. */
  17. class ShipmentReferenceTest extends \PHPUnit\Framework\TestCase
  18. {
  19. /**
  20. * @var ObjectManager
  21. */
  22. private $objectManager;
  23. /**
  24. * Init object manager
  25. */
  26. public function setUp()
  27. {
  28. parent::setUp();
  29. $this->objectManager = Bootstrap::getObjectManager();
  30. }
  31. /**
  32. * @test
  33. */
  34. public function dataIsSetThroughConstructorArgument()
  35. {
  36. $entityId = 303;
  37. $shipmentId = 808;
  38. $shipmentReferenceId = 'F00-S01';
  39. $locationReferenceId = 'F00-L01';
  40. $trackingReferenceId = 'F00-T01';
  41. $trackingUrl = 'https://example.org/';
  42. /** @var ShipmentReferenceInterface $shipmentReference */
  43. $shipmentReference = $this->objectManager->create(ShipmentReferenceInterface::class, ['data' => [
  44. ShipmentReferenceInterface::ENTITY_ID => $entityId,
  45. ShipmentReferenceInterface::SHIPMENT_ID => $shipmentId,
  46. ShipmentReferenceInterface::EXT_SHIPMENT_ID => $shipmentReferenceId,
  47. ShipmentReferenceInterface::EXT_LOCATION_ID => $locationReferenceId,
  48. ShipmentReferenceInterface::EXT_TRACKING_REFERENCE => $trackingReferenceId,
  49. ShipmentReferenceInterface::EXT_TRACKING_URL => $trackingUrl,
  50. ]]);
  51. $this->assertEquals($entityId, $shipmentReference->getEntityId());
  52. $this->assertEquals($shipmentId, $shipmentReference->getShipmentId());
  53. $this->assertEquals($shipmentReferenceId, $shipmentReference->getExtShipmentId());
  54. $this->assertEquals($locationReferenceId, $shipmentReference->getExtLocationId());
  55. $this->assertEquals($trackingReferenceId, $shipmentReference->getExtTrackingReference());
  56. $this->assertEquals($trackingUrl, $shipmentReference->getExtTrackingUrl());
  57. }
  58. /**
  59. * @test
  60. */
  61. public function dataIsSetThroughSetters()
  62. {
  63. $entityId = 303;
  64. $shipmentId = 808;
  65. $shipmentReferenceId = 'F00-S01';
  66. $locationReferenceId = 'F00-L01';
  67. $trackingReferenceId = 'F00-T01';
  68. $trackingUrl = 'https://example.org/';
  69. /** @var ShipmentReferenceInterface $shipmentReference */
  70. $shipmentReference = $this->objectManager->create(ShipmentReferenceInterface::class);
  71. $this->assertEmpty($shipmentReference->getEntityId());
  72. $shipmentReference->setEntityId($entityId);
  73. $this->assertEquals($entityId, $shipmentReference->getEntityId());
  74. $shipmentReference->setShipmentId($shipmentId);
  75. $this->assertEquals($shipmentId, $shipmentReference->getShipmentId());
  76. $shipmentReference->setExtShipmentId($shipmentReferenceId);
  77. $this->assertEquals($shipmentReferenceId, $shipmentReference->getExtShipmentId());
  78. $shipmentReference->setExtLocationId($locationReferenceId);
  79. $this->assertEquals($locationReferenceId, $shipmentReference->getExtLocationId());
  80. $shipmentReference->setExtTrackingReference($trackingReferenceId);
  81. $this->assertEquals($trackingReferenceId, $shipmentReference->getExtTrackingReference());
  82. $shipmentReference->setExtTrackingUrl($trackingUrl);
  83. $this->assertEquals($trackingUrl, $shipmentReference->getExtTrackingUrl());
  84. }
  85. }