class FieldDropButtonTest
Same name in this branch
- 9 core/modules/views/tests/src/Kernel/Handler/FieldDropbuttonTest.php \Drupal\Tests\views\Kernel\Handler\FieldDropbuttonTest
Same name and namespace in other branches
- 11.x core/modules/views/tests/src/Kernel/Handler/FieldDropbuttonTest.php \Drupal\Tests\views\Kernel\Handler\FieldDropbuttonTest
- 11.x core/modules/views/tests/src/Functional/Handler/FieldDropButtonTest.php \Drupal\Tests\views\Functional\Handler\FieldDropButtonTest
- 10 core/modules/views/tests/src/Kernel/Handler/FieldDropbuttonTest.php \Drupal\Tests\views\Kernel\Handler\FieldDropbuttonTest
- 10 core/modules/views/tests/src/Functional/Handler/FieldDropButtonTest.php \Drupal\Tests\views\Functional\Handler\FieldDropButtonTest
- 8.9.x core/modules/views/tests/src/Kernel/Handler/FieldDropbuttonTest.php \Drupal\Tests\views\Kernel\Handler\FieldDropbuttonTest
- 8.9.x core/modules/views/tests/src/Functional/Handler/FieldDropButtonTest.php \Drupal\Tests\views\Functional\Handler\FieldDropButtonTest
Tests the dropbutton field handler.
@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 extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\views\Functional\ViewTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait extends \Drupal\Tests\BrowserTestBase
- class \Drupal\Tests\views\Functional\Handler\FieldDropButtonTest extends \Drupal\Tests\views\Functional\ViewTestBase
- class \Drupal\Tests\views\Functional\ViewTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of FieldDropButtonTest
See also
\Drupal\system\Plugin\views\field\Dropbutton
File
-
core/
modules/ views/ tests/ src/ Functional/ Handler/ FieldDropButtonTest.php, line 13
Namespace
Drupal\Tests\views\Functional\HandlerView source
class FieldDropButtonTest extends ViewTestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = [
'test_dropbutton',
];
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'node',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE, $modules = [
'views_test_config',
]) : void {
parent::setUp($import_test_views, $modules);
$admin_user = $this->drupalCreateUser([
'access content overview',
'administer nodes',
'bypass node access',
]);
$this->drupalLogin($admin_user);
}
/**
* Tests dropbutton field.
*/
public function testDropbutton() {
// Create some test nodes.
$nodes = [];
for ($i = 0; $i < 5; $i++) {
$nodes[] = $this->drupalCreateNode();
}
$this->drupalGet('test-dropbutton');
foreach ($nodes as $node) {
// Test that only one node title link was found.
$this->assertSession()
->elementsCount('xpath', "//ul[contains(@class, dropbutton)]/li/a[contains(@href, '/node/{$node->id()}') and text()='{$node->label()}']", 1);
// Test that only one custom link was found.
$this->assertSession()
->elementsCount('xpath', "//ul[contains(@class, dropbutton)]/li/a[contains(@href, '/node/{$node->id()}') and text()='Custom Text']", 1);
}
// Check if the dropbutton.js library is available.
$this->drupalGet('admin/content');
$this->assertSession()
->responseContains('dropbutton.js');
// Check if the dropbutton.js library is available on a cached page to
// ensure that bubbleable metadata is not lost in the views render workflow.
$this->drupalGet('admin/content');
$this->assertSession()
->responseContains('dropbutton.js');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.