Functional tests for the contextual_links_example module.
<?php /** * @file * Functional tests for the contextual_links_example module. */ /** * Functional tests for the contextual_links_example module. * * @ingroup contextual_links_example */ class ContextualLinksExampleTestCase extends BackdropWebTestCase { protected $webUser; /** * Enable modules and create user with specific permissions. */ public function setUp() { parent::setUp('contextual', 'contextual_links_example'); $this->webUser = $this->backdropCreateUser(array( 'access contextual links', 'administer blocks', 'administer layouts', )); $this->backdropLogin($this->webUser); } /** * Test the various contextual links that this module defines and displays. */ 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'))); } }