Inheritance: implements Symfony\Component\DependencyInjection\ContainerInterface
Beispiel #1
0
 public function setUp()
 {
     $container = new phpbb_mock_container_builder();
     $migrator = new phpbb_mock_migrator();
     $container->set('migrator', $migrator);
     $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/'), 'vendor3/bar' => array('ext_name' => 'vendor3/bar', 'ext_active' => '1', 'ext_path' => 'ext/vendor3/bar/'), 'vendor2/bar' => array('ext_name' => 'vendor2/bar', 'ext_active' => '1', 'ext_path' => 'ext/vendor2/bar/')), $container);
 }
Beispiel #2
0
 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));
 }
 public function test_censor_is_restored()
 {
     global $phpbb_container;
     $phpbb_container = new phpbb_mock_container_builder();
     global $phpbb_root_path, $phpEx;
     $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');
     $user->optionset('viewcensors', false);
     $config = new \phpbb\config\config(array('allow_nocensors' => true));
     $auth = $this->getMock('phpbb\\auth\\auth');
     $auth->expects($this->any())->method('acl_get')->with('u_chgcensors')->will($this->returnValue(true));
     $phpbb_container->set('user', $user);
     $phpbb_container->set('config', $config);
     $phpbb_container->set('auth', $auth);
     $this->get_test_case_helpers()->set_s9e_services($phpbb_container);
     $renderer = $phpbb_container->get('text_formatter.renderer');
     $original = '<r><CENSOR with="banana">apple</CENSOR></r>';
     $renderer->set_viewcensors(false);
     $this->assertSame('apple', $renderer->render($original));
     $renderer->set_viewcensors(true);
     $this->assertSame('banana', $renderer->render($original));
     $this->assertSame('apple', generate_text_for_display($original, '', '', 0, false));
     $this->assertSame('banana', $renderer->render($original), 'The original setting was not restored');
     $renderer->set_viewcensors(false);
     $this->assertSame('apple', $renderer->render($original));
     $this->assertSame('banana', generate_text_for_display($original, '', '', 0, truee));
     $this->assertSame('apple', $renderer->render($original), 'The original setting was not restored');
 }
Beispiel #4
0
 protected function setUp()
 {
     parent::setUp();
     global $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $user, $phpbb_root_path, $phpEx;
     $this->db = $db = $this->new_dbal();
     $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_dispatcher = new phpbb_mock_event_dispatcher();
     $phpbb_container = new phpbb_mock_container_builder();
     $config = new \phpbb\config\config(array('auth_method' => 'oauth', 'auth_oauth_google_key' => 'foo', 'auth_oauth_google_secret' => 'bar'));
     $cache = new \phpbb\cache\driver\dummy();
     $request = new phpbb_mock_request();
     $notification_manager = new phpbb_mock_notification_manager();
     $provider_collection = new \phpbb\auth\provider_collection($phpbb_container, $config);
     $oauth_provider_google = new \phpbb\auth\provider\oauth\service\google($config, $request);
     $oauth_provider_collection = new \phpbb\di\service_collection($phpbb_container);
     $oauth_provider_collection->offsetSet('auth.provider.oauth.service.google', $oauth_provider_google);
     $driver_helper = new \phpbb\passwords\driver\helper($config);
     $passwords_drivers = array('passwords.driver.bcrypt_2y' => new \phpbb\passwords\driver\bcrypt_2y($config, $driver_helper), 'passwords.driver.bcrypt' => new \phpbb\passwords\driver\bcrypt($config, $driver_helper), 'passwords.driver.salted_md5' => new \phpbb\passwords\driver\salted_md5($config, $driver_helper), 'passwords.driver.phpass' => new \phpbb\passwords\driver\phpass($config, $driver_helper));
     $passwords_helper = new \phpbb\passwords\helper();
     // Set up passwords manager
     $passwords_manager = new \phpbb\passwords\manager($config, $passwords_drivers, $passwords_helper, array_keys($passwords_drivers));
     $oauth_provider = new \phpbb\auth\provider\oauth\oauth($db, $config, $passwords_manager, $request, $user, 'phpbb_oauth_tokens', 'phpbb_oauth_accounts', $oauth_provider_collection, 'phpbb_users', $phpbb_container, $this->phpbb_root_path, $this->php_ext);
     $provider_collection->offsetSet('auth.provider.oauth', $oauth_provider);
     $phpbb_container->set('auth.provider.oauth', $oauth_provider);
     $phpbb_container->set('auth.provider.oauth.service.google', $oauth_provider_google);
     $phpbb_container->set('auth.provider_collection', $provider_collection);
     $phpbb_container->set('notification_manager', $notification_manager);
 }
