You are here

public function UcAddressesEntityCase::testExistingUcOrderPropertyGet in Ubercart Addresses 7

Tests getting uc_addreses properties on an existing uc_order.

@covers uc_addresses_uc_order_address_property_get()

File

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

Class

UcAddressesEntityCase
Tests for Entity API integration.

Code

public function testExistingUcOrderPropertyGet() {
  $delivery_city = self::randomName();
  $billing_city = self::randomName();

  // Create a new order manually and save into the database.
  $order_new = new UcOrder();
  $order_new->delivery_city = $delivery_city;
  $order_new->billing_city = $billing_city;
  drupal_write_record('uc_orders', $order_new);

  // Load this order.
  $order = uc_order_load($order_new->order_id);

  // Assert that properties can be get using the Entity API's metadata wrapper.
  $order_wrapper = entity_metadata_wrapper('uc_order', $order);
  $this
    ->assertEqual($delivery_city, $order_wrapper->uc_addresses_delivery_address->city
    ->raw());
  $this
    ->assertEqual($billing_city, $order_wrapper->uc_addresses_billing_address->city
    ->raw());
  $this
    ->assertTrue($order_wrapper->uc_addresses_delivery_address
    ->raw() instanceof UcAddressesAddress);
  $this
    ->assertTrue($order_wrapper->uc_addresses_billing_address
    ->raw() instanceof UcAddressesAddress);
}