RedirectNodeFormTest.php in Redirect 8
File
tests/src/Functional/RedirectNodeFormTest.php
View source
<?php
namespace Drupal\Tests\redirect\Functional;
use Drupal\Tests\BrowserTestBase;
class RedirectNodeFormTest extends BrowserTestBase {
protected $webUser;
protected $adminUser;
public static $modules = [
'node',
'redirect',
];
protected $defaultTheme = 'stark';
protected function setUp() {
parent::setUp();
if ($this->profile != 'standard') {
$this
->drupalCreateContentType([
'type' => 'page',
'name' => 'Basic page',
'display_submitted' => FALSE,
]);
}
$this->webUser = $this
->drupalCreateUser([
'access content',
'create page content',
'edit own page content',
]);
$this->adminUser = $this
->drupalCreateUser([
'access content',
'administer redirects',
'bypass node access',
]);
}
public function testNodeForm() {
$this
->drupalLogin($this->webUser);
$settings = [
'title' => $this
->randomMachineName(8),
];
$node = $this
->drupalCreateNode($settings);
$this
->drupalGet('node/' . $node
->id() . '/edit');
$this
->assertNoRaw('Add URL redirect');
$this
->drupalLogin($this->adminUser);
$this
->drupalGet('node/' . $node
->id() . '/edit');
$this
->assertRaw('Add URL redirect');
$this
->clickLink('Add URL redirect');
$this
->assertUrl('admin/config/search/redirect/add');
$this
->assertFieldsByValue($this
->xpath("//input[@id = 'edit-redirect-redirect-0-uri']"), '/node/' . $node
->id(), 'To: field correctly pre-filled.');
}
}