Beispiel #5
0
 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();
     $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($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();
 }
 /**
  * Setup test environment
  */
 public function setUp()
 {
     parent::setUp();
     global $phpbb_dispatcher;
     $this->db = $this->new_dbal();
     $this->phpbb_container = new \phpbb_mock_container_builder();
     $this->config = new \phpbb\config\config(array('notification_pull_time' => 60));
     // TBD
     $auth = $this->getMock('\\phpbb\\auth\\auth');
     $cache = new \phpbb\cache\service(new \phpbb\cache\driver\null(), $this->config, $this->db, $phpbb_root_path, $phpEx);
     $user_loader = new \phpbb\user_loader($this->db, $phpbb_root_path, $phpEx, USERS_TABLE);
     // Event dispatcher
     $phpbb_dispatcher = new \phpbb_mock_event_dispatcher();
     // Notification Types
     $notification_types = array('pm');
     $notification_types_array = array();
     foreach ($notification_types as $type) {
         $class_name = '\\phpbb\\notification\\type\\' . $type;
         $class = new $class_name($user_loader, $this->db, $cache->get_driver(), $user, $auth, $this->config, $phpbb_root_path, $phpEx, NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE);
         $this->phpbb_container->set('notification.type.' . $type, $class);
         $notification_types_array['notification.type.' . $type] = $class;
     }
     // Notification Manager
     $this->phpbb_notifications = new \phpbb\notification\manager($notification_types_array, array(), $this->phpbb_container, $user_loader, $this->config, $phpbb_dispatcher, $this->db, $cache, $user, $phpbb_root_path, $phpEx, NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE);
     $user = new \phpbb_mock_user();
     $user->optionset('viewcensors', false);
     $user->style['style_path'] = 'prosilver';
     $this->user = $this->getMock('\\phpbb\\user', array(), array('\\phpbb\\datetime'));
     $this->template = $this->getMockBuilder('\\phpbb\\template\\template')->getMock();
     $phpbb_container = new \phpbb_mock_container_builder();
     $phpbb_container->set('path_helper', $phpbb_path_helper);
     $this->controller_helper = $this->getMockBuilder('\\phpbb\\controller\\helper')->disableOriginalConstructor()->getMock();
     $this->request = $this->getMock('\\phpbb\\request\\request');
 }
Beispiel #7
0
 public function test_run()
 {
     $this->module->run();
     $task = $this->container->get('task_one');
     $this->assertTrue($task->was_task_runned());
     $task = $this->container->get('task_two');
     $this->assertTrue($task->was_task_runned());
 }
 public function setUp()
 {
     parent::setUp();
     global $phpbb_container;
     $phpbb_container = new phpbb_mock_container_builder();
     $phpbb_container->set('auth.provider_collection', array('auth.provider.acp_board_valid' => new phpbb\auth\provider\acp\board_valid(), 'auth.provider.acp_board_invalid' => new phpbb\auth\provider\acp\board_invalid()));
     $this->acp_board = new acp_board();
 }
Beispiel #9
0
 protected function setUp()
 {
     global $user, $phpbb_dispatcher, $phpbb_container, $phpbb_root_path, $phpbb_path_helper;
     parent::setUp();
     $phpbb_container = new phpbb_mock_container_builder();
     $user = new phpbb_mock_user();
     $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
     $phpbb_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, 'php');
     $phpbb_container->set('path_helper', $phpbb_path_helper);
 }
 public function setUp()
 {
     $container = new phpbb_mock_container_builder();
     $container->set('foo', new StdClass());
     $container->set('bar', new StdClass());
     $this->service_collection = new \phpbb\di\service_collection($container);
     $this->service_collection->add('foo');
     $this->service_collection->add('bar');
     parent::setUp();
 }
