public function testConfigurationReadFromRouteOptionsIfEmpty() { $routes = new RouteCollection(); $routes->add('test_route', new Route('/test/{authorId}', array(), array(), array('propel_converter' => array('author' => array('mapping' => array('authorId' => 'id')))))); $router = $this->getMock('Symfony\\Bundle\\FrameworkBundle\\Routing\\Router', array(), array(), '', false); $router->expects($this->once())->method('getRouteCollection')->will($this->returnValue($routes)); $paramConverter = new PropelParamConverter(); $paramConverter->setRouter($router); $request = new Request(); $request->attributes->add(array('_route' => 'test_route', 'id' => 10, 'author' => null)); $configuration = new ParamConverter(array('class' => 'Propel\\PropelBundle\\Tests\\Request\\ParamConverter\\MyAuthor', 'name' => 'author', 'options' => array())); $paramConverter->apply($request, $configuration); $author = $request->attributes->get('author'); $this->assertInstanceOf('Propel\\PropelBundle\\Tests\\Request\\ParamConverter\\MyAuthor', $author, 'param "author" should be an instance of "Propel\\PropelBundle\\Tests\\Request\\ParamConverter\\MyAuthor"'); }
/** * @expectedException LogicException */ public function testParamConverterFindLogicError() { $paramConverter = new PropelParamConverter(); $request = new Request(array(), array(), array('book' => null)); $configuration = new ParamConverter(array('class' => 'Propel\\PropelBundle\\Tests\\Fixtures\\Model\\Book', 'name' => 'book')); $paramConverter->apply($request, $configuration); }