LocationModelTest.php 3.1 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 Location 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 LocationModelTest extends \PHPUnit\Framework\TestCase
  16. {
  17. /**
  18. * @test
  19. */
  20. public function dataIsSetThroughConstructorArgument()
  21. {
  22. $locationId = 'eebf51a8-b4b8-4ee2-b830-e0f8c9a3c559';
  23. $name = 'Foo Store';
  24. $uniqueIdentifier = 'foo-store';
  25. $type = 'Store';
  26. $street = '77 Foo Street';
  27. $postalCode = '4006';
  28. $isDefault = true;
  29. /** @var Location $location */
  30. $location = Bootstrap::getObjectManager()->create(Location::class, ['data' => [
  31. Location::LOCATION_ID => $locationId,
  32. Location::NAME => $name,
  33. Location::UNIQUE_IDENTIFIER => $uniqueIdentifier,
  34. Location::TYPE => $type,
  35. Location::STREET => $street,
  36. Location::POSTAL_CODE => $postalCode,
  37. Location::IS_DEFAULT => $isDefault,
  38. ]]);
  39. $this->assertEquals($locationId, $location->getLocationId());
  40. $this->assertEquals($name, $location->getName());
  41. $this->assertEquals($uniqueIdentifier, $location->getUniqueIdentifier());
  42. $this->assertEquals($type, $location->getType());
  43. $this->assertEquals($street, $location->getStreet());
  44. $this->assertEquals($postalCode, $location->getPostalCode());
  45. $this->assertEquals($isDefault, $location->isDefault());
  46. }
  47. /**
  48. * @test
  49. */
  50. public function dataIsSetThroughSetters()
  51. {
  52. $locationId = 'eebf51a8-b4b8-4ee2-b830-e0f8c9a3c559';
  53. $name = 'Foo Store';
  54. $uniqueIdentifier = 'foo-store';
  55. $type = 'Store';
  56. $street = '77 Foo Street';
  57. $postalCode = '4006';
  58. $isDefault = true;
  59. /** @var Location $location */
  60. $location = Bootstrap::getObjectManager()->create(Location::class);
  61. $this->assertEmpty($location->getLocationId());
  62. $location->setData(Location::LOCATION_ID, $locationId);
  63. $this->assertEquals($locationId, $location->getLocationId());
  64. $location->setData(Location::NAME, $name);
  65. $this->assertEquals($name, $location->getName());
  66. $location->setData(Location::UNIQUE_IDENTIFIER, $uniqueIdentifier);
  67. $this->assertEquals($uniqueIdentifier, $location->getUniqueIdentifier());
  68. $location->setData(Location::TYPE, $type);
  69. $this->assertEquals($type, $location->getType());
  70. $location->setData(Location::STREET, $street);
  71. $this->assertEquals($street, $location->getStreet());
  72. $location->setData(Location::POSTAL_CODE, $postalCode);
  73. $this->assertEquals($postalCode, $location->getPostalCode());
  74. $location->setData(Location::IS_DEFAULT, $isDefault);
  75. $this->assertEquals($isDefault, $location->isDefault());
  76. }
  77. }