Beispiel #11
0
 protected function setUp()
 {
     parent::setUp();
     global $cache, $config, $db, $phpbb_dispatcher, $phpbb_container;
     $db = $this->db = $this->new_dbal();
     $config = new \phpbb\config\config(array('load_online_time' => 5, 'search_type' => '\\phpbb\\search\\fulltext_mysql'));
     $cache = new phpbb_mock_null_cache();
     $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
     $phpbb_container = new phpbb_mock_container_builder();
     $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager());
 }
 public function setUp()
 {
     global $config, $phpbb_container, $phpbb_dispatcher;
     parent::setUp();
     $config = new \phpbb\config\config(array());
     set_config(null, null, null, $config);
     $phpbb_container = new phpbb_mock_container_builder();
     $phpbb_container->set('config', $config);
     $this->get_test_case_helpers()->set_s9e_services($phpbb_container);
     $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
 }
Beispiel #13
0
 public function setUp()
 {
     global $db, $request, $phpbb_container;
     $db = $this->new_dbal();
     parent::setUp();
     $request = new \phpbb_mock_request();
     $phpbb_container = new \phpbb_mock_container_builder();
     $factory = new \phpbb\db\tools\factory();
     $phpbb_container->set('dbal.tools', $factory->get($db));
     $this->qa = new \phpbb\captcha\plugins\qa('phpbb_captcha_questions', 'phpbb_captcha_answers', 'phpbb_qa_confirm');
 }
Beispiel #14
0
 public function setUp()
 {
     parent::setUp();
     $this->db = $this->new_dbal();
     $factory = new \phpbb\db\tools\factory();
     $this->db_tools = $factory->get($this->db);
     $this->config = new \phpbb\config\db($this->db, new phpbb_mock_cache(), 'phpbb_config');
     $tools = array(new \phpbb\db\migration\tool\config($this->config));
     $container = new phpbb_mock_container_builder();
     $this->migrator = new \phpbb\db\migrator($container, $this->config, $this->db, $this->db_tools, 'phpbb_migrations', dirname(__FILE__) . '/../../phpBB/', 'php', 'phpbb_', $tools, new \phpbb\db\migration\helper());
     $container->set('migrator', $this->migrator);
     $container->set('dispatcher', new phpbb_mock_event_dispatcher());
     $this->extension_manager = new \phpbb\extension\manager($container, $this->db, $this->config, new phpbb\filesystem\filesystem(), 'phpbb_ext', dirname(__FILE__) . '/../../phpBB/', 'php', null);
 }
 public function test_navigation()
 {
     // Mock nav interface
     $nav_stub = $this->getMockBuilder('\\phpbb\\install\\helper\\navigation\\navigation_interface')->getMock();
     $nav_stub->method('get')->willReturn(array('foo' => 'bar'));
     // Set up dependencies
     $container = new phpbb_mock_container_builder();
     $container->set('foo', $nav_stub);
     $nav_collection = new \phpbb\di\service_collection($container);
     $nav_collection->add('foo');
     // Let's test
     $nav_provider = new \phpbb\install\helper\navigation\navigation_provider($nav_collection);
     $this->assertEquals(array('foo' => 'bar'), $nav_provider->get());
 }
Beispiel #16
0
    /**
     * @dataProvider delete_user_pms_data
     */
    public function test_delete_user_pms($delete_user, $remaining_privmsgs, $remaining_privmsgs_to)
    {
        global $db, $phpbb_container;
        $db = $this->new_dbal();
        $phpbb_container = new phpbb_mock_container_builder();
        $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager());
        phpbb_delete_user_pms($delete_user);
        $sql = 'SELECT msg_id
			FROM ' . PRIVMSGS_TABLE;
        $result = $db->sql_query($sql);
        $this->assertEquals($remaining_privmsgs, $db->sql_fetchrowset($result));
        $sql = 'SELECT msg_id, user_id
			FROM ' . PRIVMSGS_TO_TABLE;
        $result = $db->sql_query($sql);
        $this->assertEquals($remaining_privmsgs_to, $db->sql_fetchrowset($result));
    }
Beispiel #17
0
 protected function setUp()
 {
     parent::setUp();
     global $cache, $config, $db, $phpbb_dispatcher, $phpbb_container, $phpbb_root_path;
     $db = $this->db = $this->new_dbal();
     $config = new \phpbb\config\config(array('load_online_time' => 5, 'search_type' => '\\phpbb\\search\\fulltext_mysql'));
     $cache = new phpbb_mock_null_cache();
     $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
     $phpbb_container = new phpbb_mock_container_builder();
     $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager());
     // Works as a workaround for tests
     $phpbb_container->set('attachment.manager', new \phpbb\attachment\delete($config, $db, new \phpbb_mock_event_dispatcher(), new \phpbb\filesystem\filesystem(), new \phpbb\attachment\resync($db), $phpbb_root_path));
     $phpbb_container->set('auth.provider.db', new phpbb_mock_auth_provider());
     $provider_collection = new \phpbb\auth\provider_collection($phpbb_container, $config);
     $provider_collection->add('auth.provider.db');
     $phpbb_container->set('auth.provider_collection', $provider_collection);
 }
