You are here

public static function UcAddressesTestCase::checkAddressValuesInDatabase in Ubercart Addresses 7

Same name and namespace in other branches
  1. 6.2 tests/UcAddressesTestCase.test \UcAddressesTestCase::checkAddressValuesInDatabase()

Test if these address values appear in the database.

@static

Parameters

array $values: The address values to check for.

Return value

boolean

7 calls to UcAddressesTestCase::checkAddressValuesInDatabase()
UcAddressesApiTestCase::testAddressBookCrud in tests/uc_addresses.api.test
Tests if addresses can be added, saved and deleted.
UcAddressesCartCheckoutTestCase::doDefaultAddressesTests in tests/uc_addresses.checkout.test
Checkout with the default addresses.
UcAddressesCartCheckoutTestCase::testCheckoutWithPreviousOrders in tests/uc_addresses.checkout.test
Test if checkout works when customer has previous placed orders, but no addresses in the address book.
UcAddressesEntityCase::testEntityCrud in tests/uc_addresses.entity.test
Test Ubercart Addresses Entity CRUD.
UcAddressesFeedsTest::test in tests/uc_addresses.feeds.test
Test address creation.

... See full list

File

tests/UcAddressesTestCase.test, line 284
Contains base class for Ubercart Addresses tests.

Class

UcAddressesTestCase
Base class for Ubercart Addresses tests.

Code

public static function checkAddressValuesInDatabase($values) {
  $schema_values = array();

  // Only check real schema fields.
  foreach ($values as $fieldname => $value) {
    if (UcAddressesSchemaAddress::schemaFieldExists($fieldname)) {
      $schema_values[$fieldname] = $value;
    }
  }
  $query = db_select('uc_addresses');
  $query
    ->addExpression('COUNT(aid)');
  foreach ($schema_values as $fieldname => $value) {
    $query
      ->condition($fieldname, $value);
  }
  $sQuery = (string) $query;
  $result = $query
    ->execute();
  return $result
    ->fetchField() ? TRUE : FALSE;
}