class KernelTestHttpRequestTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/KernelTestHttpRequestTest.php \Drupal\KernelTests\KernelTestHttpRequestTest
Tests making HTTP requests in a kernel test.
Attributes
#[CoversTrait(HttpKernelUiHelperTrait::class)]
#[Group('PHPUnit')]
#[Group('Test')]
#[Group('KernelTests')]
#[RunTestsInSeparateProcesses]
Hierarchy
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\Tests\DrupalTestCaseTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\Tests\BrowserHtmlDebugTrait, \Drupal\Tests\HttpKernelUiHelperTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\KernelTests\KernelTestHttpRequestTest extends \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of KernelTestHttpRequestTest
File
-
core/
tests/ Drupal/ KernelTests/ KernelTestHttpRequestTest.php, line 16
Namespace
Drupal\KernelTestsView source
class KernelTestHttpRequestTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'system',
'system_test',
'test_page_test',
];
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
}
/**
* Tests making a request.
*/
public function testRequest() : void {
$this->drupalGet('/system-test/main-content-handling');
$this->assertEquals(Response::HTTP_OK, $this->getSession()
->getStatusCode());
$this->assertSession()
->pageTextContains('Content to test main content fallback');
}
/**
* Tests clickLink() functionality.
*/
public function testClickLink() : void {
$this->drupalGet('test-page');
$this->clickLink('Visually identical test links');
$this->assertStringContainsString('user/login', $this->getSession()
->getCurrentUrl());
$this->drupalGet('test-page');
$this->clickLink('Visually identical test links', 0);
$this->assertStringContainsString('user/login', $this->getSession()
->getCurrentUrl());
$this->drupalGet('test-page');
$this->clickLink('Visually identical test links', 1);
$this->assertStringContainsString('user/register', $this->getSession()
->getCurrentUrl());
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.