You are here

protected function UcAddressesEntityCase::doOtherEntityTests in Ubercart Addresses 7

Test if non-crud entity API functions behave as expected.

Parameters

object $entity: The entity to pass to entity API functions.

UcAddressesAddress $address: An instance of UcAddressesAddress. This will be used to perform known address book API methods on.

Return value

void

1 call to UcAddressesEntityCase::doOtherEntityTests()
UcAddressesEntityCase::testEntityCrud in tests/uc_addresses.entity.test
Test Ubercart Addresses Entity CRUD.

File

tests/uc_addresses.entity.test, line 488
Test cases address entity.

Class

UcAddressesEntityCase
Tests for Entity API integration.

Code

protected function doOtherEntityTests($entity, UcAddressesAddress $address) {

  // Ensure the address ID can be get via entity_id().
  $this
    ->assertEqual(entity_id('uc_addresses', $entity), $address
    ->getId(), 'The address ID can be get via entity_id().');

  // Test if entity_label() returns the name of the address (if the address has one).
  if ($name = $address
    ->getName()) {
    $this
      ->assertEqual(entity_label('uc_addresses', $entity), $name, 'entity_label() correctly returns the address name.');
  }

  // Test for correct uri.
  $uri['path'] = 'user/' . $address
    ->getUserId() . '/addresses/' . $address
    ->getId();
  $entity_uri = entity_uri('uc_addresses', $entity);
  $msgvars = array(
    '@uri' => check_plain($uri['path']),
    '@entity_uri' => check_plain($entity_uri['path']),
  );
  $this
    ->assertEqual($entity_uri['path'], $uri['path'], strtr('entity_uri() returns the expected uri: @uri (actual: @entity_uri).', $msgvars));
}