CancelButtonEntityRoutesTest.php in Entity Form Cancel Button 8
File
tests/src/Functional/CancelButtonEntityRoutesTest.php
View source
<?php
namespace Drupal\Tests\cancel_button\Functional;
use Drupal\Tests\BrowserTestBase;
class CancelButtonEntityRoutesTest extends BrowserTestBase {
public static $modules = [
'cancel_button',
'cancel_button_test',
'entity_test',
];
protected $entities = [];
protected function setUp() {
parent::setUp();
foreach ([
'entity_test_broken_canonical',
'entity_test_broken_collection',
] as $entity_type) {
$storage = $this->container
->get('entity_type.manager')
->getStorage($entity_type);
$entity_test = $storage
->create([
'name' => $this
->randomMachineName(),
]);
$entity_test
->save();
$this->entities[] = $entity_test;
}
$permissions = [
'administer cancel button configuration',
'administer entity_test content',
'view test entity',
];
$this
->drupalLogin($this
->drupalCreateUser($permissions));
}
public function testEntityFormCancelButton() {
foreach ($this->entities as $entity) {
$uri = $entity
->toUrl('edit-form');
$this
->drupalGet($uri);
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->linkExists('Cancel');
}
}
}