2023-10-17 10:36:46 +02:00
|
|
|
// start test
|
|
|
|
/** @test */
|
|
|
|
public function it_loads_the_blog_page(): void {
|
|
|
|
$this->drupalGet('/blog');
|
|
|
|
|
|
|
|
$session = $this->assertSession();
|
|
|
|
$session->statusCodeEquals(200);
|
|
|
|
|
|
|
|
$session->responseContains('<h1>Blog</h1>');
|
|
|
|
$session->pageTextContains('Welcome to my blog!');
|
|
|
|
}
|
|
|
|
// end test
|
|
|
|
|
2024-05-09 13:57:56 +01:00
|
|
|
E 1 / 1 (100%)
|
|
|
|
|
|
|
|
Time: 00:02.101, Memory: 6.00 MB
|
|
|
|
|
|
|
|
// start output
|
|
|
|
There was 1 error:
|
|
|
|
|
|
|
|
1) Drupal\Tests\drupalcon\Functional\BlogPageTest::it_loads_the_blog_page
|
|
|
|
Behat\Mink\Exception\ResponseTextException:
|
|
|
|
The text "Welcome to my blog!" was not found anywhere in the text
|
|
|
|
of the current page.
|
|
|
|
// end output
|
|
|
|
|
|
|
|
/app/vendor/behat/mink/src/WebAssert.php:907
|
|
|
|
/app/vendor/behat/mink/src/WebAssert.php:293
|
|
|
|
/app/web/modules/custom/drupalcon/tests/src/Functional/BlogPageTest.php:17
|
|
|
|
/app/vendor/phpunit/phpunit/src/Framework/TestResult.php:728
|
|
|
|
|
|
|
|
ERRORS!
|
|
|
|
Tests: 1, Assertions: 3, Errors: 1.
|
|
|
|
|
2023-10-17 10:36:46 +02:00
|
|
|
// start code
|
|
|
|
namespace Drupal\drupalcon\Controller;
|
|
|
|
|
|
|
|
use Drupal\Core\StringTranslation\StringTranslationTrait;
|
|
|
|
|
|
|
|
class BlogPageController {
|
|
|
|
|
|
|
|
use StringTranslationTrait;
|
|
|
|
|
|
|
|
public function __invoke(): array {
|
|
|
|
return [
|
|
|
|
'#markup' => $this->t('Welcome to my blog!'),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
// end code
|
|
|
|
|
2024-05-09 13:57:56 +01:00
|
|
|
// start output2
|
2023-10-17 10:36:46 +02:00
|
|
|
. 1 / 1 (100%)
|
|
|
|
|
|
|
|
Time: 00:01.911, Memory: 6.00 MB
|
|
|
|
|
|
|
|
OK (1 test, 3 assertions)
|
2024-05-09 13:57:56 +01:00
|
|
|
// end output2
|
2023-10-17 10:36:46 +02:00
|
|
|
|
|
|
|
Task completed in 0m2.124s
|