You are here

public function AuthcachePanelsPageManagerTest::testEmptyContentPane in Authenticated User Page Caching (Authcache) 7.2

Test the behavior on empty content panes.

File

modules/authcache_panels_page_manager/authcache_panels_page_manager.test, line 190
Test cases for the Authcache PanelsPageManager module.

Class

AuthcachePanelsPageManagerTest
Tests for markup substitution.

Code

public function testEmptyContentPane() {
  $this
    ->drupalLogin($this->admin);

  // Enable the node page.
  $this
    ->drupalGet('admin/structure/pages');
  $this
    ->clickLink(t('Edit'), 4);

  // Import variant.
  $edit = array(
    'object' => file_get_contents(drupal_get_path('module', 'authcache_panels_page_manager') . '/tests/node-page-forced-node-42.stub.txt'),
  );
  $this
    ->drupalPost('admin/structure/pages/nojs/operation/node_view/actions/import', $edit, t('Update and save'));
  $this
    ->assertResponse(200);
  $this
    ->clickLink(t('Enable'));
  $this
    ->drupalPost(NULL, array(), t('Enable'));
  $this
    ->drupalLogout();
  authcache_p13n_request_router_rebuild();

  // Setup client and fragment stub.
  $client_info = array(
    'authcache_p13n_test' => array(
      'title' => t('Test Client'),
      'enabled' => TRUE,
    ),
  );
  $this->stubmod
    ->hook('authcache_p13n_client', $client_info);
  $substituted_markup = $this
    ->randomName(8);
  $fragment_stub = HookStub::on('theme_authcache_p13n_fragment__authcache_p13n_test', $substituted_markup);
  $this
    ->drupalLogin($this->member);
  $this
    ->drupalGet('node/' . $this->node->nid);
  $this
    ->assertResponse(200);

  // Test succeeds if there was no error during the rendering of the page.
  // However sadly, we are not able to attach the fragment loader when a
  // content pane did not produce any result. This might result in weird
  // results like outlined in https://drupal.org/node/2237659#comment-8681127.
  // Somebody has an idea on how to fix that?
  //
  // Correct but failing assertions:
  // $this->assertText($substituted_markup);
  // $this->assertStub($fragment_stub, HookStub::once());
  //
  // Wrong but working assertions:
  $this
    ->assertNoText($substituted_markup);
  $this
    ->assertStub($fragment_stub, HookStub::never());
}