1 contextual_links_example.test public ContextualLinksExampleTestCase::testContextualLinksExample()

Test the various contextual links that this module defines and displays.


modules/examples/contextual_links_example/tests/contextual_links_example.test, line 32
Functional tests for the contextual_links_example module.


Functional tests for the contextual_links_example module.


public function testContextualLinksExample() {
  // Create a node and promote it to the front page. Then view the front page
  // and verify that the "Example action" contextual link works.
  $node = $this->backdropCreateNode(array('type' => 'page', 'promote' => 1));
  $this->clickLink(t('Example action'));
  $this->assertUrl('node/' . $node->nid . '/example-action', array('query' => array('destination' => 'home')));

  // Visit our example overview page and click the third contextual link.
  // This should take us to a page for editing the third object we defined.
  $this->clickLink('Edit object', 2);
  $this->assertUrl('examples/contextual-links/3/edit', array('query' => array('destination' => 'examples/contextual-links')));

  // Enable our module's block, go back to the front page, and click the
  // "Edit object" contextual link that we expect to be there.
  // Add a block to the sidebar.
  $this->clickLink(t('Add block'), 3);
  $this->clickLink(t('Contextual links example block'));
  // $edit = array(
  // 'block_settings[count]' => 5,
  // );
  $this->backdropPost(NULL, array(), t('Add block'));
  // Save the layout.
  $this->backdropPost(NULL, array(), t('Save layout'));

  $this->clickLink('Edit object');
  $this->assertUrl('examples/contextual-links/1/edit', array('query' => array('destination' => 'node/1')));