class AreaTitleWebTest
Same name and namespace in other branches
- 11.x core/modules/views/tests/src/Functional/Handler/AreaTitleWebTest.php \Drupal\Tests\views\Functional\Handler\AreaTitleWebTest
- 10 core/modules/views/tests/src/Functional/Handler/AreaTitleWebTest.php \Drupal\Tests\views\Functional\Handler\AreaTitleWebTest
Tests the title area handler with a web test.
@group views
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\views\Functional\ViewTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait implements \Drupal\Tests\BrowserTestBase
- class \Drupal\Tests\views\Functional\Handler\AreaTitleWebTest implements \Drupal\Tests\views\Functional\ViewTestBase
- class \Drupal\Tests\views\Functional\ViewTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait implements \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of AreaTitleWebTest
See also
\Drupal\views\Plugin\views\area\Title
File
-
core/
modules/ views/ tests/ src/ Functional/ Handler/ AreaTitleWebTest.php, line 14
Namespace
Drupal\Tests\views\Functional\HandlerView source
class AreaTitleWebTest extends ViewTestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = [
'test_area_title',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE, $modules = [
'views_test_config',
]) : void {
parent::setUp($import_test_views, $modules);
$this->enableViewsTestModule();
}
/**
* Tests the title area handler.
*/
public function testTitleText() {
// Confirm that the view has the normal title before making the view return
// no result.
$this->drupalGet('test-area-title');
$this->assertSession()
->titleEquals('test_title_header | Drupal');
// Change the view to return no result.
/** @var \Drupal\views\Entity\View $view */
$view = View::load('test_area_title');
$display =& $view->getDisplay('default');
$display['display_options']['filters']['name'] = [
'field' => 'name',
'id' => 'name',
'table' => 'views_test_data',
'relationship' => 'none',
'plugin_id' => 'string',
// Add a value which does not exist. The dataset is defined in
// \Drupal\views\Tests\ViewTestData::dataSet().
'value' => 'Euler',
];
$view->save();
$this->drupalGet('test-area-title');
$this->assertSession()
->titleEquals('test_title_empty | Drupal');
// Change the view to return a result instead.
/** @var \Drupal\views\Entity\View $view */
$view = View::load('test_area_title');
$display =& $view->getDisplay('default');
$display['display_options']['filters']['name'] = [
'field' => 'name',
'id' => 'name',
'table' => 'views_test_data',
'relationship' => 'none',
'plugin_id' => 'string',
// Change to a value which does exist. The dataset is defined in
// \Drupal\views\Tests\ViewTestData::dataSet().
'value' => 'Ringo',
];
$view->save();
$this->drupalGet('test-area-title');
$this->assertSession()
->titleEquals('test_title_header | Drupal');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.