page_manager-8.x-4.0-beta6/tests/src/Unit/RouteAttributesTest.php
tests/src/Unit/RouteAttributesTest.php
<?php
namespace Drupal\Tests\page_manager\Unit;
use Drupal\page_manager\Routing\RouteAttributes;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\Routing\Route;
/**
* @coversDefaultClass \Drupal\page_manager\Routing\RouteAttributes
* @group PageManager
*/
class RouteAttributesTest extends UnitTestCase {
/**
* @covers ::extractRawAttributes
*
* @dataProvider providerTestExtractRawAttributes
*/
public function testExtractRawAttributes(Route $route, $name, $path, array $expected) {
$expected['_route_object'] = $route;
$expected['_route'] = $name;
$this->assertEquals($expected, RouteAttributes::extractRawAttributes($route, $name, $path));
}
/**
* Data provider for testExtractRawAttributes.
*/
public static function providerTestExtractRawAttributes() {
$data = [];
$data['no-parameters'] = [new Route('/prefix/a'), 'a_route', '/prefix', []];
$data['no-matching-parameters'] = [new Route('/prefix/{x}'), 'a_route', '/different-prefix/b', []];
$data['matching-parameters'] = [new Route('/prefix/{x}'), 'a_route', '/prefix/b', ['x' => 'b']];
// phpcs:ignore
$data['with-defaults'] = [new Route('/prefix/{x}', ['foo' => 'bar']), 'a_route', '/different-prefix/b', ['foo' => 'bar']];
return $data;
}
}
