FieldDropButtonTest.php in Drupal 10
File
core/modules/views/tests/src/Functional/Handler/FieldDropButtonTest.php
View source
<?php
namespace Drupal\Tests\views\Functional\Handler;
use Drupal\Tests\views\Functional\ViewTestBase;
class FieldDropButtonTest extends ViewTestBase {
public static $testViews = [
'test_dropbutton',
];
protected static $modules = [
'node',
];
protected $defaultTheme = 'stark';
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);
}
public function testDropbutton() {
$nodes = [];
for ($i = 0; $i < 5; $i++) {
$nodes[] = $this
->drupalCreateNode();
}
$this
->drupalGet('test-dropbutton');
foreach ($nodes as $node) {
$this
->assertSession()
->elementsCount('xpath', "//ul[contains(@class, dropbutton)]/li/a[contains(@href, '/node/{$node->id()}') and text()='{$node->label()}']", 1);
$this
->assertSession()
->elementsCount('xpath', "//ul[contains(@class, dropbutton)]/li/a[contains(@href, '/node/{$node->id()}') and text()='Custom Text']", 1);
}
$this
->drupalGet('admin/content');
$this
->assertSession()
->responseContains('dropbutton.js');
$this
->drupalGet('admin/content');
$this
->assertSession()
->responseContains('dropbutton.js');
}
}