Issue #2093497 by dawehner: Convert ExceptionControllerTest to a phpunit test.

8.0.x
webchick 2013-10-08 22:45:35 -07:00
parent e09eb5ea1b
commit 34eb47b5c8
1 changed files with 15 additions and 9 deletions

View File

@ -1,21 +1,26 @@
<?php <?php
/** /**
* Definition of Drupal\system\Tests\System\ExceptionControllerTest. * @file
* Contains \Drupal\Tests\Core\Controller\ExceptionControllerTest
*/ */
namespace Drupal\system\Tests\System; namespace Drupal\system\Tests\System;
use \Drupal\Core\ContentNegotiation; use Drupal\Core\ContentNegotiation;
use \Drupal\Core\Controller\ExceptionController; use Drupal\Core\Controller\ExceptionController;
use \Drupal\simpletest\UnitTestBase; use Drupal\Tests\UnitTestCase;
use \Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use \Symfony\Component\HttpKernel\Exception\FlattenException; use Symfony\Component\HttpKernel\Exception\FlattenException;
/** /**
* Tests exception controller. * Tests exception controller.
*
* @see \Drupal\Core\Controller\ExceptionController
*
* @group Drupal
*/ */
class ExceptionControllerTest extends UnitTestBase { class ExceptionControllerTest extends UnitTestCase {
public static function getInfo() { public static function getInfo() {
return array( return array(
@ -33,7 +38,8 @@ class ExceptionControllerTest extends UnitTestBase {
$flat_exception = FlattenException::create($exception, 405); $flat_exception = FlattenException::create($exception, 405);
$exception_controller = new ExceptionController(new ContentNegotiation()); $exception_controller = new ExceptionController(new ContentNegotiation());
$response = $exception_controller->execute($flat_exception, new Request()); $response = $exception_controller->execute($flat_exception, new Request());
$this->assertEqual($response->getStatusCode(), 405, 'HTTP status of response is correct.'); $this->assertEquals($response->getStatusCode(), 405, 'HTTP status of response is correct.');
$this->assertEqual($response->getContent(), 'Method Not Allowed', 'HTTP response body is correct.'); $this->assertEquals($response->getContent(), 'Method Not Allowed', 'HTTP response body is correct.');
} }
} }