You are here

public function AnnotationClassLoaderTest::testLoad 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::testLoad()

@dataProvider getLoadTests

File

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

Class

AnnotationClassLoaderTest

Namespace

Symfony\Component\Routing\Tests\Loader

Code

public function testLoad($className, $routeData = array(), $methodArgs = array()) {
  $routeData = array_replace(array(
    'name' => 'route',
    'path' => '/',
    'requirements' => array(),
    'options' => array(),
    'defaults' => array(),
    'schemes' => array(),
    'methods' => array(),
    'condition' => '',
  ), $routeData);
  $this->reader
    ->expects($this
    ->once())
    ->method('getMethodAnnotations')
    ->will($this
    ->returnValue(array(
    $this
      ->getAnnotatedRoute($routeData),
  )));
  $routeCollection = $this->loader
    ->load($className);
  $route = $routeCollection
    ->get($routeData['name']);
  $this
    ->assertSame($routeData['path'], $route
    ->getPath(), '->load preserves path annotation');
  $this
    ->assertCount(count($routeData['requirements']), array_intersect_assoc($routeData['requirements'], $route
    ->getRequirements()), '->load preserves requirements annotation');
  $this
    ->assertCount(count($routeData['options']), array_intersect_assoc($routeData['options'], $route
    ->getOptions()), '->load preserves options annotation');
  $defaults = array_replace($methodArgs, $routeData['defaults']);
  $this
    ->assertCount(count($defaults), array_intersect_assoc($defaults, $route
    ->getDefaults()), '->load preserves defaults annotation and merges them with default arguments in method signature');
  $this
    ->assertEquals($routeData['schemes'], $route
    ->getSchemes(), '->load preserves schemes annotation');
  $this
    ->assertEquals($routeData['methods'], $route
    ->getMethods(), '->load preserves methods annotation');
  $this
    ->assertSame($routeData['condition'], $route
    ->getCondition(), '->load preserves condition annotation');
}