You are here

public function AuthcacheP13nTestRequestBuilder::testRequestResourcesNullFragments in Authenticated User Page Caching (Authcache) 7.2

Cover authcache_p13n_request_resources().

Also cover hook_authcache_p13n_request() and hook_authcache_p13n_request_alter(). Test defaults.

File

modules/authcache_p13n/tests/authcache_p13n.request-builder.test, line 88
Defines test classes for request builder.

Class

AuthcacheP13nTestRequestBuilder
Request builder test cases.

Code

public function testRequestResourcesNullFragments() {
  $request_base_stub = $this->stubmod
    ->hook('authcache_p13n_base_request');
  $request_base_alter_stub = $this->stubmod
    ->hook('authcache_p13n_base_request_alter');
  $request_info_stub = $this->stubmod
    ->hook('authcache_p13n_request');
  $request_info_alter_stub = $this->stubmod
    ->hook('authcache_p13n_request_alter');
  $fragment_info = array(
    'null-fragment' => array(),
  );
  $fragment_info_stub = $this->stubmod
    ->hook('authcache_p13n_fragment', $fragment_info);
  $setting_info = array(
    'null-setting' => array(),
  );
  $setting_info_stub = $this->stubmod
    ->hook('authcache_p13n_setting', $setting_info);
  $assembly_info = array(
    'null-assembly' => array(),
  );
  $assembly_info_stub = $this->stubmod
    ->hook('authcache_p13n_assembly', $assembly_info);

  // Setup expectations.
  $frontcontroller_path = drupal_get_path('module', 'authcache_p13n') . '/frontcontroller/authcache.php';
  $expect_resources = array(
    'frag/null-fragment' => array(
      'fragment' => array(
        '#type' => 'value',
        '#value' => NULL,
      ),
      'fragment validator' => array(
        '#type' => 'value',
        '#value' => '@fragment[accept_instance(AuthcacheP13nFragmentValidatorInterface)]',
      ),
      'fragment loader' => array(
        '#type' => 'value',
        '#value' => '@fragment[accept_instance(AuthcacheP13nFragmentLoaderInterface)]',
      ),
      'fragment access' => array(
        '#type' => 'value',
        '#value' => '@fragment[accept_instance(AuthcacheP13nFragmentAccessInterface)]',
      ),
      'admin type' => array(
        '#type' => 'value',
        '#value' => t('Fragment'),
      ),
      'content builder' => array(
        '#class' => 'AuthcacheP13nFragmentBuilder',
        '#arguments' => array(
          '@fragment',
          '@fragment validator',
          '@fragment loader',
          '@fragment access',
        ),
        '#type' => 'class',
      ),
      'content encoder' => array(
        '#class' => 'AuthcacheP13nHTMLContent',
        '#type' => 'class',
      ),
      'cache maxage' => array(
        '#type' => 'value',
        '#value' => 600,
      ),
      'cache granularity' => array(
        '#type' => 'value',
        '#value' => AuthcacheP13nCacheGranularity::PER_USER,
      ),
      'bootstrap phase' => array(
        '#type' => 'value',
        '#value' => NULL,
      ),
      'admin group' => array(
        '#type' => 'value',
        '#value' => t('Other'),
      ),
      'admin name' => array(
        '#type' => 'value',
        '#value' => t('Unknown'),
      ),
      'admin description' => array(
        '#type' => 'value',
        '#value' => '',
      ),
      'admin path' => array(
        '#type' => 'value',
        '#value' => NULL,
      ),
      'admin entry object' => array(
        '#type' => 'value',
        '#value' => '@admin entry[as_object]',
      ),
      'conf override' => array(
        '#type' => 'value',
        '#value' => array(),
      ),
      'cache granularity object' => array(
        '#class' => 'AuthcacheP13nCacheGranularity',
        '#arguments' => array(
          '@cache granularity',
        ),
        '#type' => 'class',
      ),
      'cache control header' => array(
        '#class' => 'AuthcacheP13nAddCacheControlHeaderFilter',
        '#arguments' => array(
          '@services[require_instance(AuthcacheP13nCoreServiceInterface)]',
          '@cache maxage',
          '@cache granularity object[require_instance(AuthcacheP13nCacheGranularity)]',
        ),
        '#member_of' => 'request filters',
        '#type' => 'class',
      ),
      'request validator' => array(
        '#type' => 'value',
        '#value' => '@content builder[accept_instance(AuthcacheP13nRequestValidatorInterface)]',
      ),
      'request filters' => array(
        '#collection' => 'request filters',
        '#processor' => 'require_instance(AuthcacheP13nFilterInterface)',
        '#type' => 'collection',
      ),
      'response filters' => array(
        '#collection' => 'response filters',
        '#processor' => 'require_instance(AuthcacheP13nFilterInterface)',
        '#type' => 'collection',
      ),
      'filters' => array(
        '#type' => 'value',
        '#value' => array(
          'request' => '@request filters',
          'response' => '@response filters',
        ),
      ),
      'conf override context provider' => array(
        '#class' => 'AuthcacheP13nConfOverrideContextProvider',
        '#arguments' => array(
          '@conf override',
        ),
        '#weight' => -150,
        '#member_of' => 'context providers',
        '#key' => 'conf override',
        '#type' => 'class',
      ),
      'bootstrap context provider' => array(
        '#class' => 'AuthcacheP13nBootstrapContextProvider',
        '#arguments' => array(
          '@services[require_instance(AuthcacheP13nCoreServiceInterface)]',
          '@bootstrap phase',
        ),
        '#weight' => -50,
        '#member_of' => 'context providers',
        '#key' => 'bootstrap phase',
        '#type' => 'class',
      ),
      'context providers' => array(
        '#collection' => 'context providers',
        '#processor' => 'require_instance(AuthcacheP13nContextProviderInterface)',
        '#type' => 'collection',
      ),
      'handler' => array(
        '#class' => 'AuthcacheP13nDefaultRequestHandler',
        '#arguments' => array(
          '@services[require_instance(AuthcacheP13nCoreServiceInterface)]',
          '@request validator[accept_instance(AuthcacheP13nRequestValidatorInterface)]',
          '@content builder[require_instance(AuthcacheP13nContentBuilderInterface)]',
          '@content encoder[require_instance(AuthcacheP13nContentEncoderInterface)]',
          '@filters',
          '@context providers',
        ),
        '#type' => 'class',
      ),
      'frontcontroller' => array(
        '#value' => $frontcontroller_path,
        '#type' => 'value',
      ),
      'url generator' => array(
        '#class' => 'AuthcacheP13nDefaultRequestUrlGenerator',
        '#arguments' => array(
          '@frontcontroller',
          '@cache granularity object[require_instance(AuthcacheP13nCacheGranularity)]',
        ),
        '#type' => 'class',
      ),
      'services' => array(
        '#class' => 'AuthcacheP13nDefaultCoreService',
        '#type' => 'class',
      ),
      'admin entry' => array(
        '#type' => 'value',
        '#value' => array(
          'type' => '@admin type',
          'group' => '@admin group',
          'name' => '@admin name',
          'description' => '@admin description',
          'clients' => NULL,
          'cacheMaxage' => '@cache maxage',
          'cacheGranularity' => '@cache granularity object[require_instance(AuthcacheP13nCacheGranularity)]',
          'adminPath' => '@admin path',
        ),
      ),
    ),
    'setting/null-setting' => array(
      'settings' => array(
        '#collection' => 'settings',
        '#type' => 'collection',
      ),
      'admin type' => array(
        '#type' => 'value',
        '#value' => t('Setting'),
      ),
      'content builder' => array(
        '#class' => 'AuthcacheP13nSettingBuilder',
        '#arguments' => array(
          '@settings',
        ),
        '#type' => 'class',
      ),
      'content encoder' => array(
        '#class' => 'AuthcacheP13nJSONContent',
        '#type' => 'class',
      ),
      'cache maxage' => array(
        '#type' => 'value',
        '#value' => 600,
      ),
      'cache granularity' => array(
        '#type' => 'value',
        '#value' => AuthcacheP13nCacheGranularity::PER_USER,
      ),
      'bootstrap phase' => array(
        '#type' => 'value',
        '#value' => NULL,
      ),
      'admin group' => array(
        '#type' => 'value',
        '#value' => t('Other'),
      ),
      'admin name' => array(
        '#type' => 'value',
        '#value' => t('Unknown'),
      ),
      'admin description' => array(
        '#type' => 'value',
        '#value' => '',
      ),
      'admin path' => array(
        '#type' => 'value',
        '#value' => NULL,
      ),
      'admin entry object' => array(
        '#type' => 'value',
        '#value' => '@admin entry[as_object]',
      ),
      'conf override' => array(
        '#type' => 'value',
        '#value' => array(),
      ),
      'cache granularity object' => array(
        '#class' => 'AuthcacheP13nCacheGranularity',
        '#arguments' => array(
          '@cache granularity',
        ),
        '#type' => 'class',
      ),
      'cache control header' => array(
        '#class' => 'AuthcacheP13nAddCacheControlHeaderFilter',
        '#arguments' => array(
          '@services[require_instance(AuthcacheP13nCoreServiceInterface)]',
          '@cache maxage',
          '@cache granularity object[require_instance(AuthcacheP13nCacheGranularity)]',
        ),
        '#member_of' => 'request filters',
        '#type' => 'class',
      ),
      'request validator' => array(
        '#type' => 'value',
        '#value' => '@content builder[accept_instance(AuthcacheP13nRequestValidatorInterface)]',
      ),
      'request filters' => array(
        '#collection' => 'request filters',
        '#processor' => 'require_instance(AuthcacheP13nFilterInterface)',
        '#type' => 'collection',
      ),
      'response filters' => array(
        '#collection' => 'response filters',
        '#processor' => 'require_instance(AuthcacheP13nFilterInterface)',
        '#type' => 'collection',
      ),
      'filters' => array(
        '#type' => 'value',
        '#value' => array(
          'request' => '@request filters',
          'response' => '@response filters',
        ),
      ),
      'conf override context provider' => array(
        '#class' => 'AuthcacheP13nConfOverrideContextProvider',
        '#arguments' => array(
          '@conf override',
        ),
        '#weight' => -150,
        '#member_of' => 'context providers',
        '#key' => 'conf override',
        '#type' => 'class',
      ),
      'bootstrap context provider' => array(
        '#class' => 'AuthcacheP13nBootstrapContextProvider',
        '#arguments' => array(
          '@services[require_instance(AuthcacheP13nCoreServiceInterface)]',
          '@bootstrap phase',
        ),
        '#weight' => -50,
        '#member_of' => 'context providers',
        '#key' => 'bootstrap phase',
        '#type' => 'class',
      ),
      'context providers' => array(
        '#collection' => 'context providers',
        '#processor' => 'require_instance(AuthcacheP13nContextProviderInterface)',
        '#type' => 'collection',
      ),
      'handler' => array(
        '#class' => 'AuthcacheP13nDefaultRequestHandler',
        '#arguments' => array(
          '@services[require_instance(AuthcacheP13nCoreServiceInterface)]',
          '@request validator[accept_instance(AuthcacheP13nRequestValidatorInterface)]',
          '@content builder[require_instance(AuthcacheP13nContentBuilderInterface)]',
          '@content encoder[require_instance(AuthcacheP13nContentEncoderInterface)]',
          '@filters',
          '@context providers',
        ),
        '#type' => 'class',
      ),
      'frontcontroller' => array(
        '#value' => $frontcontroller_path,
        '#type' => 'value',
      ),
      'url generator' => array(
        '#class' => 'AuthcacheP13nDefaultRequestUrlGenerator',
        '#arguments' => array(
          '@frontcontroller',
          '@cache granularity object[require_instance(AuthcacheP13nCacheGranularity)]',
        ),
        '#type' => 'class',
      ),
      'services' => array(
        '#class' => 'AuthcacheP13nDefaultCoreService',
        '#type' => 'class',
      ),
      'admin entry' => array(
        '#type' => 'value',
        '#value' => array(
          'type' => '@admin type',
          'group' => '@admin group',
          'name' => '@admin name',
          'description' => '@admin description',
          'clients' => NULL,
          'cacheMaxage' => '@cache maxage',
          'cacheGranularity' => '@cache granularity object[require_instance(AuthcacheP13nCacheGranularity)]',
          'adminPath' => '@admin path',
        ),
      ),
    ),
    'asm/null-assembly' => array(
      'partials' => array(
        '#collection' => 'partials',
        '#type' => 'collection',
      ),
      'admin type' => array(
        '#type' => 'value',
        '#value' => t('Assembly'),
      ),
      'content builder' => array(
        '#class' => 'AuthcacheP13nFragmentAssemblyBuilder',
        '#arguments' => array(
          '@partials',
        ),
        '#type' => 'class',
      ),
      'content encoder' => array(
        '#class' => 'AuthcacheP13nJSONContent',
        '#type' => 'class',
      ),
      'cache maxage' => array(
        '#type' => 'value',
        '#value' => 600,
      ),
      'cache granularity' => array(
        '#type' => 'value',
        '#value' => AuthcacheP13nCacheGranularity::PER_USER,
      ),
      'bootstrap phase' => array(
        '#type' => 'value',
        '#value' => NULL,
      ),
      'admin group' => array(
        '#type' => 'value',
        '#value' => t('Other'),
      ),
      'admin name' => array(
        '#type' => 'value',
        '#value' => t('Unknown'),
      ),
      'admin description' => array(
        '#type' => 'value',
        '#value' => '',
      ),
      'admin path' => array(
        '#type' => 'value',
        '#value' => NULL,
      ),
      'admin entry object' => array(
        '#type' => 'value',
        '#value' => '@admin entry[as_object]',
      ),
      'conf override' => array(
        '#type' => 'value',
        '#value' => array(),
      ),
      'cache granularity object' => array(
        '#class' => 'AuthcacheP13nCacheGranularity',
        '#arguments' => array(
          '@cache granularity',
        ),
        '#type' => 'class',
      ),
      'cache control header' => array(
        '#class' => 'AuthcacheP13nAddCacheControlHeaderFilter',
        '#arguments' => array(
          '@services[require_instance(AuthcacheP13nCoreServiceInterface)]',
          '@cache maxage',
          '@cache granularity object[require_instance(AuthcacheP13nCacheGranularity)]',
        ),
        '#member_of' => 'request filters',
        '#type' => 'class',
      ),
      'request validator' => array(
        '#type' => 'value',
        '#value' => '@content builder[accept_instance(AuthcacheP13nRequestValidatorInterface)]',
      ),
      'request filters' => array(
        '#collection' => 'request filters',
        '#processor' => 'require_instance(AuthcacheP13nFilterInterface)',
        '#type' => 'collection',
      ),
      'response filters' => array(
        '#collection' => 'response filters',
        '#processor' => 'require_instance(AuthcacheP13nFilterInterface)',
        '#type' => 'collection',
      ),
      'filters' => array(
        '#type' => 'value',
        '#value' => array(
          'request' => '@request filters',
          'response' => '@response filters',
        ),
      ),
      'conf override context provider' => array(
        '#class' => 'AuthcacheP13nConfOverrideContextProvider',
        '#arguments' => array(
          '@conf override',
        ),
        '#weight' => -150,
        '#member_of' => 'context providers',
        '#key' => 'conf override',
        '#type' => 'class',
      ),
      'bootstrap context provider' => array(
        '#class' => 'AuthcacheP13nBootstrapContextProvider',
        '#arguments' => array(
          '@services[require_instance(AuthcacheP13nCoreServiceInterface)]',
          '@bootstrap phase',
        ),
        '#weight' => -50,
        '#member_of' => 'context providers',
        '#key' => 'bootstrap phase',
        '#type' => 'class',
      ),
      'context providers' => array(
        '#collection' => 'context providers',
        '#processor' => 'require_instance(AuthcacheP13nContextProviderInterface)',
        '#type' => 'collection',
      ),
      'handler' => array(
        '#class' => 'AuthcacheP13nDefaultRequestHandler',
        '#arguments' => array(
          '@services[require_instance(AuthcacheP13nCoreServiceInterface)]',
          '@request validator[accept_instance(AuthcacheP13nRequestValidatorInterface)]',
          '@content builder[require_instance(AuthcacheP13nContentBuilderInterface)]',
          '@content encoder[require_instance(AuthcacheP13nContentEncoderInterface)]',
          '@filters',
          '@context providers',
        ),
        '#type' => 'class',
      ),
      'frontcontroller' => array(
        '#value' => $frontcontroller_path,
        '#type' => 'value',
      ),
      'url generator' => array(
        '#class' => 'AuthcacheP13nDefaultRequestUrlGenerator',
        '#arguments' => array(
          '@frontcontroller',
          '@cache granularity object[require_instance(AuthcacheP13nCacheGranularity)]',
        ),
        '#type' => 'class',
      ),
      'services' => array(
        '#class' => 'AuthcacheP13nDefaultCoreService',
        '#type' => 'class',
      ),
      'admin entry' => array(
        '#type' => 'value',
        '#value' => array(
          'type' => '@admin type',
          'group' => '@admin group',
          'name' => '@admin name',
          'description' => '@admin description',
          'clients' => NULL,
          'cacheMaxage' => '@cache maxage',
          'cacheGranularity' => '@cache granularity object[require_instance(AuthcacheP13nCacheGranularity)]',
          'adminPath' => '@admin path',
        ),
      ),
    ),
  );
  $resources = authcache_p13n_request_resources();
  $this
    ->assertEqual($expect_resources, $resources);
  $this
    ->assertStub($request_base_stub, HookStub::once());
  $this
    ->assertStub($request_base_alter_stub, HookStub::once());
  $this
    ->assertStub($request_info_stub, HookStub::once());
  $this
    ->assertStub($request_info_alter_stub, HookStub::once());
  $this
    ->assertStub($fragment_info_stub, HookStub::once());
  $this
    ->assertStub($setting_info_stub, HookStub::once());
  $this
    ->assertStub($assembly_info_stub, HookStub::once());
}