You are here

public function AuthcacheEnumCombTestCase::testCombineK in Authenticated User Page Caching (Authcache) 7.2

Test calculation of k-combinations.

File

modules/authcache_enum/lib/Drupal/authcache_enum/Tests/AuthcacheEnumCombTestCase.php, line 37
Defines a test case covering _authcache_enum_comb.

Class

AuthcacheEnumCombTestCase
Unit tests for _authcache_enum_comb.

Namespace

Drupal\authcache_enum\Tests

Code

public function testCombineK() {
  $set = array(
    'a',
    'b',
    'c',
    'd',
  );
  $expect = array(
    array(
      'a',
    ),
    array(
      'b',
    ),
    array(
      'c',
    ),
    array(
      'd',
    ),
  );
  $result = _authcache_enum_comb_k($set, 1);
  $this
    ->assertEqual($expect, $result);
  $expect = array(
    array(
      'a',
      'b',
    ),
    array(
      'a',
      'c',
    ),
    array(
      'a',
      'd',
    ),
    array(
      'b',
      'c',
    ),
    array(
      'b',
      'd',
    ),
    array(
      'c',
      'd',
    ),
  );
  $result = _authcache_enum_comb_k($set, 2);
  $this
    ->assertEqual($expect, $result);
  $expect = array(
    array(
      'a',
      'b',
      'c',
    ),
    array(
      'a',
      'b',
      'd',
    ),
    array(
      'a',
      'c',
      'd',
    ),
    array(
      'b',
      'c',
      'd',
    ),
  );
  $result = _authcache_enum_comb_k($set, 3);
  $this
    ->assertEqual($expect, $result);
}