public function UbercartAddressTestCase::testAddressComparison in Ubercart 7.3
Tests comparison of address objects.
File
- uc_store/
tests/ uc_address.test, line 52 - Tests for the UcAddress class.
Class
- UbercartAddressTestCase
- Tests for the UcAddress class.
Code
public function testAddressComparison() {
$address1 = $this->test_address[0];
$address2 = $this->test_address[1];
$this
->pass((string) $this->test_address[0]);
$this
->pass((string) $this->test_address[1]);
// Use randomly generated address first.
$address = clone $this->test_address[0];
// Modify phone number and test equality
$address->phone = 'this is not a valid phone number';
$this
->assertTrue($this->test_address[0]
->isSamePhysicalLocation($address), t('Physical address comparison ignores non-physical fields.'));
// Use specifc address.
$address = clone $this->test_address[1];
// Modify city and test equality
$address->city = 'nEw YoRk';
$this
->pass((string) $address);
$this
->assertTrue($this->test_address[1]
->isSamePhysicalLocation($address), t('Case-insensitive address comparison works.'));
// Modify city and test equality
$address->city = ' NewYork ';
$this
->pass((string) $address);
$this
->assertTrue($this->test_address[1]
->isSamePhysicalLocation($address), t('Whitespace-insensitive address comparison works.'));
}