protected function setUp() { parent::setUp(); $this->cache = new phpbb_mock_cache(); $this->config = new \phpbb\config\config(array('version' => '3.1.0')); $this->db = $this->new_dbal(); $factory = new \phpbb\db\tools\factory(); $this->db_tools = $factory->get($this->db); $this->phpbb_root_path = dirname(__FILE__) . '/'; $this->phpEx = 'php'; $this->table_prefix = 'phpbb_'; $container = new phpbb_mock_container_builder(); $cache_path = $this->phpbb_root_path . 'cache/twig'; $context = new \phpbb\template\context(); $loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), ''); $filesystem = new \phpbb\filesystem\filesystem(); $phpbb_path_helper = new \phpbb\path_helper(new \phpbb\symfony_request(new phpbb_mock_request()), $filesystem, $this->getMock('\\phpbb\\request\\request'), $this->phpbb_root_path, $this->phpEx); $twig = new \phpbb\template\twig\environment($this->config, $filesystem, $phpbb_path_helper, $cache_path, null, $loader, array('cache' => false, 'debug' => false, 'auto_reload' => true, 'autoescape' => false)); $container = new phpbb_mock_container_builder(); $this->migrator = new \phpbb\db\migrator($container, $this->config, $this->db, $this->db_tools, 'phpbb_migrations', $this->phpbb_root_path, 'php', $this->table_prefix, array(), new \phpbb\db\migration\helper()); $container->set('migrator', $this->migrator); $this->extension_manager = new \phpbb\extension\manager($container, $this->db, $this->config, new \phpbb\filesystem\filesystem(), 'phpbb_ext', $this->phpbb_root_path, $this->phpEx, $this->cache); global $phpbb_root_path; $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $this->phpEx); $lang_loader->set_extension_manager($this->extension_manager); $lang = new \phpbb\language\language($lang_loader); $this->user = new \phpbb\user($lang, '\\phpbb\\datetime'); $this->template = new phpbb\template\twig\twig($phpbb_path_helper, $this->config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user))); $twig->setLexer(new \phpbb\template\twig\lexer($twig)); }
protected function generate_route_objects() { global $request; $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); $request = $this->request; $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, $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))); $twig->setLexer(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/'))); $loader = new \Symfony\Component\Routing\Loader\YamlFileLoader(new \phpbb\routing\file_locator($this->filesystem, dirname(__FILE__) . '/')); $resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $this->extension_manager); $this->router = new phpbb_mock_router($container, $resources_locator, $loader, dirname(__FILE__) . '/', 'php'); // Set correct current phpBB root path $this->root_path = $this->get_phpbb_root_path(); }
protected function setup_engine(array $new_config = array()) { global $phpbb_root_path, $phpEx, $user; $defaults = $this->config_defaults(); $config = new \phpbb\config\config(array_merge($defaults, $new_config)); $filesystem = new \phpbb\filesystem\filesystem(); $this->phpbb_path_helper = new \phpbb\path_helper(new \phpbb\symfony_request(new phpbb_mock_request()), $filesystem, $this->getMock('\\phpbb\\request\\request'), $phpbb_root_path, $phpEx); $this->template_path = $this->test_path . '/templates'; $this->parent_template_path = $this->test_path . '/parent_templates'; $container = new phpbb_mock_container_builder(); $cache_path = $phpbb_root_path . 'cache/twig'; $context = new \phpbb\template\context(); $loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), ''); $twig = new \phpbb\template\twig\environment($config, $filesystem, $this->phpbb_path_helper, $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, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user))); $twig->setLexer(new \phpbb\template\twig\lexer($twig)); $this->template->set_custom_style('tests', array($this->template_path, $this->parent_template_path)); }
protected function setup_engine_for_events($dataset, $style_names, array $new_config = array()) { global $phpbb_root_path, $phpEx, $user; $defaults = $this->config_defaults(); $config = new \phpbb\config\config(array_merge($defaults, $new_config)); $this->template_path = dirname(__FILE__) . "/datasets/{$dataset}/styles/silver/template"; $this->extension_manager = new phpbb_mock_filesystem_extension_manager(dirname(__FILE__) . "/datasets/{$dataset}/"); $filesystem = new \phpbb\filesystem\filesystem(); $path_helper = new \phpbb\path_helper(new \phpbb\symfony_request(new phpbb_mock_request()), new \phpbb\filesystem\filesystem(), $this->getMock('\\phpbb\\request\\request'), $phpbb_root_path, $phpEx); $container = new phpbb_mock_container_builder(); $cache_path = $phpbb_root_path . 'cache/twig'; $context = new \phpbb\template\context(); $loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), ''); $twig = new \phpbb\template\twig\environment($config, $filesystem, $path_helper, $cache_path, $this->extension_manager, $loader, array('cache' => false, 'debug' => false, 'auto_reload' => true, 'autoescape' => false)); $this->template = new \phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user)), $this->extension_manager); $twig->setLexer(new \phpbb\template\twig\lexer($twig)); $this->template->set_custom_style(!empty($style_names) ? $style_names : 'silver', array($this->template_path)); }
protected function setup_engine_for_allfolder(array $new_config = array()) { global $phpbb_root_path, $phpEx; $defaults = $this->config_defaults(); $config = new \phpbb\config\config(array_merge($defaults, $new_config)); $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'); $this->user = $user; $filesystem = new \phpbb\filesystem\filesystem(); $path_helper = new \phpbb\path_helper(new \phpbb\symfony_request(new phpbb_mock_request()), $filesystem, $this->getMock('\\phpbb\\request\\request'), $phpbb_root_path, $phpEx); $this->extension_manager = new phpbb_mock_extension_manager(dirname(__FILE__) . '/', array('vendor4/bar' => array('ext_name' => 'vendor4/bar', 'ext_active' => '1', 'ext_path' => 'ext/vendor4/bar/'))); $container = new phpbb_mock_container_builder(); $cache_path = $phpbb_root_path . 'cache/twig'; $context = new \phpbb\template\context(); $loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), ''); $twig = new \phpbb\template\twig\environment($config, $filesystem, $path_helper, $cache_path, $this->extension_manager, $loader, array('cache' => false, 'debug' => false, 'auto_reload' => true, 'autoescape' => false)); $this->template = new \phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user)), $this->extension_manager); $twig->setLexer(new \phpbb\template\twig\lexer($twig)); $this->template_path = $this->test_path . '/templates'; $this->ext_template_path = 'tests/extension/ext/vendor4/bar/styles/all/template'; $this->template->set_custom_style('all', array($this->template_path, $this->ext_template_path)); }
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); }
/** * Setup template engine */ protected function setup_template() { global $phpbb_container; if ($this->template instanceof \phpbb\template\template) { return; } $template_environment = new \phpbb\template\twig\environment($phpbb_container->get('config'), $phpbb_container->get('filesystem'), $phpbb_container->get('path_helper'), $phpbb_container->getParameter('core.template.cache_path'), $phpbb_container->get('ext.manager'), new \phpbb\template\twig\loader($phpbb_container->get('filesystem'))); $template_environment->setLexer($phpbb_container->get('template.twig.lexer')); $this->template = new \phpbb\template\twig\twig($phpbb_container->get('path_helper'), $phpbb_container->get('config'), new \phpbb\template\context(), $template_environment, $phpbb_container->getParameter('core.template.cache_path'), $phpbb_container->get('user'), $phpbb_container->get('template.twig.extensions.collection'), $phpbb_container->get('ext.manager')); }