You are here

public function AnnotationClassLoaderTest::testClassRouteLoad in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/routing/Tests/Loader/AnnotationClassLoaderTest.php \Symfony\Component\Routing\Tests\Loader\AnnotationClassLoaderTest::testClassRouteLoad()

File

vendor/symfony/routing/Tests/Loader/AnnotationClassLoaderTest.php, line 150

Class

AnnotationClassLoaderTest

Namespace

Symfony\Component\Routing\Tests\Loader

Code

public function testClassRouteLoad() {
  $classRouteData = array(
    'path' => '/prefix',
    'schemes' => array(
      'https',
    ),
    'methods' => array(
      'GET',
    ),
  );
  $methodRouteData = array(
    'name' => 'route1',
    'path' => '/path',
    'schemes' => array(
      'http',
    ),
    'methods' => array(
      'POST',
      'PUT',
    ),
  );
  $this->reader
    ->expects($this
    ->once())
    ->method('getClassAnnotation')
    ->will($this
    ->returnValue($this
    ->getAnnotatedRoute($classRouteData)));
  $this->reader
    ->expects($this
    ->once())
    ->method('getMethodAnnotations')
    ->will($this
    ->returnValue(array(
    $this
      ->getAnnotatedRoute($methodRouteData),
  )));
  $routeCollection = $this->loader
    ->load('Symfony\\Component\\Routing\\Tests\\Fixtures\\AnnotatedClasses\\BarClass');
  $route = $routeCollection
    ->get($methodRouteData['name']);
  $this
    ->assertSame($classRouteData['path'] . $methodRouteData['path'], $route
    ->getPath(), '->load concatenates class and method route path');
  $this
    ->assertEquals(array_merge($classRouteData['schemes'], $methodRouteData['schemes']), $route
    ->getSchemes(), '->load merges class and method route schemes');
  $this
    ->assertEquals(array_merge($classRouteData['methods'], $methodRouteData['methods']), $route
    ->getMethods(), '->load merges class and method route methods');
}