LogEntryTest.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <?php
  2. /**
  3. * @copyright Vertex. All rights reserved. https://www.vertexinc.com/
  4. * @author Mediotype https://www.mediotype.com/
  5. */
  6. namespace Vertex\Tax\Test\Unit\Model\Data;
  7. use Vertex\Tax\Model\Data\LogEntry;
  8. use Vertex\Tax\Test\Unit\TestCase;
  9. class LogEntryTest extends TestCase
  10. {
  11. public function testType()
  12. {
  13. $entry = $this->createEntry();
  14. $entry->setType('type');
  15. $this->assertEquals('type', $entry->getType());
  16. $this->assertOthersNull($entry, 'getType');
  17. }
  18. public function testCartId()
  19. {
  20. $entry = $this->createEntry();
  21. $entry->setCartId(2);
  22. $this->assertEquals(2, $entry->getCartId());
  23. $this->assertOthersNull($entry, 'getCartId');
  24. }
  25. public function testOrderId()
  26. {
  27. $entry = $this->createEntry();
  28. $entry->setOrderId(3);
  29. $this->assertEquals(3, $entry->getOrderId());
  30. $this->assertOthersNull($entry, 'getOrderId');
  31. }
  32. public function testTotalTax()
  33. {
  34. $entry = $this->createEntry();
  35. $entry->setTotalTax(3.14);
  36. $this->assertEquals(3.14, $entry->getTotalTax());
  37. $this->assertOthersNull($entry, 'getTotalTax');
  38. }
  39. public function testSourcePath()
  40. {
  41. $entry = $this->createEntry();
  42. $entry->setSourcePath('path');
  43. $this->assertEquals('path', $entry->getSourcePath());
  44. $this->assertOthersNull($entry, 'getSourcePath');
  45. }
  46. public function testTaxAreaId()
  47. {
  48. $entry = $this->createEntry();
  49. $entry->setTaxAreaId('id');
  50. $this->assertEquals('id', $entry->getTaxAreaId());
  51. $this->assertOthersNull($entry, 'getTaxAreaId');
  52. }
  53. public function testSubTotal()
  54. {
  55. $entry = $this->createEntry();
  56. $entry->setSubTotal(4);
  57. $this->assertEquals(4, $entry->getSubTotal());
  58. $this->assertOthersNull($entry, 'getSubTotal');
  59. }
  60. public function testTotal()
  61. {
  62. $entry = $this->createEntry();
  63. $entry->setTotal(8);
  64. $this->assertEquals(8, $entry->getTotal());
  65. $this->assertOthersNull($entry, 'getTotal');
  66. }
  67. public function testLookupResult()
  68. {
  69. $entry = $this->createEntry();
  70. $entry->setLookupResult('val');
  71. $this->assertEquals('val', $entry->getLookupResult());
  72. $this->assertOthersNull($entry, 'getLookupResult');
  73. }
  74. public function testDate()
  75. {
  76. $entry = $this->createEntry();
  77. $entry->setDate('val');
  78. $this->assertEquals('val', $entry->getDate());
  79. $this->assertOthersNull($entry, 'getDate');
  80. }
  81. public function testRequestXml()
  82. {
  83. $entry = $this->createEntry();
  84. $entry->setRequestXml('val');
  85. $this->assertEquals('val', $entry->getRequestXml());
  86. $this->assertOthersNull($entry, 'getRequestXml');
  87. }
  88. public function testResponseXml()
  89. {
  90. $entry = $this->createEntry();
  91. $entry->setResponseXml('val');
  92. $this->assertEquals('val', $entry->getResponseXml());
  93. $this->assertOthersNull($entry, 'getResponseXml');
  94. }
  95. /**
  96. * @return LogEntry
  97. */
  98. private function createEntry()
  99. {
  100. return $this->getObject(LogEntry::class);
  101. }
  102. /**
  103. * Helper method for ensuring there are no side effects on the data class
  104. *
  105. * @param LogEntry $object
  106. * @param string $test Method we should expect a result from
  107. */
  108. private function assertOthersNull(LogEntry $object, $test)
  109. {
  110. $methods = [
  111. 'getType',
  112. 'getCartId',
  113. 'getOrderId',
  114. 'getTotalTax',
  115. 'getSourcePath',
  116. 'getTaxAreaId',
  117. 'getSubTotal',
  118. 'getTotal',
  119. 'getLookupResult',
  120. 'getDate',
  121. 'getRequestXml',
  122. 'getResponseXml'
  123. ];
  124. foreach ($methods as $method) {
  125. if ($method !== $test) {
  126. $this->assertNull($object->{$method}());
  127. }
  128. }
  129. }
  130. }