diff options
Diffstat (limited to 'tests/extension')
| -rw-r--r-- | tests/extension/ext/vendor2/bar/acp/a_info.php | 1 | ||||
| -rw-r--r-- | tests/extension/ext/vendor2/foo/acp/a_info.php | 1 | ||||
| -rw-r--r-- | tests/extension/ext/vendor2/foo/acp/fail_info.php | 1 | ||||
| -rw-r--r-- | tests/extension/ext/vendor2/foo/mcp/a_info.php | 1 | ||||
| -rw-r--r-- | tests/extension/finder_test.php | 4 | ||||
| -rw-r--r-- | tests/extension/includes/acp/info/acp_foobar.php | 1 | ||||
| -rw-r--r-- | tests/extension/manager_test.php | 7 | ||||
| -rw-r--r-- | tests/extension/metadata_manager_test.php | 81 | ||||
| -rw-r--r-- | tests/extension/modules_test.php | 61 | 
9 files changed, 79 insertions, 79 deletions
| diff --git a/tests/extension/ext/vendor2/bar/acp/a_info.php b/tests/extension/ext/vendor2/bar/acp/a_info.php index 8132df587f..8268006f9f 100644 --- a/tests/extension/ext/vendor2/bar/acp/a_info.php +++ b/tests/extension/ext/vendor2/bar/acp/a_info.php @@ -9,7 +9,6 @@ class a_info  		return array(  			'filename'	=> 'vendor2\\bar\\acp\\a_module',  			'title'		=> 'Bar', -			'version'	=> '3.1.0-dev',  			'modes'		=> array(  				'config'		=> array('title' => 'Config',	'auth' => '', 'cat' => array('ACP_MODS')),  			), diff --git a/tests/extension/ext/vendor2/foo/acp/a_info.php b/tests/extension/ext/vendor2/foo/acp/a_info.php index e1eaa340b7..48ab4cf8e7 100644 --- a/tests/extension/ext/vendor2/foo/acp/a_info.php +++ b/tests/extension/ext/vendor2/foo/acp/a_info.php @@ -9,7 +9,6 @@ class a_info  		return array(  			'filename'	=> 'vendor2\\foo\\acp\\a_module',  			'title'		=> 'Foobar', -			'version'	=> '3.1.0-dev',  			'modes'		=> array(  				'config'		=> array('title' => 'Config',	'auth' => 'ext_vendor2/foo', 'cat' => array('ACP_MODS')),  			), diff --git a/tests/extension/ext/vendor2/foo/acp/fail_info.php b/tests/extension/ext/vendor2/foo/acp/fail_info.php index d9b4353957..78479fee70 100644 --- a/tests/extension/ext/vendor2/foo/acp/fail_info.php +++ b/tests/extension/ext/vendor2/foo/acp/fail_info.php @@ -13,7 +13,6 @@ class foo_info  		return array(  			'filename'	=> 'vendor2\foo\acp\fail_module',  			'title'		=> 'Foobar', -			'version'	=> '3.1.0-dev',  			'modes'		=> array(  				'config'		=> array('title' => 'Config',	'auth' => '', 'cat' => array('ACP_MODS')),  			), diff --git a/tests/extension/ext/vendor2/foo/mcp/a_info.php b/tests/extension/ext/vendor2/foo/mcp/a_info.php index b5599fde65..2532e44b12 100644 --- a/tests/extension/ext/vendor2/foo/mcp/a_info.php +++ b/tests/extension/ext/vendor2/foo/mcp/a_info.php @@ -9,7 +9,6 @@ class a_info  		return array(  			'filename'	=> 'vendor2\\foo\\mcp\\a_module',  			'title'		=> 'Foobar', -			'version'	=> '3.1.0-dev',  			'modes'		=> array(  				'config'		=> array('title' => 'Config',	'auth' => '', 'cat' => array('MCP_MAIN')),  			), diff --git a/tests/extension/finder_test.php b/tests/extension/finder_test.php index 2116cc057b..463b69e9a9 100644 --- a/tests/extension/finder_test.php +++ b/tests/extension/finder_test.php @@ -244,7 +244,7 @@ class phpbb_extension_finder_test extends phpbb_test_case  	public function test_get_classes_create_cache()  	{  		$cache = new phpbb_mock_cache; -		$finder = new \phpbb\finder(new \phpbb\filesystem(), dirname(__FILE__) . '/', $cache, 'php', '_custom_cache_name'); +		$finder = new \phpbb\finder(new \phpbb\filesystem\filesystem(), dirname(__FILE__) . '/', $cache, 'php', '_custom_cache_name');  		$finder->set_extensions(array_keys($this->extension_manager->all_enabled()));  		$files = $finder->suffix('_class.php')->get_files(); @@ -284,7 +284,7 @@ class phpbb_extension_finder_test extends phpbb_test_case  		);  		$finder = new \phpbb\finder( -			new \phpbb\filesystem(), +			new \phpbb\filesystem\filesystem(),  			dirname(__FILE__) . '/',  			new phpbb_mock_cache(array(  				'_ext_finder' => array( diff --git a/tests/extension/includes/acp/info/acp_foobar.php b/tests/extension/includes/acp/info/acp_foobar.php index 870225ba4f..8ca1afa1c6 100644 --- a/tests/extension/includes/acp/info/acp_foobar.php +++ b/tests/extension/includes/acp/info/acp_foobar.php @@ -18,7 +18,6 @@ class acp_foobar_info  		return array(  			'filename'	=> 'acp_foobar',  			'title'		=> 'ACP Foobar', -			'version'	=> '3.1.0-dev',  			'modes'		=> array(  				'test'		=> array('title' => 'Test', 'auth' => '', 'cat' => array('ACP_GENERAL')),  			), diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php index 0eeb060936..a24b0cf178 100644 --- a/tests/extension/manager_test.php +++ b/tests/extension/manager_test.php @@ -150,11 +150,11 @@ class phpbb_extension_manager_test extends phpbb_database_test_case  		$config = new \phpbb\config\config(array('version' => PHPBB_VERSION));  		$db = $this->new_dbal(); -		$db_tools = new \phpbb\db\tools($db); +		$factory = new \phpbb\db\tools\factory(); +		$db_tools = $factory->get($db);  		$phpbb_root_path = __DIR__ . './../../phpBB/';  		$php_ext = 'php';  		$table_prefix = 'phpbb_'; -		$user = new \phpbb\user('\phpbb\user');  		$container = new phpbb_mock_container_builder(); @@ -176,8 +176,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case  			$container,  			$db,  			$config, -			new \phpbb\filesystem(), -			$user, +			new \phpbb\filesystem\filesystem(),  			'phpbb_ext',  			dirname(__FILE__) . '/',  			$php_ext, diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php index 2a746d3792..53bd3d109b 100644 --- a/tests/extension/metadata_manager_test.php +++ b/tests/extension/metadata_manager_test.php @@ -41,25 +41,40 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case  			'version'		=> '3.1.0',  		));  		$this->db = $this->new_dbal(); -		$this->db_tools = new \phpbb\db\tools($this->db); +		$factory = new \phpbb\db\tools\factory(); +		$this->db_tools = $factory->get($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 +		$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, -			$this->user, -			new \phpbb\template\context() +			$filesystem, +			$phpbb_path_helper, +			$container, +			$cache_path, +			null, +			$loader, +			array( +				'cache'			=> false, +				'debug'			=> false, +				'auto_reload'	=> true, +				'autoescape'	=> false, +			)  		);  		$container = new phpbb_mock_container_builder(); @@ -82,13 +97,22 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case  			$container,  			$this->db,  			$this->config, -			new \phpbb\filesystem(), -			$this->user, +			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))); +		$container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig));  	}  	// Should fail from missing composer.json @@ -104,7 +128,8 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case  		}  		catch (\phpbb\extension\exception $e)  		{ -			$this->assertEquals((string) $e, $this->user->lang('FILE_NOT_FOUND', $this->phpbb_root_path . $this->extension_manager->get_extension_path($ext_name) . 'composer.json')); +			$message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); +			$this->assertEquals($message, $this->user->lang('FILE_NOT_FOUND', $this->phpbb_root_path . $this->extension_manager->get_extension_path($ext_name) . 'composer.json'));  		}  	} @@ -121,7 +146,8 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case  		}  		catch (\phpbb\extension\exception $e)  		{ -			$this->fail($e); +			$message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); +			$this->fail($message);  		}  		$json = json_decode(file_get_contents($this->phpbb_root_path . 'ext/vendor2/foo/composer.json'), true); @@ -151,9 +177,10 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case  			$manager->validate($field_name);  			$this->fail('Exception not triggered');  		} -		catch(\phpbb\extension\exception $e) +		catch (\phpbb\extension\exception $e)  		{ -			$this->assertEquals((string) $e, $this->user->lang('META_FIELD_NOT_SET', $field_name)); +			$message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); +			$this->assertEquals($message, $this->user->lang('META_FIELD_NOT_SET', $field_name));  		}  	} @@ -167,7 +194,8 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case  		}  		catch (\phpbb\extension\exception $e)  		{ -			$this->assertEquals((string) $e, $this->user->lang('META_FIELD_NOT_SET', 'authors')); +			$message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); +			$this->assertEquals($message, $this->user->lang('META_FIELD_NOT_SET', 'authors'));  		}  		$manager->merge_metadata(array( @@ -183,7 +211,8 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case  		}  		catch (\phpbb\extension\exception $e)  		{ -			$this->assertEquals((string) $e, $this->user->lang('META_FIELD_NOT_SET', 'author name')); +			$message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); +			$this->assertEquals($message, $this->user->lang('META_FIELD_NOT_SET', 'author name'));  		}  	} @@ -214,9 +243,10 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case  			$manager->validate($field_name);  			$this->fail('Exception not triggered');  		} -		catch(\phpbb\extension\exception $e) +		catch (\phpbb\extension\exception $e)  		{ -			$this->assertEquals((string) $e, $this->user->lang('META_FIELD_INVALID', $field_name)); +			$message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); +			$this->assertEquals($message, $this->user->lang('META_FIELD_INVALID', $field_name));  		}  	} @@ -238,9 +268,9 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case  		{  			$this->assertEquals(true, $manager->validate('enable'));  		} -		catch(\phpbb\extension\exception $e) +		catch (\phpbb\extension\exception $e)  		{ -			$this->fail($e); +			$message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters()));  		}  	} @@ -336,7 +366,6 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case  			$this->config,  			$this->extension_manager,  			$this->template, -			$this->user,  			$this->phpbb_root_path  		);  	} diff --git a/tests/extension/modules_test.php b/tests/extension/modules_test.php index 21f1c6aca5..88634bc6ba 100644 --- a/tests/extension/modules_test.php +++ b/tests/extension/modules_test.php @@ -22,6 +22,7 @@ class phpbb_extension_modules_test extends phpbb_test_case  {  	protected $extension_manager;  	protected $finder; +	protected $module_manager;  	public function setUp()  	{ @@ -43,7 +44,14 @@ class phpbb_extension_modules_test extends phpbb_test_case  			));  		$phpbb_extension_manager = $this->extension_manager; -		$this->acp_modules = new acp_modules(); +		$this->module_manager = new \phpbb\module\module_manager( +			new \phpbb\cache\driver\dummy(), +			$this->getMock('\phpbb\db\driver\driver_interface'), +			$this->extension_manager, +			MODULES_TABLE, +			dirname(__FILE__) . '/', +			'php' +		);  	}  	public function test_get_module_infos() @@ -56,13 +64,11 @@ class phpbb_extension_modules_test extends phpbb_test_case  		$phpbb_root_path = dirname(__FILE__) . '/';  		// Find acp module info files -		$this->acp_modules->module_class = 'acp'; -		$acp_modules = $this->acp_modules->get_module_infos(); +		$acp_modules = $this->module_manager->get_module_infos('acp');  		$this->assertEquals(array(  				'vendor2\\foo\\acp\\a_module' => array(  					'filename'	=> 'vendor2\\foo\\acp\\a_module',  					'title'		=> 'Foobar', -					'version'	=> '3.1.0-dev',  					'modes'		=> array(  						'config'		=> array('title' => 'Config',	'auth' => 'ext_vendor2/foo', 'cat' => array('ACP_MODS')),  					), @@ -70,7 +76,6 @@ class phpbb_extension_modules_test extends phpbb_test_case  				'acp_foobar' => array(  					'filename'	=> 'acp_foobar',  					'title'		=> 'ACP Foobar', -					'version'	=> '3.1.0-dev',  					'modes'		=> array(  						'test'		=> array('title' => 'Test', 'auth' => '', 'cat' => array('ACP_GENERAL')),  					), @@ -78,13 +83,11 @@ class phpbb_extension_modules_test extends phpbb_test_case  			), $acp_modules);  		// Find mcp module info files -		$this->acp_modules->module_class = 'mcp'; -		$acp_modules = $this->acp_modules->get_module_infos(); +		$acp_modules = $this->module_manager->get_module_infos('mcp');  		$this->assertEquals(array(  				'vendor2\\foo\\mcp\\a_module' => array(  					'filename'	=> 'vendor2\\foo\\mcp\\a_module',  					'title'		=> 'Foobar', -					'version'	=> '3.1.0-dev',  					'modes'		=> array(  						'config'		=> array('title' => 'Config',	'auth' => '', 'cat' => array('MCP_MAIN')),  					), @@ -92,27 +95,11 @@ class phpbb_extension_modules_test extends phpbb_test_case  			), $acp_modules);  		// Find a specific module info file (mcp_a_module) -		$this->acp_modules->module_class = 'mcp'; -		$acp_modules = $this->acp_modules->get_module_infos('mcp_a_module'); -		$this->assertEquals(array( -				'vendor2\\foo\\mcp\\a_module' => array( -					'filename'	=> 'vendor2\\foo\\mcp\\a_module', -					'title'		=> 'Foobar', -					'version'	=> '3.1.0-dev', -					'modes'		=> array( -						'config'		=> array('title' => 'Config',	'auth' => '', 'cat' => array('MCP_MAIN')), -					), -				), -			), $acp_modules); - -		// Find a specific module info file (mcp_a_module) with passing the module_class -		$this->acp_modules->module_class = ''; -		$acp_modules = $this->acp_modules->get_module_infos('mcp_a_module', 'mcp'); +		$acp_modules = $this->module_manager->get_module_infos('mcp', 'mcp_a_module');  		$this->assertEquals(array(  				'vendor2\\foo\\mcp\\a_module' => array(  					'filename'	=> 'vendor2\\foo\\mcp\\a_module',  					'title'		=> 'Foobar', -					'version'	=> '3.1.0-dev',  					'modes'		=> array(  						'config'		=> array('title' => 'Config',	'auth' => '', 'cat' => array('MCP_MAIN')),  					), @@ -120,23 +107,19 @@ class phpbb_extension_modules_test extends phpbb_test_case  			), $acp_modules);  		// The mcp module info file we're looking for shouldn't exist -		$this->acp_modules->module_class = 'mcp'; -		$acp_modules = $this->acp_modules->get_module_infos('mcp_a_fail'); +		$acp_modules = $this->module_manager->get_module_infos('mcp', 'mcp_a_fail');  		$this->assertEquals(array(), $acp_modules);  		// As there are no ucp modules we shouldn't find any -		$this->acp_modules->module_class = 'ucp'; -		$acp_modules = $this->acp_modules->get_module_infos(); +		$acp_modules = $this->module_manager->get_module_infos('ucp');  		$this->assertEquals(array(), $acp_modules);  		// Get module info of specified extension module -		$this->acp_modules->module_class = 'acp'; -		$acp_modules = $this->acp_modules->get_module_infos('foo_acp_a_module'); +		$acp_modules = $this->module_manager->get_module_infos('acp', 'foo_acp_a_module');  		$this->assertEquals(array(  				'vendor2\\foo\\acp\\a_module' => array (  					'filename' => 'vendor2\\foo\\acp\\a_module',  					'title' => 'Foobar', -					'version' => '3.1.0-dev',  					'modes' => array (  						'config'		=> array ('title' => 'Config', 'auth' => 'ext_vendor2/foo', 'cat' => array ('ACP_MODS')),  					), @@ -144,23 +127,20 @@ class phpbb_extension_modules_test extends phpbb_test_case  			), $acp_modules);  		// No specific module and module class set to an incorrect name -		$acp_modules = $this->acp_modules->get_module_infos('', 'wcp', true); +		$acp_modules = $this->module_manager->get_module_infos('wcp', '', true);  		$this->assertEquals(array(), $acp_modules);  		// No specific module, no module_class set in the function parameter, and an incorrect module class -		$this->acp_modules->module_class = 'wcp'; -		$acp_modules = $this->acp_modules->get_module_infos(); +		$acp_modules = $this->module_manager->get_module_infos('wcp');  		$this->assertEquals(array(), $acp_modules);  		// No specific module, module class set to false (will default to the above acp)  		// Setting $use_all_available will cause get_module_infos() to also load not enabled extensions (vendor2/bar) -		$this->acp_modules->module_class = 'acp'; -		$acp_modules = $this->acp_modules->get_module_infos('', false, true); +		$acp_modules = $this->module_manager->get_module_infos('acp', '', true);  		$this->assertEquals(array(  				'vendor2\\foo\\acp\\a_module' => array(  					'filename'	=> 'vendor2\\foo\\acp\\a_module',  					'title'		=> 'Foobar', -					'version'	=> '3.1.0-dev',  					'modes'		=> array(  						'config'		=> array('title' => 'Config',	'auth' => 'ext_vendor2/foo', 'cat' => array('ACP_MODS')),  					), @@ -168,7 +148,6 @@ class phpbb_extension_modules_test extends phpbb_test_case  				'acp_foobar' => array(  					'filename'	=> 'acp_foobar',  					'title'		=> 'ACP Foobar', -					'version'	=> '3.1.0-dev',  					'modes'		=> array(  						'test'		=> array('title' => 'Test', 'auth' => '', 'cat' => array('ACP_GENERAL')),  					), @@ -176,7 +155,6 @@ class phpbb_extension_modules_test extends phpbb_test_case  				'vendor2\\bar\\acp\\a_module' => array(  					'filename'	=> 'vendor2\\bar\\acp\\a_module',  					'title'		=> 'Bar', -					'version'	=> '3.1.0-dev',  					'modes'		=> array(  						'config'		=> array('title' => 'Config',	'auth' => '', 'cat' => array('ACP_MODS')),  					), @@ -184,12 +162,11 @@ class phpbb_extension_modules_test extends phpbb_test_case  			), $acp_modules);  		// Specific module set to disabled extension -		$acp_modules = $this->acp_modules->get_module_infos('vendor2_bar_acp_a_module', 'acp', true); +		$acp_modules = $this->module_manager->get_module_infos('acp', 'vendor2_bar_acp_a_module', true);  		$this->assertEquals(array(  				'vendor2\\bar\\acp\\a_module' => array(  					'filename'	=> 'vendor2\\bar\\acp\\a_module',  					'title'		=> 'Bar', -					'version'	=> '3.1.0-dev',  					'modes'		=> array(  						'config'		=> array('title' => 'Config',	'auth' => '', 'cat' => array('ACP_MODS')),  					), | 
