AddressTest.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace Test\Unit;
  3. require_once dirname(__DIR__) . '/Setup.php';
  4. use Test\Setup;
  5. use Braintree;
  6. class AddressTest extends Setup
  7. {
  8. public function testGet_givesErrorIfInvalidProperty()
  9. {
  10. $this->setExpectedException('PHPUnit_Framework_Error', 'Undefined property on Braintree\Address: foo');
  11. $a = Braintree\Address::factory([]);
  12. $a->foo;
  13. }
  14. public function testIsEqual()
  15. {
  16. $first = Braintree\Address::factory(
  17. ['customerId' => 'c1', 'id' => 'a1']
  18. );
  19. $second = Braintree\Address::factory(
  20. ['customerId' => 'c1', 'id' => 'a1']
  21. );
  22. $this->assertTrue($first->isEqual($second));
  23. $this->assertTrue($second->isEqual($first));
  24. }
  25. public function testIsNotEqual() {
  26. $first = Braintree\Address::factory(
  27. ['customerId' => 'c1', 'id' => 'a1']
  28. );
  29. $second = Braintree\Address::factory(
  30. ['customerId' => 'c1', 'id' => 'not a1']
  31. );
  32. $this->assertFalse($first->isEqual($second));
  33. $this->assertFalse($second->isEqual($first));
  34. }
  35. public function testCustomerIdNotEqual()
  36. {
  37. $first = Braintree\Address::factory(
  38. ['customerId' => 'c1', 'id' => 'a1']
  39. );
  40. $second = Braintree\Address::factory(
  41. ['customerId' => 'not c1', 'id' => 'a1']
  42. );
  43. $this->assertFalse($first->isEqual($second));
  44. $this->assertFalse($second->isEqual($first));
  45. }
  46. public function testFindErrorsOnBlankCustomerId()
  47. {
  48. $this->setExpectedException('InvalidArgumentException');
  49. Braintree\Address::find('', '123');
  50. }
  51. public function testFindErrorsOnBlankAddressId()
  52. {
  53. $this->setExpectedException('InvalidArgumentException');
  54. Braintree\Address::find('123', '');
  55. }
  56. public function testFindErrorsOnWhitespaceOnlyId()
  57. {
  58. $this->setExpectedException('InvalidArgumentException');
  59. Braintree\Address::find('123', ' ');
  60. }
  61. public function testFindErrorsOnWhitespaceOnlyCustomerId()
  62. {
  63. $this->setExpectedException('InvalidArgumentException');
  64. Braintree\Address::find(' ', '123');
  65. }
  66. }