You are here

public function AuthcacheP13nTestConfigWidget::testConfigCacheGranularity in Authenticated User Page Caching (Authcache) 7.2

Cover authcache_p13n_config_cache_granularity().

File

modules/authcache_p13n/tests/authcache_p13n.config.test, line 70
Defines test for authcache personalization configuration widget.

Class

AuthcacheP13nTestConfigWidget
Tests for authcache_p13n_config element.

Code

public function testConfigCacheGranularity() {
  $tests = array(
    array(
      array(),
      0,
    ),
    array(
      array(
        'perpage' => 1,
      ),
      AuthcacheP13nCacheGranularity::PER_PAGE,
    ),
    array(
      array(
        'peruser' => 1,
      ),
      AuthcacheP13nCacheGranularity::PER_USER,
    ),
    array(
      array(
        'peruser' => 1,
        'perpage' => 1,
      ),
      AuthcacheP13nCacheGranularity::PER_USER | AuthcacheP13nCacheGranularity::PER_PAGE,
    ),
  );
  foreach ($tests as $pair) {
    list($config, $expect) = $pair;
    $result = authcache_p13n_config_cache_granularity($config);
    $this
      ->assertEqual($expect, $result);
  }
}