You are here

protected function CommerceBpcTestCase::assertCorrectPermutationsExist in Commerce Bulk Product Creation 7

Asserts that a product with the correct permutations exists.

Parameters

array $parameters: The expected parameters of the product.

string $text: The message corresponding to the assertion.

1 call to CommerceBpcTestCase::assertCorrectPermutationsExist()
CommerceBpcTestCase::testTwoFieldsTwoListValues in ./commerce_bpc.test
Test the correct creation of 2x3 combinations.

File

./commerce_bpc.test, line 145
Tests for Commerce bulk product creation

Class

CommerceBpcTestCase
@file Tests for Commerce bulk product creation

Code

protected function assertCorrectPermutationsExist($parameters, $text) {
  $combinations = $this
    ->generatePermutations($parameters);
  $count = 0;
  foreach ($combinations as $combination) {
    $attributes = array();
    foreach ($combination as $field => $value) {
      $attributes[] = array(
        'field' => $field,
        'value' => $value,
      );
    }
    if ($this
      ->getNumberOfProductsWithFieldValues($attributes) == 1) {
      $count++;
    }
  }
  $this
    ->assertEqual($count, count($combinations), $text);
}