Beispiel #18
0
 public function get_command_tester($current_version)
 {
     global $user, $phpbb_root_path, $phpEx;
     $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
     $user = $this->getMock('\\phpbb\\user', array(), array($this->language, '\\phpbb\\datetime'));
     $user->method('lang')->will($this->returnArgument(0));
     $cache = $this->getMockBuilder('\\phpbb\\cache\\service')->disableOriginalConstructor()->getMock();
     $config = new \phpbb\config\config(array('version' => $current_version));
     $this->version_helper = new \phpbb\version_helper($cache, $config, new \phpbb\file_downloader());
     $container = new phpbb_mock_container_builder();
     $container->set('version_helper', $this->version_helper);
     $application = new Application();
     $application->add(new check($user, $config, $container, $this->language));
     $command = $application->find('update:check');
     $this->command_name = $command->getName();
     return new CommandTester($command);
 }
Beispiel #19
0
 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();
     $this->db_tools = new \phpbb\db\tools($this->db);
     $this->phpbb_root_path = dirname(__FILE__) . '/';
     $this->phpEx = 'php';
     $this->user = new \phpbb\user('\\phpbb\\datetime');
     $this->table_prefix = 'phpbb_';
     $this->template = new \phpbb\template\twig\twig(new \phpbb\path_helper(new \phpbb\symfony_request(new phpbb_mock_request()), new \phpbb\filesystem(), $this->getMock('\\phpbb\\request\\request'), $this->phpbb_root_path, $this->phpEx), $this->config, $this->user, new \phpbb\template\context());
     $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(), $this->user, 'phpbb_ext', $this->phpbb_root_path, $this->phpEx, $this->cache);
 }
Beispiel #20
0
 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, $container, $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);
     $container->set('template.twig.lexer', 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(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, $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, $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->template->set_custom_style('tests', array($this->template_path, $this->parent_template_path));
 }
Beispiel #22
0
    /**
     * @dataProvider delete_user_pms_data
     */
    public function test_delete_user_pms($delete_user, $remaining_privmsgs, $remaining_privmsgs_to)
    {
        global $db, $phpbb_container, $phpbb_root_path;
        $db = $this->new_dbal();
        $phpbb_container = new phpbb_mock_container_builder();
        $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager());
        // Works as a workaround for tests
        $phpbb_container->set('attachment.manager', new \phpbb\attachment\delete(new \phpbb\config\config(array()), $db, new \phpbb_mock_event_dispatcher(), new \phpbb\filesystem\filesystem(), new \phpbb\attachment\resync($db), $phpbb_root_path));
        phpbb_delete_user_pms($delete_user);
        $sql = 'SELECT msg_id
			FROM ' . PRIVMSGS_TABLE;
        $result = $db->sql_query($sql);
        $this->assertEquals($remaining_privmsgs, $db->sql_fetchrowset($result));
        $sql = 'SELECT msg_id, user_id
			FROM ' . PRIVMSGS_TO_TABLE;
        $result = $db->sql_query($sql);
        $this->assertEquals($remaining_privmsgs_to, $db->sql_fetchrowset($result));
    }
Beispiel #23
0
 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'));
 }
