1 contextual_links_example.test | public ContextualLinksExampleTestCase::testContextualLinksExample() |
Test the various contextual links that this module defines and displays.
File
- modules/
examples/ contextual_links_example/ tests/ contextual_links_example.test, line 32 - Functional tests for the contextual_links_example module.
Class
- ContextualLinksExampleTestCase
- Functional tests for the contextual_links_example module.
Code
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->backdropGet('');
$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->backdropGet('examples/contextual-links');
$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.
$this->backdropGet('admin/structure/layouts/manage/default');
// 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->backdropGet('node/1');
$this->clickLink('Edit object');
$this->assertUrl('examples/contextual-links/1/edit', array('query' => array('destination' => 'node/1')));
}