public function ReadmeHelpTest::testInsertPhpSnippets in README Help 8
Verifies markup generated by the PHP highlight_file() function.
See also
\Drupal\readmehelp\ReadmeHelpMarkdownConverter::insertPhpSnippets()
File
- tests/
src/ Functional/ ReadmeHelpTest.php, line 156
Class
- ReadmeHelpTest
- Tests markdown into markup conversion.
Namespace
Drupal\Tests\readmehelp\FunctionalCode
public function testInsertPhpSnippets() {
$this
->drupalLogin($this->adminUser);
$this
->drupalGet('admin/help/readmehelp_test');
// Ensure the actual help page is displayed to avoid a false positive.
$this
->assertResponse(200);
// The PHP file tokens should be replaced by the specified snippets.
$this
->assertSession()
->pageTextNotContains('@PHPFILE: readmehelp_test/readmehelp_test.module LINE:19 PADD:1 :PHPFILE@');
$this
->assertSession()
->pageTextNotContains('@PHPFILE: readmehelp_test/readmehelp_test.module :PHPFILE@');
$snippet = $this
->getSession()
->getPage()
->findAll('css', '.highlighted-snippet');
$this
->assertEquals('table', $snippet[0]
->getTagName());
$this
->assertEquals('table', $snippet[1]
->getTagName());
$strlen_0 = strlen($snippet[0]
->getText());
$strlen_1 = strlen($snippet[1]
->getText());
$this
->assertEquals(98, $strlen_0, "The expected snippet length 98 is equal to actual {$strlen_0}.");
$this
->assertEquals(320, $strlen_1, "The expected snippet length 320 is equal to actual {$strlen_1}.");
}