Beispiel #24
0
 protected function prepare_s9e_services($setup = null)
 {
     global $config, $phpbb_container, $user;
     $config = new \phpbb\config\config(array('max_poll_options' => 999));
     $map = array(array('MAX_FLASH_HEIGHT_EXCEEDED', 123, 'Your flash files may only be up to 123 pixels high.'), array('MAX_FLASH_WIDTH_EXCEEDED', 456, 'Your flash files may only be up to 456 pixels wide.'), array('MAX_FONT_SIZE_EXCEEDED', 120, 'You may only use fonts up to size 120.'), array('MAX_FONT_SIZE_EXCEEDED', 200, 'You may only use fonts up to size 200.'), array('MAX_IMG_HEIGHT_EXCEEDED', 12, 'Your images may only be up to 12 pixels high.'), array('MAX_IMG_WIDTH_EXCEEDED', 34, 'Your images may only be up to 34 pixels wide.'), array('TOO_MANY_SMILIES', 3, 'Your message contains too many smilies. The maximum number of smilies allowed is 3.'), array('TOO_MANY_URLS', 2, 'Your message contains too many URLs. The maximum number of URLs allowed is 2.'), array('UNAUTHORISED_BBCODE', '[flash]', 'You cannot use certain BBCodes: [flash].'), array('UNAUTHORISED_BBCODE', '[img]', 'You cannot use certain BBCodes: [img].'), array('UNAUTHORISED_BBCODE', '[quote]', 'You cannot use certain BBCodes: [quote].'), array('UNAUTHORISED_BBCODE', '[url]', 'You cannot use certain BBCodes: [url].'), array('UNABLE_GET_IMAGE_SIZE', 'It was not possible to determine the dimensions of the image.'));
     $user = $this->getMockBuilder('phpbb\\user')->disableOriginalConstructor()->getMock();
     $user->expects($this->any())->method('lang')->will($this->returnValueMap($map));
     $user->data = array('is_bot' => false, 'is_registered' => true, 'user_id' => 2);
     $user->style = array('style_id' => 1);
     $user->lang = array('NO_POLL_TITLE' => 'You have to enter a poll title.', 'POLL_TITLE_TOO_LONG' => 'The poll title must contain fewer than 100 characters.', 'POLL_TITLE_COMP_TOO_LONG' => 'The parsed size of your poll title is too large, consider removing BBCodes or smilies.', 'TOO_FEW_POLL_OPTIONS' => 'You must enter at least two poll options.', 'TOO_MANY_POLL_OPTIONS' => 'You have tried to enter too many poll options.', 'TOO_MANY_USER_OPTIONS' => 'You cannot specify more options per user than existing poll options.');
     $phpbb_container = new phpbb_mock_container_builder();
     $phpbb_container->set('user', $user);
     $phpbb_container->set('config', $config);
     if (isset($setup)) {
         $setup($phpbb_container, $this);
     }
     $this->get_test_case_helpers()->set_s9e_services($phpbb_container);
 }
