public function testParse() { $kernel = new Kernel(); $kernel->boot(); $logger = new Logger(); $parser = new ControllerNameParser($kernel, $logger); $this->assertEquals('TestBundle\FooBundle\Controller\DefaultController::indexAction', $parser->parse('FooBundle:Default:index'), '->parse() converts a short a:b:c notation string to a class::method string'); $this->assertEquals('TestBundle\FooBundle\Controller\Sub\DefaultController::indexAction', $parser->parse('FooBundle:Sub\Default:index'), '->parse() converts a short a:b:c notation string to a class::method string'); $this->assertEquals('TestBundle\Fabpot\FooBundle\Controller\DefaultController::indexAction', $parser->parse('SensioFooBundle:Default:index'), '->parse() converts a short a:b:c notation string to a class::method string'); $this->assertEquals('TestBundle\Sensio\Cms\FooBundle\Controller\DefaultController::indexAction', $parser->parse('SensioCmsFooBundle:Default:index'), '->parse() converts a short a:b:c notation string to a class::method string'); try { $parser->parse('foo:'); $this->fail('->parse() throws an \InvalidArgumentException if the controller is not an a:b:c string'); } catch (\Exception $e) { $this->assertInstanceOf('\InvalidArgumentException', $e, '->parse() throws an \InvalidArgumentException if the controller is not an a:b:c string'); } try { $parser->parse('BarBundle:Default:index'); $this->fail('->parse() throws a \InvalidArgumentException if the class is found but does not exist'); } catch (\Exception $e) { $this->assertInstanceOf('\InvalidArgumentException', $e, '->parse() throws a \LogicException if the class is found but does not exist'); } }
/** * @dataProvider getParseInvalidTests * @expectedException \InvalidArgumentException */ public function testParseInvalid($name) { $kernel = new Kernel(); $kernel->boot(); $converter = new TemplateNameParser($kernel); $converter->parse($name); }
private function createParser() { $kernel = new Kernel(); $kernel->boot(); $logger = new Logger(); return new ControllerNameParser($kernel, $logger); }
public function testFromShortNotation() { $kernel = new Kernel(); $kernel->boot(); $logger = new Logger(); $converter = new ControllerNameConverter($kernel, $logger); $this->assertEquals('Symfony\\Bundle\\FrameworkBundle\\Controller\\DefaultController::indexAction', $converter->fromShortNotation('FrameworkBundle:Default:index'), '->fromShortNotation() converts a short a:b:c notation string to a class::method string'); try { $converter->fromShortNotation('foo:'); $this->fail('->fromShortNotation() throws an \\InvalidArgumentException if the controller is not an a:b:c string'); } catch (\Exception $e) { $this->assertInstanceOf('\\InvalidArgumentException', $e, '->toShortNotation() throws an \\InvalidArgumentException if the controller is not an a:b:c string'); } try { $converter->fromShortNotation('FooBundle:Default:index'); $this->fail('->fromShortNotation() throws a \\InvalidArgumentException if the class is found but does not exist'); } catch (\Exception $e) { $this->assertInstanceOf('\\InvalidArgumentException', $e, '->fromShortNotation() throws a \\LogicException if the class is found but does not exist'); } }
protected function setUp() { $kernel = new Kernel(); $kernel->boot(); $this->parser = new TemplateNameParser($kernel); }