class TabledragMenuTest
Same name and namespace in other branches
- 4.0.x modules/tabledrag_example/tests/src/Functional/TabledragMenuTest.php \Drupal\Tests\tabledrag_example\Functional\TabledragMenuTest
Verify functionalities of tabledrag_example.
@group tabledrag_example @group examples
@todo Add more tests in https://www.drupal.org/project/examples/issues/2925368
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\tabledrag_example\Functional\TabledragMenuTest implements \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of TabledragMenuTest
Related topics
File
-
modules/
tabledrag_example/ tests/ src/ Functional/ TabledragMenuTest.php, line 19
Namespace
Drupal\Tests\tabledrag_example\FunctionalView source
class TabledragMenuTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected static $modules = [
'tabledrag_example',
];
/**
* The installation profile to use with this test.
*
* We need the 'minimal' profile in order to make sure the Tool block is
* available.
*
* @var string
*/
protected $profile = 'minimal';
/**
* Tests tabledrag_example menus.
*/
public function testTabledragInteractions() {
$links = [
'examples/tabledrag-example',
'examples/tabledrag-example/row',
'examples/tabledrag-example/nested',
'examples/tabledrag-example/roots-and-leaves',
'examples/tabledrag-example/reset',
];
// Login a user that can access content.
$this->drupalLogin($this->createUser([
'access content',
]));
$assertion = $this->assertSession();
// Get the front page, which should only have the links in the sidebar.
$this->drupalGet('');
foreach ($links as $path) {
$assertion->linkByHrefExists($path);
}
// Get each path and verify a 200 response.
foreach ($links as $path) {
$this->drupalGet($path);
$assertion->statusCodeEquals(200);
}
// Click all the submit and cancel buttons.
$pages = [
'tabledrag_example.simple_form' => [
'Save All Changes',
'Cancel',
],
'tabledrag_example.parent_form' => [
'Save All Changes',
'Cancel',
],
'tabledrag_example.rootleaf_form' => [
'Save All Changes',
'Cancel',
],
'tabledrag_example.reset_form' => [
'Yes, Reset It!',
],
];
foreach ($pages as $route => $buttons) {
$path = Url::fromRoute($route);
foreach ($buttons as $button) {
$this->drupalGet($path);
$this->submitForm([], $button);
$assertion->statusCodeEquals(200);
}
}
// The reset form implements 'Cancel' as a link.
$this->drupalGet(Url::fromRoute('tabledrag_example.reset_form'));
$this->clickLink('Cancel');
$assertion->statusCodeEquals(200);
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
TabledragMenuTest::$defaultTheme | protected | property | |
TabledragMenuTest::$modules | protected static | property | |
TabledragMenuTest::$profile | protected | property | The installation profile to use with this test. |
TabledragMenuTest::testTabledragInteractions | public | function | Tests tabledrag_example menus. |