Skip to content

Commit

Permalink
[Routing] Added YamlFileLoader tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jakzal committed Mar 19, 2011
1 parent f981b6c commit 4244ae7
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/Symfony/Tests/Component/Routing/Fixtures/incomplete.yml
@@ -0,0 +1,2 @@
blog_show:
defaults: { _controller: MyBlogBundle:Blog:show }
@@ -0,0 +1,4 @@
blog_show:
pattern: /blog/{slug}
defaults: { _controller: MyBlogBundle:Blog:show }

@@ -0,0 +1,2 @@
blog_show:
resource: validpattern.yml
Expand Up @@ -60,4 +60,33 @@ public function testLoadThrowsExceptionIfArrayHasUnsupportedKeys()
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
$loader->load('nonvalidkeys.yml');
}

/**
* @expectedException \InvalidArgumentException
*/
public function testLoadThrowsExceptionWhenIncomplete()
{
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
$loader->load('incomplete.yml');
}

public function testLoadWithPattern()
{
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
$routeCollection = $loader->load('validpattern.yml');
$routes = $routeCollection->all();

$this->assertEquals(1, count($routes), 'One route is loaded');
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
}

public function testLoadWithResource()
{
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
$routeCollection = $loader->load('validresource.yml');
$routes = $routeCollection->all();

$this->assertEquals(1, count($routes), 'One route is loaded');
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
}
}

0 comments on commit 4244ae7

Please sign in to comment.