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); }
public function setUp() { parent::setUp(); $this->session = $this->session_factory->get_session($this->db); global $phpbb_container; $plugins = new \phpbb\di\service_collection($phpbb_container); $plugins->add('core.captcha.plugins.nogd'); $phpbb_container->set('captcha.factory', new \phpbb\captcha\factory($phpbb_container, $plugins)); $phpbb_container->set('core.captcha.plugins.nogd', new \phpbb\captcha\plugins\nogd()); }
public function setUp() { parent::setUp(); $this->config = new \phpbb\config\config(array('test_reparser_cron_interval' => 0, 'my_reparser_cron_interval' => 100)); $db = $this->new_dbal(); $this->config_text = new \phpbb\config\db_text($db, 'phpbb_config_text'); $service_collection = new \phpbb\di\service_collection(new phpbb_mock_container_builder()); $service_collection->add('test_reparser'); $service_collection->add('another_reparser'); $service_collection->add('my_reparser'); $this->reparser_manager = new \phpbb\textreparser\manager($this->config, $this->config_text, $service_collection); }
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()); }
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); }
/** * Gets the 'profilefields.type_collection' service. * * This service is shared. * This method always returns the same instance of the service. * * @return \phpbb\di\service_collection A phpbb\di\service_collection instance. */ protected function getProfilefields_TypeCollectionService() { $this->services['profilefields.type_collection'] = $instance = new \phpbb\di\service_collection($this); $instance->add('profilefields.type.bool'); $instance->add('profilefields.type.date'); $instance->add('profilefields.type.dropdown'); $instance->add('profilefields.type.googleplus'); $instance->add('profilefields.type.int'); $instance->add('profilefields.type.string'); $instance->add('profilefields.type.text'); $instance->add('profilefields.type.url'); return $instance; }