ThemingExampleTest.php in Examples for Developers 3.x
File
modules/theming_example/tests/src/Functional/ThemingExampleTest.php
View source
<?php
namespace Drupal\Tests\theming_example\Functional;
use Drupal\Tests\examples\Functional\ExamplesBrowserTestBase;
class ThemingExampleTest extends ExamplesBrowserTestBase {
protected $defaultTheme = 'stark';
public static $modules = [
'theming_example',
];
protected $profile = 'minimal';
public function testThemingPage() {
$this
->drupalGet('/examples/theming_example');
$this
->assertRaw('Some examples of pages and forms that are run through theme functions.</h1>');
$this
->assertRaw('examples/theming_example/form_select">Simple form 1</a>');
$this
->assertRaw('examples/theming_example/form_text">Simple form 2</a>');
$this
->drupalGet('/examples/theming_example/list');
$this
->assertSession()
->responseMatches('/<link rel="stylesheet".*theming_example.css/');
$li_list = $this
->xpath('//ul[contains(@class,"render-version-list")]/li');
$this
->assertTrue($li_list[0]
->getText() == 'First item');
$li_list = $this
->xpath('//ol[contains(@class,"theming-example-list")]/li');
$this
->assertTrue($li_list[1]
->getText() == 'Second item');
$this
->drupalGet('/examples/theming_example/form_select');
$this
->assertRaw('<h3 data-drupal-selector="edit-title">Choose which ordering you want</h3>');
$this
->assertRaw('<strong>Choose which ordering you want</strong>');
$this
->assertSession()
->responseMatches('/<div class="container-inline choice-wrapper"><div class="[a-zA-Z- ]* form-item-choice/');
$this
->assertSession()
->responseNotMatches('/<link rel="stylesheet".*theming_example.css/');
$this
->drupalGet('/examples/theming_example/form_text');
$this
->assertText('Please input something!');
}
}