Beispiel #25
0
    /**
     * @dataProvider delete_post_data
     */
    public function test_delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $reason, $expected_posts, $expected_topic, $expected_forum, $expected_user)
    {
        global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $phpbb_root_path, $phpEx;
        $config = new \phpbb\config\config(array('num_posts' => 3, 'num_topics' => 1, 'search_type' => 'phpbb_mock_search'));
        $cache = new phpbb_mock_cache();
        $db = $this->new_dbal();
        $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
        // Create auth mock
        $auth = $this->getMock('\\phpbb\\auth\\auth');
        $auth->expects($this->any())->method('acl_get')->with($this->stringContains('_'), $this->anything())->will($this->returnValueMap(array(array('m_approve', 1, true))));
        $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');
        $attachment_delete = new \phpbb\attachment\delete($config, $db, new \phpbb_mock_event_dispatcher(), new \phpbb\filesystem\filesystem(), new \phpbb\attachment\resync($db), $phpbb_root_path);
        $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
        $phpbb_container = new phpbb_mock_container_builder();
        $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager());
        $phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE));
        // Works as a workaround for tests
        $phpbb_container->set('attachment.manager', $attachment_delete);
        delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $reason);
        $result = $db->sql_query('SELECT post_id, post_visibility, post_delete_reason
			FROM phpbb_posts
			WHERE topic_id = ' . $topic_id . '
			ORDER BY post_id ASC');
        $this->assertEquals($expected_posts, $db->sql_fetchrowset($result));
        $db->sql_freeresult($result);
        $result = $db->sql_query('SELECT topic_visibility, topic_first_post_id, topic_last_post_id, topic_posts_approved, topic_posts_unapproved, topic_posts_softdeleted, topic_delete_reason
			FROM phpbb_topics
			WHERE topic_id = ' . $topic_id);
        $this->assertEquals($expected_topic, $db->sql_fetchrowset($result));
        $db->sql_freeresult($result);
        $result = $db->sql_query('SELECT forum_posts_approved, forum_posts_unapproved, forum_posts_softdeleted, forum_topics_approved, forum_topics_unapproved, forum_topics_softdeleted, forum_last_post_id
			FROM phpbb_forums
			WHERE forum_id = ' . $forum_id);
        $this->assertEquals($expected_forum, $db->sql_fetchrowset($result));
        $db->sql_freeresult($result);
        $sql = 'SELECT user_posts
			FROM ' . USERS_TABLE . '
			WHERE user_id = ' . (int) $data['poster_id'];
        $result = $db->sql_query($sql);
        $this->assertEquals($expected_user, $db->sql_fetchrowset($result));
        $db->sql_freeresult($result);
    }
Beispiel #26
0
 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'));
 }
Beispiel #27
0
 public function setUp()
 {
     parent::setUp();
     global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $user, $request, $phpEx, $phpbb_root_path;
     // Database
     $this->db = $this->new_dbal();
     $db = $this->db;
     // Auth
     $auth = $this->getMock('\\phpbb\\auth\\auth');
     $auth->expects($this->any())->method('acl_get')->with($this->stringContains('_'), $this->anything())->will($this->returnValueMap(array(array('f_noapprove', 1, true), array('f_postcount', 1, true), array('m_edit', 1, false))));
     // Config
     $config = new \phpbb\config\config(array('num_topics' => 1, 'num_posts' => 1));
     $cache = new \phpbb\cache\service(new \phpbb\cache\driver\dummy(), $config, $db, $phpbb_root_path, $phpEx);
     // Event dispatcher
     $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
     // User
     $user = $this->getMock('\\phpbb\\user', array(), array(new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), '\\phpbb\\datetime'));
     $user->ip = '';
     $user->data = array('user_id' => 2, 'username' => 'user-name', 'is_registered' => true, 'user_colour' => '');
     // Request
     $type_cast_helper = $this->getMock('\\phpbb\\request\\type_cast_helper_interface');
     $request = $this->getMock('\\phpbb\\request\\request');
     // Container
     $phpbb_container = new phpbb_mock_container_builder();
     $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
     $phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE));
     $user_loader = new \phpbb\user_loader($db, $phpbb_root_path, $phpEx, USERS_TABLE);
     // Notification Types
     $notification_types = array('quote', 'bookmark', 'post', 'post_in_queue', 'topic', 'topic_in_queue', 'approve_topic', 'approve_post');
     $notification_types_array = array();
     foreach ($notification_types as $type) {
         $class_name = '\\phpbb\\notification\\type\\' . $type;
         $class = new $class_name($user_loader, $db, $cache->get_driver(), $user, $auth, $config, $phpbb_root_path, $phpEx, NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE);
         if ($type === 'quote') {
             $class->set_utils(new \phpbb\textformatter\s9e\utils());
         }
         $phpbb_container->set('notification.type.' . $type, $class);
         $notification_types_array['notification.type.' . $type] = $class;
     }
     // Notification Manager
     $phpbb_notifications = new \phpbb\notification\manager($notification_types_array, array(), $phpbb_container, $user_loader, $config, $phpbb_dispatcher, $db, $cache, $user, $phpbb_root_path, $phpEx, NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE);
     $phpbb_container->set('notification_manager', $phpbb_notifications);
 }
