class ViewsNoResultsBehaviorTest in Drupal 10
Same name and namespace in other branches
- 8 core/modules/views/tests/src/Functional/ViewsNoResultsBehaviorTest.php \Drupal\Tests\views\Functional\ViewsNoResultsBehaviorTest
- 9 core/modules/views/tests/src/Functional/ViewsNoResultsBehaviorTest.php \Drupal\Tests\views\Functional\ViewsNoResultsBehaviorTest
Tests no results behavior.
@group views
Hierarchy
- class \Drupal\Tests\BrowserTestBase extends \PHPUnit\Framework\TestCase uses \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, FunctionalTestSetupTrait, TestSetupTrait, BlockCreationTrait, ConfigTestTrait, ExtensionListTestTrait, ContentTypeCreationTrait, NodeCreationTrait, RandomGeneratorTrait, TestRequirementsTrait, PhpUnitWarnings, UiHelperTrait, UserCreationTrait, XdebugRequestTrait
- class \Drupal\Tests\views\Functional\ViewTestBase uses ViewResultAssertionTrait
- class \Drupal\Tests\views\Functional\ViewsNoResultsBehaviorTest
- class \Drupal\Tests\views\Functional\ViewTestBase uses ViewResultAssertionTrait
Expanded class hierarchy of ViewsNoResultsBehaviorTest
File
- core/
modules/ views/ tests/ src/ Functional/ ViewsNoResultsBehaviorTest.php, line 10
Namespace
Drupal\Tests\views\FunctionalView source
class ViewsNoResultsBehaviorTest extends ViewTestBase {
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'node',
'user',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE, $modules = []) : void {
parent::setUp($import_test_views, $modules);
$this
->enableViewsTestModule();
$user = $this
->createUser([], NULL, TRUE);
$this
->drupalLogin($user);
// Set the Stark theme and use the default templates from views module.
/** @var \Drupal\Core\Extension\ThemeInstallerInterface $theme_installer */
$theme_installer = \Drupal::service('theme_installer');
$theme_installer
->install([
'stark',
]);
$this
->config('system.theme')
->set('default', 'stark')
->save();
}
/**
* Tests the view with the text.
*/
public function testDuplicateText() {
$output = $this
->drupalGet('admin/content');
$this
->assertEquals(1, substr_count($output, 'No content available.'), 'Only one message should be present');
}
}