CustomProvidersUiTest.php in oEmbed Providers 2.x
File
tests/src/Functional/CustomProvidersUiTest.php
View source
<?php
namespace Drupal\Tests\oembed_providers\Functional;
use Drupal\Tests\BrowserTestBase;
class CustomProvidersUiTest extends BrowserTestBase {
protected $defaultTheme = 'stark';
protected $adminUser;
protected $nonAdminUser;
protected static $modules = [
'media',
'oembed_providers',
'oembed_providers_test',
];
protected function setUp() : void {
parent::setUp();
$this->adminUser = $this
->drupalCreateUser([
'access administration pages',
'administer oembed providers',
]);
$this->nonAdminUser = $this
->drupalCreateUser([
'access administration pages',
]);
}
public function testRoutePermissions() {
$assert_session = $this
->assertSession();
$this
->drupalLogin($this->nonAdminUser);
$this
->drupalGet('/admin/config/media/oembed-providers/custom-providers');
$assert_session
->statusCodeEquals(403);
$this
->drupalGet('/admin/config/media/oembed-providers/custom-providers/add');
$assert_session
->statusCodeEquals(403);
$this
->drupalGet('/admin/config/media/oembed-providers/custom-providers/unl_mediahub/edit');
$assert_session
->statusCodeEquals(403);
$this
->drupalGet('/admin/config/media/oembed-providers/custom-providers/unl_mediahub/delete');
$assert_session
->statusCodeEquals(403);
$this
->drupalLogin($this->adminUser);
$this
->drupalGet('/admin/config/media/oembed-providers/custom-providers');
$assert_session
->statusCodeEquals(200);
$this
->drupalGet('/admin/config/media/oembed-providers/custom-providers/add');
$assert_session
->statusCodeEquals(200);
$this
->drupalGet('/admin/config/media/oembed-providers/custom-providers/unl_mediahub/edit');
$assert_session
->statusCodeEquals(200);
$this
->drupalGet('/admin/config/media/oembed-providers/custom-providers/unl_mediahub/delete');
$assert_session
->statusCodeEquals(200);
}
}