Sets a parameter.
public setParameter ( string $name, mixed $value ) | ||
$name | string | The parameter name |
$value | mixed | The parameter value |
protected function generate_route_objects() { $this->request = new phpbb_mock_request(); $this->request->overwrite('SCRIPT_NAME', $this->get_uri(), \phpbb\request\request_interface::SERVER); $this->request->overwrite('SCRIPT_FILENAME', $this->get_script_name(), \phpbb\request\request_interface::SERVER); $this->request->overwrite('REQUEST_URI', $this->get_base_uri(), \phpbb\request\request_interface::SERVER); $this->request->overwrite('SERVER_NAME', 'localhost', \phpbb\request\request_interface::SERVER); $this->request->overwrite('SERVER_PORT', '80', \phpbb\request\request_interface::SERVER); $this->symfony_request = new \phpbb\symfony_request($this->request); $this->filesystem = new \phpbb\filesystem\filesystem(); $this->phpbb_path_helper = new \phpbb\path_helper($this->symfony_request, $this->filesystem, $this->request, $phpbb_root_path, $phpEx); $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); $lang = new \phpbb\language\language($lang_loader); $this->user = new \phpbb\user($lang, '\\phpbb\\datetime'); $container = new phpbb_mock_container_builder(); $container->setParameter('core.environment', PHPBB_ENVIRONMENT); $cache_path = $phpbb_root_path . 'cache/twig'; $context = new \phpbb\template\context(); $loader = new \phpbb\template\twig\loader($this->filesystem, ''); $twig = new \phpbb\template\twig\environment($this->config, $this->filesystem, $this->phpbb_path_helper, $container, $cache_path, null, $loader, array('cache' => false, 'debug' => false, 'auto_reload' => true, 'autoescape' => false)); $this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $this->config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user))); $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); $this->extension_manager = new phpbb_mock_extension_manager(dirname(__FILE__) . '/', array('vendor2/foo' => array('ext_name' => 'vendor2/foo', 'ext_active' => '1', 'ext_path' => 'ext/vendor2/foo/'))); $this->router = new phpbb_mock_router($container, $this->filesystem, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $this->extension_manager); $this->router->find_routing_files($this->extension_manager->all_enabled(false)); $this->router->find(dirname(__FILE__) . '/'); // Set correct current phpBB root path $this->root_path = $this->get_phpbb_root_path(); }
public function test_router_find_files() { $container = new phpbb_mock_container_builder(); $container->setParameter('core.environment', PHPBB_ENVIRONMENT); $router = new \phpbb\routing\router($container, new \phpbb\filesystem\filesystem(), dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $this->extension_manager); $router->find_routing_files($this->extension_manager->all_enabled(false)); $routes = $router->find(__DIR__)->get_routes(); // This will need to be updated if any new routes are defined $this->assertInstanceOf('Symfony\\Component\\Routing\\Route', $routes->get('core_controller')); $this->assertEquals('/core_foo', $routes->get('core_controller')->getPath()); $this->assertInstanceOf('Symfony\\Component\\Routing\\Route', $routes->get('controller1')); $this->assertEquals('/foo', $routes->get('controller1')->getPath()); $this->assertInstanceOf('Symfony\\Component\\Routing\\Route', $routes->get('controller2')); $this->assertEquals('/foo/bar', $routes->get('controller2')->getPath()); $this->assertInstanceOf('Symfony\\Component\\Routing\\Route', $routes->get('controller3')); $this->assertEquals('/bar', $routes->get('controller3')->getPath()); $this->assertNull($routes->get('controller_noroute')); }
public function test_router_default_loader() { $container = new phpbb_mock_container_builder(); $container->setParameter('core.environment', PHPBB_ENVIRONMENT); $loader = new \Symfony\Component\Routing\Loader\YamlFileLoader(new \phpbb\routing\file_locator(new \phpbb\filesystem\filesystem(), dirname(__FILE__) . '/')); $resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $this->extension_manager); $router = new phpbb_mock_router($container, $resources_locator, $loader, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); $routes = $router->get_routes(); // This will need to be updated if any new routes are defined $this->assertInstanceOf('Symfony\\Component\\Routing\\Route', $routes->get('core_controller')); $this->assertEquals('/core_foo', $routes->get('core_controller')->getPath()); $this->assertInstanceOf('Symfony\\Component\\Routing\\Route', $routes->get('controller1')); $this->assertEquals('/foo', $routes->get('controller1')->getPath()); $this->assertInstanceOf('Symfony\\Component\\Routing\\Route', $routes->get('controller2')); $this->assertEquals('/foo/bar', $routes->get('controller2')->getPath()); $this->assertInstanceOf('Symfony\\Component\\Routing\\Route', $routes->get('controller3')); $this->assertEquals('/bar', $routes->get('controller3')->getPath()); $this->assertNull($routes->get('controller_noroute')); }
public function setUp() { global $phpbb_container, $config, $phpbb_root_path, $phpEx, $request, $user; $phpbb_container = new phpbb_mock_container_builder(); $config = new \phpbb\config\config(array('board_email_sig' => '-- Thanks, The Management', 'sitename' => 'yourdomain.com', 'default_lang' => 'en')); $phpbb_container->set('config', $config); $request = new phpbb_mock_request(); $symfony_request = new \phpbb\symfony_request($request); $filesystem = new \phpbb\filesystem\filesystem(); $phpbb_path_helper = new \phpbb\path_helper($symfony_request, $filesystem, $request, $phpbb_root_path, $phpEx); $phpbb_container->set('path_helper', $phpbb_path_helper); $phpbb_container->set('filesystem', $filesystem); $cache_path = $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/twig'; $phpbb_container->setParameter('core.template.cache_path', $cache_path); $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); $lang = new \phpbb\language\language($lang_loader); $user = new \phpbb\user($lang, '\\phpbb\\datetime'); $phpbb_container->set('user', $user); $extension_manager = new phpbb_mock_extension_manager(dirname(__FILE__) . '/', array('vendor2/foo' => array('ext_name' => 'vendor2/foo', 'ext_active' => '1', 'ext_path' => 'ext/vendor2/foo/'))); $phpbb_container->set('ext.manager', $extension_manager); $context = new \phpbb\template\context(); $twig_extension = new \phpbb\template\twig\extension($context, $lang); $phpbb_container->set('template.twig.extensions.phpbb', $twig_extension); $twig_extensions_collection = new \phpbb\di\service_collection($phpbb_container); $twig_extensions_collection->add('template.twig.extensions.phpbb'); $phpbb_container->set('template.twig.extensions.collection', $twig_extensions_collection); $twig = new \phpbb\template\twig\environment($config, $filesystem, $phpbb_path_helper, $cache_path, null, new \phpbb\template\twig\loader($filesystem, ''), array('cache' => false, 'debug' => false, 'auto_reload' => true, 'autoescape' => false)); $twig->addExtension($twig_extension); $phpbb_container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); if (!class_exists('messenger')) { include $phpbb_root_path . 'includes/functions_messenger.' . $phpEx; } $this->messenger = new \messenger(); $reflection = new ReflectionObject($this->messenger); $this->reflection_template_property = $reflection->getProperty('template'); $this->reflection_template_property->setAccessible(true); }
protected function get_cache_driver() { if (!$this->cache) { global $phpbb_container; $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->setParameter('core.environment', PHPBB_ENVIRONMENT); $this->cache = new \phpbb\cache\driver\file(); } return $this->cache; }