ConfigEntityStatusUITest.php in Drupal 9
File
core/modules/config/tests/src/Functional/ConfigEntityStatusUITest.php
View source
<?php
namespace Drupal\Tests\config\Functional;
use Drupal\Tests\BrowserTestBase;
class ConfigEntityStatusUITest extends BrowserTestBase {
protected static $modules = [
'config_test',
];
protected $defaultTheme = 'stark';
public function testCRUD() {
$this
->drupalLogin($this
->drupalCreateUser([
'administer site configuration',
]));
$id = strtolower($this
->randomMachineName());
$edit = [
'id' => $id,
'label' => $this
->randomMachineName(),
];
$this
->drupalGet('admin/structure/config_test/add');
$this
->submitForm($edit, 'Save');
$entity = \Drupal::entityTypeManager()
->getStorage('config_test')
->load($id);
$disable_url = $entity
->toUrl('disable');
$this
->assertSession()
->linkByHrefExists($disable_url
->toString());
$this
->drupalGet($disable_url);
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->linkByHrefNotExists($disable_url
->toString());
$enable_url = $entity
->toUrl('enable');
$this
->assertSession()
->linkByHrefExists($enable_url
->toString());
$this
->drupalGet($enable_url);
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->linkByHrefNotExists($enable_url
->toString());
}
}