Beispiel #28
0
 public function test_version_phpbb_com()
 {
     global $phpbb_container;
     $phpbb_container = new phpbb_mock_container_builder();
     $phpbb_container->set('file_downloader', new \phpbb\file_downloader());
     $hostname = 'version.phpbb.com';
     if (!phpbb_checkdnsrr($hostname, 'A')) {
         $this->markTestSkipped(sprintf('Could not find a DNS record for hostname %s. ' . 'Assuming network is down.', $hostname));
     }
     $errstr = $errno = null;
     $file = get_remote_file($hostname, '/phpbb', '30x.txt', $errstr, $errno);
     $this->assertNotEquals(0, strlen($file), 'Failed asserting that the response is not empty.');
     $this->assertSame('', $errstr, 'Failed asserting that the error string is empty.');
     $this->assertSame(0, $errno, 'Failed asserting that the error number is 0 (i.e. no error occurred).');
     $lines = explode("\n", $file);
     $this->assertGreaterThanOrEqual(2, sizeof($lines), 'Failed asserting that the version file has at least two lines.');
     $this->assertStringStartsWith('3.', $lines[0], "Failed asserting that the first line of the version file starts with '3.'");
     $this->assertNotSame(false, filter_var($lines[1], FILTER_VALIDATE_URL), 'Failed asserting that the second line of the version file is a valid URL.');
     $this->assertContains('http', $lines[1]);
     $this->assertContains('phpbb.com', $lines[1], '', true);
 }
 /**
  * @dataProvider handle_data
  */
 public function test_post_check($username, $message, $should_pass)
 {
     $phpbb_container = new \phpbb_mock_container_builder();
     $mock_akismet = new \gothick\akismet\tests\mock\akismet();
     $phpbb_container->set('gothick.akismet.tijsverkoyen.akismet', $mock_akismet);
     $request = $this->getMock('\\phpbb\\request\\request');
     // Make sure we enable, (and, more importantly, disable!) super globals around
     // the use of the vendor Akismet library.
     $request->expects($this->at(0))->method('enable_super_globals')->with();
     $request->expects($this->at(1))->method('disable_super_globals')->with();
     $listener = new \gothick\akismet\event\main_listener(new \gothick\akismet\tests\mock\user($username), $request, new \phpbb\config\config(array('gothick_akismet_user_id' => 1)), new \phpbb\log\null(), $this->getMock('\\phpbb\\auth\\auth'), $phpbb_container, '.php', './');
     $data = array('data' => array('message' => $message, 'topic_id' => 123));
     $event = new \phpbb\event\data($data);
     $listener->check_submitted_post($event);
     if ($should_pass) {
         $this->assertFalse(isset($event['data']['force_approved_state']));
     } else {
         $this->assertTrue(isset($event['data']['force_approved_state']));
         $this->assertEquals($event['data']['force_approved_state'], ITEM_UNAPPROVED);
     }
 }
Beispiel #30
0
 public function setUp()
 {
     global $auth, $db, $cache, $config, $user, $phpbb_dispatcher, $phpbb_container, $phpbb_root_path, $phpEx;
     $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
     $phpbb_container = new phpbb_mock_container_builder();
     $phpbb_container->set('cache.driver', new phpbb_mock_cache());
     $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager());
     $auth = $this->getMock('\\phpbb\\auth\\auth');
     $cache = $phpbb_container->get('cache.driver');
     $config = $this->config = new \phpbb\config\config(array('board_timezone' => 'UTC', 'default_lang' => 'en', 'email_enable' => false, 'min_name_chars' => 3, 'max_name_chars' => 10, 'min_pass_chars' => 3, 'max_pass_chars' => 10, 'pass_complex' => 'PASS_TYPE_ANY'));
     $db = $this->db = $this->new_dbal();
     $this->language = $this->getMockBuilder('\\phpbb\\language\\language')->disableOriginalConstructor()->getMock();
     $this->language->expects($this->any())->method('lang')->will($this->returnArgument(0));
     $user = $this->user = $this->getMock('\\phpbb\\user', array(), array($this->language, '\\phpbb\\datetime'));
     $this->user_loader = new \phpbb\user_loader($db, $phpbb_root_path, $phpEx, USERS_TABLE);
     $driver_helper = new \phpbb\passwords\driver\helper($this->config);
     $passwords_drivers = array('passwords.driver.bcrypt_2y' => new \phpbb\passwords\driver\bcrypt_2y($this->config, $driver_helper), 'passwords.driver.bcrypt' => new \phpbb\passwords\driver\bcrypt($this->config, $driver_helper), 'passwords.driver.salted_md5' => new \phpbb\passwords\driver\salted_md5($this->config, $driver_helper), 'passwords.driver.phpass' => new \phpbb\passwords\driver\phpass($this->config, $driver_helper));
     $passwords_helper = new \phpbb\passwords\helper();
     $this->passwords_manager = new \phpbb\passwords\manager($this->config, $passwords_drivers, $passwords_helper, array_keys($passwords_drivers));
     $this->phpbb_root_path = $phpbb_root_path;
     $this->php_ext = $phpEx;
     $this->log = $this->getMockBuilder('\\phpbb\\log\\log')->disableOriginalConstructor()->getMock();
     $phpbb_container->set('auth.provider.db', new phpbb_mock_auth_provider());
     $provider_collection = new \phpbb\auth\provider_collection($phpbb_container, $config);
     $provider_collection->add('auth.provider.db');
     $phpbb_container->set('auth.provider_collection', $provider_collection);
     parent::setUp();
 }