Namespace
Drupal\Tests\hooks_example\Functional
File
-
modules/hooks_example/tests/src/Functional/HooksExampleTest.php
View source
<?php
namespace Drupal\Tests\hooks_example\Functional;
use Drupal\Tests\BrowserTestBase;
class HooksExampleTest extends BrowserTestBase {
protected $defaultTheme = 'stark';
protected static $modules = [
'help',
'hooks_example',
];
protected $profile = 'minimal';
protected function setUp() : void {
parent::setUp();
$this->createContentType([
'type' => 'page',
]);
$account = $this->drupalCreateUser([
'access administration pages',
]);
$this->drupalLogin($account);
}
public function testHooksExample() {
$this->drupalGet('<front>');
$this->assertSession()
->linkExists('Hooks Example');
$this->drupalGet('examples/hooks-example');
$this->assertSession()
->statusCodeEquals(200);
$this->drupalGet('admin/help/hooks_example');
$this->assertSession()
->statusCodeEquals(200);
$this->assertSession()
->pageTextContains('This text is provided by the function hooks_example_help()');
$settings = [
'type' => 'page',
'title' => 'Hooks Example Testing Node',
'status' => 1,
];
$node = $this->drupalCreateNode($settings);
$this->drupalGet($node->toUrl());
$this->assertSession()
->pageTextContains('You have viewed this node 1 times this session.');
$this->assertSession()
->pageTextContains('This is the first time you have viewed the node ' . $node->label() . '.');
$this->drupalGet('<front>');
$this->drupalGet($node->toUrl());
$this->assertSession()
->pageTextContains('You have viewed this node 2 times this session.');
$this->assertSession()
->pageTextNotContains('This is the first time you have viewed the node ' . $node->label() . '.');
$this->drupalLogout();
$this->drupalGet('user/login');
$this->assertSession()
->pageTextContains('This text has been altered by hooks_example_form_alter().');
}
}
Classes
| Title |
Deprecated |
Summary |
| HooksExampleTest |
|
Test the functionality of the Hooks Example module. |