You are here

public function AuthcacheP13nTestFragmentAssemblyBuilder::testFragmentAssemblyBuilder in Authenticated User Page Caching (Authcache) 7.2

Test multi fragment request.

File

modules/authcache_p13n/tests/authcache_p13n.request-handler.test, line 524
Define unit tests for request handler.

Class

AuthcacheP13nTestFragmentAssemblyBuilder
Tests update functionality unrelated to the database.

Code

public function testFragmentAssemblyBuilder() {
  $partials = array(
    'param_1' => array(
      'renderer' => new AuthcacheP13nTestEchoPartial(),
    ),
    'param_2' => array(
      'renderer' => new AuthcacheP13nTestEchoPartial(),
    ),
  );
  $builder = new AuthcacheP13nFragmentAssemblyBuilder($partials);
  $input['a'] = array(
    'param_1' => array(
      'some_key' => array(
        'some' => 'subject',
      ),
    ),
    'param_2' => array(
      'key_1' => array(
        'some' => 'subject',
      ),
      'key_2' => array(
        'some_other' => 'subject',
      ),
    ),
    'param_3' => array(
      'no handler' => 'for this fragment',
    ),
  );
  $expect = array(
    'param_1' => array(
      'some_key' => array(
        'key' => 'some_key',
        'subject' => array(
          'some' => 'subject',
        ),
      ),
    ),
    'param_2' => array(
      'key_1' => array(
        'key' => 'key_1',
        'subject' => array(
          'some' => 'subject',
        ),
      ),
      'key_2' => array(
        'key' => 'key_2',
        'subject' => array(
          'some_other' => 'subject',
        ),
      ),
    ),
  );
  $output = $builder
    ->build($input, array());
  $this
    ->assertEqual($expect, $output);
}