Commit 9a8a42d1 authored by Dries's avatar Dries

Issue #1833440 by scor, klausi, Crell: Added Implement partial matcher based...

Issue #1833440 by scor, klausi, Crell: Added Implement partial matcher based on content negotiation MIME type.
parent 5307c387
......@@ -8,8 +8,8 @@
namespace Drupal\Core\Routing;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\UnsupportedMediaTypeHttpException;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Exception\RouteNotFoundException;
/**
* This class filters routes based on the media type in HTTP Accept headers.
......@@ -46,9 +46,7 @@ public function matchRequestPartial(Request $request) {
}
if (!count($collection)) {
// @todo update with UnsupportedMediaTypeException when available
// @see http://drupal.org/node/1831074
throw new RouteNotFoundException();
throw new UnsupportedMediaTypeHttpException();
}
return $collection;
......
......@@ -7,17 +7,13 @@
namespace Drupal\system\Tests\Routing;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Exception\RouteNotFoundException;
use Drupal\simpletest\UnitTestBase;
use Drupal\Core\Routing\FirstEntryFinalMatcher;
use Drupal\Core\Routing\MimeTypeMatcher;
use Drupal\Core\Routing\NestedMatcher;
use Drupal\Core\Routing\FirstEntryFinalMatcher;
use Drupal\simpletest\UnitTestBase;
use Exception;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\UnsupportedMediaTypeHttpException;
/**
* Basic tests for the MimeTypeMatcher class.
......@@ -117,8 +113,8 @@ public function testNoRouteFound() {
$routes = $matcher->matchRequestPartial($request);
$this->fail(t('No exception was thrown.'));
}
catch (Exception $e) {
$this->assertTrue($e instanceof RouteNotFoundException, 'The correct exception was thrown.');
catch (UnsupportedMediaTypeHttpException $e) {
$this->pass('The correct exception was thrown.');
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment