ErrorHandlerTest.php in Apigee Edge 8
File
tests/src/Functional/ErrorHandlerTest.php
View source
<?php
namespace Drupal\Tests\apigee_edge\Functional;
use Drupal\Core\Url;
use Symfony\Component\HttpFoundation\Response;
class ErrorHandlerTest extends ApigeeEdgeFunctionalTestBase {
protected static $mock_api_client_ready = TRUE;
protected $prefix;
protected $drupalUser;
protected function setUp() {
parent::setUp();
$this->prefix = $this
->randomMachineName();
$this
->invalidateKey();
$this
->disableUserPresave();
$this->drupalUser = $this
->createAccount([], TRUE, $this->prefix);
$this->drupalUser
->save();
$this
->enableUserPresave();
}
public function testErrorPages() {
$this
->drupalLogin($this->rootUser);
$errorPageTitle = $this
->getRandomGenerator()
->word(16);
$this
->drupalPostForm(Url::fromRoute('apigee_edge.settings.error_page'), [
'error_page_title' => $errorPageTitle,
], 'Save configuration');
$this
->assertSession()
->pageTextContains('The configuration options have been saved.');
$this
->drupalLogin($this->drupalUser);
$parameters = [
'user' => $this->drupalUser
->id(),
'app' => 'x',
];
$routes = [
'entity.developer_app.collection_by_developer',
'entity.developer_app.add_form_for_developer',
'entity.developer_app.canonical_by_developer',
'entity.developer_app.edit_form_for_developer',
'entity.developer_app.delete_form_for_developer',
'entity.developer_app.analytics_for_developer',
];
foreach ($routes as $route_name) {
$route = Url::fromRoute($route_name, $parameters);
$this
->drupalGet($route);
$this
->assertEquals(Response::HTTP_SERVICE_UNAVAILABLE, $this
->getSession()
->getStatusCode(), $route_name);
$this
->assertSession()
->pageTextContains($errorPageTitle);
}
}
}