diff options
Diffstat (limited to 'tests')
35 files changed, 450 insertions, 225 deletions
diff --git a/tests/avatar/driver/barfoo.php b/tests/avatar/driver/barfoo.php index 11c100db36..0bf30b8a91 100644 --- a/tests/avatar/driver/barfoo.php +++ b/tests/avatar/driver/barfoo.php @@ -18,4 +18,9 @@ class barfoo extends \phpbb\avatar\driver\driver {
return false;
}
+
+ public function get_template_name()
+ {
+ return 'barfoo.html';
+ }
}
diff --git a/tests/avatar/driver/foobar.php b/tests/avatar/driver/foobar.php index a1e7bdf7cc..aabdaf5ac4 100644 --- a/tests/avatar/driver/foobar.php +++ b/tests/avatar/driver/foobar.php @@ -18,4 +18,9 @@ class foobar extends \phpbb\avatar\driver\driver {
return false;
}
+
+ public function get_template_name()
+ {
+ return 'foobar.html';
+ }
}
diff --git a/tests/extension/ext/barfoo/composer.json b/tests/extension/ext/barfoo/composer.json new file mode 100644 index 0000000000..35d5d2a956 --- /dev/null +++ b/tests/extension/ext/barfoo/composer.json @@ -0,0 +1,22 @@ +{ + "name": "vendor/barfoo", + "type": "phpbb-extension", + "description": "An example/sample extension to be used for testing purposes in phpBB Development.", + "version": "1.0.0", + "time": "2012-02-15 01:01:01", + "licence": "GNU GPL v2", + "authors": [{ + "name": "John Smith", + "username": "JohnSmith27", + "email": "email@phpbb.com", + "homepage": "http://phpbb.com", + "role": "N/A" + }], + "require": { + "php": ">=5.3", + "phpbb/phpbb": "3.1.*@dev" + }, + "extra": { + "display-name": "phpBB BarFoo Extension" + } +} diff --git a/tests/extension/ext/barfoo/ext.php b/tests/extension/ext/barfoo/ext.php index 1b7bb7ca5e..0de403424c 100644 --- a/tests/extension/ext/barfoo/ext.php +++ b/tests/extension/ext/barfoo/ext.php @@ -1,6 +1,6 @@ <?php -namespace barfoo; +namespace vendor\barfoo; class ext extends \phpbb\extension\base { diff --git a/tests/extension/ext/vendor/moo/composer.json b/tests/extension/ext/vendor/moo/composer.json index 4dc36963b3..901cb7f17a 100644 --- a/tests/extension/ext/vendor/moo/composer.json +++ b/tests/extension/ext/vendor/moo/composer.json @@ -1,5 +1,5 @@ { - "name": "moo/example", + "name": "vendor/moo", "type": "phpbb-extension", "description": "An example/sample extension to be used for testing purposes in phpBB Development.", "version": "1.0.0", diff --git a/tests/extension/ext/barfoo/acp/a_info.php b/tests/extension/ext/vendor2/bar/acp/a_info.php index ea07189f7a..8132df587f 100644 --- a/tests/extension/ext/barfoo/acp/a_info.php +++ b/tests/extension/ext/vendor2/bar/acp/a_info.php @@ -1,14 +1,14 @@ <?php -namespace barfoo\acp; +namespace vendor2\bar\acp; class a_info { public function module() { return array( - 'filename' => 'barfoo\\acp\\a_module', - 'title' => 'Barfoo', + '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/barfoo/acp/a_module.php b/tests/extension/ext/vendor2/bar/acp/a_module.php index 0ae8775013..3a3d105790 100644 --- a/tests/extension/ext/barfoo/acp/a_module.php +++ b/tests/extension/ext/vendor2/bar/acp/a_module.php @@ -1,6 +1,6 @@ <?php -namespace barfoo\acp; +namespace vendor2\bar\acp; class a_module { diff --git a/tests/extension/ext/vendor2/bar/composer.json b/tests/extension/ext/vendor2/bar/composer.json new file mode 100644 index 0000000000..5d60ec031e --- /dev/null +++ b/tests/extension/ext/vendor2/bar/composer.json @@ -0,0 +1,21 @@ +{ + "name": "vendor2/bar", + "type": "phpbb-extension", + "description": "An example/sample extension to be used for testing purposes in phpBB Development.", + "version": "1.0.0", + "time": "2012-02-15 01:01:01", + "licence": "GPL-2.0", + "authors": [{ + "name": "John Smith", + "email": "email@phpbb.com", + "homepage": "http://phpbb.com", + "role": "N/A" + }], + "require": { + "php": ">=5.3", + "phpbb/phpbb": "3.1.*@dev" + }, + "extra": { + "display-name": "phpBB Bar Extension" + } +} diff --git a/tests/extension/ext/bar/ext.php b/tests/extension/ext/vendor2/bar/ext.php index 22ff5e8077..f94ab9ad81 100644 --- a/tests/extension/ext/bar/ext.php +++ b/tests/extension/ext/vendor2/bar/ext.php @@ -1,6 +1,6 @@ <?php -namespace bar; +namespace vendor2\bar; class ext extends \phpbb\extension\base { diff --git a/tests/extension/ext/foo/a_class.php b/tests/extension/ext/vendor2/foo/a_class.php index 9db45a697f..06278c0e0c 100644 --- a/tests/extension/ext/foo/a_class.php +++ b/tests/extension/ext/vendor2/foo/a_class.php @@ -1,6 +1,6 @@ <?php -namespace foo; +namespace vendor2\foo; class a_class { diff --git a/tests/extension/ext/foo/acp/a_info.php b/tests/extension/ext/vendor2/foo/acp/a_info.php index 3b7d8cdd42..27e67c1556 100644 --- a/tests/extension/ext/foo/acp/a_info.php +++ b/tests/extension/ext/vendor2/foo/acp/a_info.php @@ -1,13 +1,13 @@ <?php -namespace foo\acp; +namespace vendor2\foo\acp; class a_info { public function module() { return array( - 'filename' => 'foo\\acp\\a_module', + 'filename' => 'vendor2\\foo\\acp\\a_module', 'title' => 'Foobar', 'version' => '3.1.0-dev', 'modes' => array( diff --git a/tests/extension/ext/foo/mcp/a_module.php b/tests/extension/ext/vendor2/foo/acp/a_module.php index ca397e7004..78d91af2fe 100644 --- a/tests/extension/ext/foo/mcp/a_module.php +++ b/tests/extension/ext/vendor2/foo/acp/a_module.php @@ -1,6 +1,6 @@ <?php -namespace foo\mcp; +namespace vendor2\foo\acp; class a_module { diff --git a/tests/extension/ext/foo/acp/fail_info.php b/tests/extension/ext/vendor2/foo/acp/fail_info.php index 01d29fc5eb..d9b4353957 100644 --- a/tests/extension/ext/foo/acp/fail_info.php +++ b/tests/extension/ext/vendor2/foo/acp/fail_info.php @@ -1,6 +1,6 @@ <?php -namespace foo\acp; +namespace vendor2\foo\acp; /* * Due to the mismatch between the class name and the file name, this module @@ -11,7 +11,7 @@ class foo_info public function module() { return array( - 'filename' => 'foo\acp\fail_module', + 'filename' => 'vendor2\foo\acp\fail_module', 'title' => 'Foobar', 'version' => '3.1.0-dev', 'modes' => array( diff --git a/tests/extension/ext/foo/acp/fail_module.php b/tests/extension/ext/vendor2/foo/acp/fail_module.php index 8070929d3c..c8a5eae745 100644 --- a/tests/extension/ext/foo/acp/fail_module.php +++ b/tests/extension/ext/vendor2/foo/acp/fail_module.php @@ -1,6 +1,6 @@ <?php -namespace foo\acp; +namespace vendor2\foo\acp; /* * Due to the mismatch between the class name and the file name of the module diff --git a/tests/extension/ext/foo/b_class.php b/tests/extension/ext/vendor2/foo/b_class.php index bb2a77c05e..3d0f193908 100644 --- a/tests/extension/ext/foo/b_class.php +++ b/tests/extension/ext/vendor2/foo/b_class.php @@ -1,6 +1,6 @@ <?php -namespace foo; +namespace vendor2\foo; class b_class { diff --git a/tests/extension/ext/foo/composer.json b/tests/extension/ext/vendor2/foo/composer.json index 5367eaf593..8821d9d50e 100644 --- a/tests/extension/ext/foo/composer.json +++ b/tests/extension/ext/vendor2/foo/composer.json @@ -1,5 +1,5 @@ { - "name": "foo/example", + "name": "vendor2/foo", "type": "phpbb-extension", "description": "An example/sample extension to be used for testing purposes in phpBB Development.", "version": "1.0.0", diff --git a/tests/extension/ext/foo/ext.php b/tests/extension/ext/vendor2/foo/ext.php index ac6098f2f1..15480fe92a 100644 --- a/tests/extension/ext/foo/ext.php +++ b/tests/extension/ext/vendor2/foo/ext.php @@ -1,6 +1,6 @@ <?php -namespace foo; +namespace vendor2\foo; class ext extends \phpbb\extension\base { diff --git a/tests/extension/ext/foo/mcp/a_info.php b/tests/extension/ext/vendor2/foo/mcp/a_info.php index 9a896ce808..b5599fde65 100644 --- a/tests/extension/ext/foo/mcp/a_info.php +++ b/tests/extension/ext/vendor2/foo/mcp/a_info.php @@ -1,13 +1,13 @@ <?php -namespace foo\mcp; +namespace vendor2\foo\mcp; class a_info { public function module() { return array( - 'filename' => 'foo\\mcp\\a_module', + 'filename' => 'vendor2\\foo\\mcp\\a_module', 'title' => 'Foobar', 'version' => '3.1.0-dev', 'modes' => array( diff --git a/tests/extension/ext/foo/acp/a_module.php b/tests/extension/ext/vendor2/foo/mcp/a_module.php index 7aa2351ab3..fe29783827 100644 --- a/tests/extension/ext/foo/acp/a_module.php +++ b/tests/extension/ext/vendor2/foo/mcp/a_module.php @@ -1,6 +1,6 @@ <?php -namespace foo\acp; +namespace vendor2\foo\mcp; class a_module { diff --git a/tests/extension/ext/foo/sub/type/alternative.php b/tests/extension/ext/vendor2/foo/sub/type/alternative.php index 1eaf794609..1eaf794609 100644 --- a/tests/extension/ext/foo/sub/type/alternative.php +++ b/tests/extension/ext/vendor2/foo/sub/type/alternative.php diff --git a/tests/extension/ext/foo/type/alternative.php b/tests/extension/ext/vendor2/foo/type/alternative.php index 8f753491ef..8f753491ef 100644 --- a/tests/extension/ext/foo/type/alternative.php +++ b/tests/extension/ext/vendor2/foo/type/alternative.php diff --git a/tests/extension/ext/foo/type/dummy/empty.txt b/tests/extension/ext/vendor2/foo/type/dummy/empty.txt index e69de29bb2..e69de29bb2 100644 --- a/tests/extension/ext/foo/type/dummy/empty.txt +++ b/tests/extension/ext/vendor2/foo/type/dummy/empty.txt diff --git a/tests/extension/ext/foo/typewrong/error.php b/tests/extension/ext/vendor2/foo/typewrong/error.php index 5020926043..5020926043 100644 --- a/tests/extension/ext/foo/typewrong/error.php +++ b/tests/extension/ext/vendor2/foo/typewrong/error.php diff --git a/tests/extension/ext/vendor3/bar/ext.php b/tests/extension/ext/vendor3/bar/ext.php new file mode 100644 index 0000000000..37a5e92059 --- /dev/null +++ b/tests/extension/ext/vendor3/bar/ext.php @@ -0,0 +1,26 @@ +<?php + +namespace vendor3\bar; + +class ext extends \phpbb\extension\base +{ + static public $state; + + public function enable_step($old_state) + { + // run 4 steps, then quit + if ($old_state === 4) + { + return false; + } + + if ($old_state === false) + { + $old_state = 0; + } + + self::$state = ++$old_state; + + return self::$state; + } +} diff --git a/tests/extension/ext/bar/my/hidden_class.php b/tests/extension/ext/vendor3/bar/my/hidden_class.php index 504c1873dc..38eb59aadf 100644 --- a/tests/extension/ext/bar/my/hidden_class.php +++ b/tests/extension/ext/vendor3/bar/my/hidden_class.php @@ -1,6 +1,6 @@ <?php -namespace bar\my; +namespace vendor3\bar\my; class hidden_class { diff --git a/tests/extension/ext/bar/styles/prosilver/template/foobar_body.html b/tests/extension/ext/vendor3/bar/styles/prosilver/template/foobar_body.html index 00c2a84a18..00c2a84a18 100644 --- a/tests/extension/ext/bar/styles/prosilver/template/foobar_body.html +++ b/tests/extension/ext/vendor3/bar/styles/prosilver/template/foobar_body.html diff --git a/tests/extension/finder_test.php b/tests/extension/finder_test.php index 8e6e71aaf8..d0ca5956b4 100644 --- a/tests/extension/finder_test.php +++ b/tests/extension/finder_test.php @@ -18,15 +18,15 @@ class phpbb_extension_finder_test extends phpbb_test_case $this->extension_manager = new phpbb_mock_extension_manager( dirname(__FILE__) . '/', array( - 'foo' => array( - 'ext_name' => 'foo', + 'vendor2/foo' => array( + 'ext_name' => 'vendor2/foo', 'ext_active' => '1', - 'ext_path' => 'ext/foo/', + 'ext_path' => 'ext/vendor2/foo/', ), - 'bar' => array( - 'ext_name' => 'bar', + 'vendor3/bar' => array( + 'ext_name' => 'vendor3/bar', 'ext_active' => '1', - 'ext_path' => 'ext/bar/', + 'ext_path' => 'ext/vendor3/bar/', ), )); @@ -43,10 +43,10 @@ class phpbb_extension_finder_test extends phpbb_test_case sort($classes); $this->assertEquals( array( - '\bar\my\hidden_class', - '\foo\a_class', - '\foo\b_class', '\phpbb\default\implementation', + '\vendor2\foo\a_class', + '\vendor2\foo\b_class', + '\vendor3\bar\my\hidden_class', ), $classes ); @@ -60,7 +60,7 @@ class phpbb_extension_finder_test extends phpbb_test_case sort($dirs); $this->assertEquals(array( - dirname(__FILE__) . '/ext/foo/type/', + dirname(__FILE__) . '/ext/vendor2/foo/type/', ), $dirs); } @@ -72,9 +72,9 @@ class phpbb_extension_finder_test extends phpbb_test_case sort($dirs); $this->assertEquals(array( - dirname(__FILE__) . '/ext/foo/sub/type/', - dirname(__FILE__) . '/ext/foo/type/', - dirname(__FILE__) . '/ext/foo/typewrong/', + dirname(__FILE__) . '/ext/vendor2/foo/sub/type/', + dirname(__FILE__) . '/ext/vendor2/foo/type/', + dirname(__FILE__) . '/ext/vendor2/foo/typewrong/', ), $dirs); } @@ -88,8 +88,8 @@ class phpbb_extension_finder_test extends phpbb_test_case sort($classes); $this->assertEquals( array( - '\bar\my\hidden_class', '\phpbb\default\implementation', + '\vendor3\bar\my\hidden_class', ), $classes ); @@ -105,9 +105,9 @@ class phpbb_extension_finder_test extends phpbb_test_case sort($classes); $this->assertEquals( array( - '\foo\sub\type\alternative', - '\foo\type\alternative', '\phpbb\default\implementation', + '\vendor2\foo\sub\type\alternative', + '\vendor2\foo\type\alternative', ), $classes ); @@ -122,7 +122,7 @@ class phpbb_extension_finder_test extends phpbb_test_case sort($classes); $this->assertEquals( array( - '\foo\type\alternative', + '\vendor2\foo\type\alternative', ), $classes ); @@ -137,7 +137,7 @@ class phpbb_extension_finder_test extends phpbb_test_case sort($classes); $this->assertEquals( array( - '\foo\sub\type\alternative', + '\vendor2\foo\sub\type\alternative', ), $classes ); @@ -152,7 +152,7 @@ class phpbb_extension_finder_test extends phpbb_test_case sort($classes); $this->assertEquals( array( - '\foo\sub\type\alternative', + '\vendor2\foo\sub\type\alternative', ), $classes ); @@ -162,14 +162,14 @@ class phpbb_extension_finder_test extends phpbb_test_case { $files = $this->finder ->extension_directory('/type') - ->find_from_extension('foo', dirname(__FILE__) . '/ext/foo/'); + ->find_from_extension('vendor2/foo', dirname(__FILE__) . '/ext/vendor2/foo/'); $classes = $this->finder->get_classes_from_files($files); sort($classes); $this->assertEquals( array( - '\foo\type\alternative', - '\foo\type\dummy\empty', + '\vendor2\foo\type\alternative', + '\vendor2\foo\type\dummy\empty', ), $classes ); diff --git a/tests/extension/fixtures/extensions.xml b/tests/extension/fixtures/extensions.xml index 6eb6fd11a5..6846162f0f 100644 --- a/tests/extension/fixtures/extensions.xml +++ b/tests/extension/fixtures/extensions.xml @@ -5,7 +5,7 @@ <column>ext_active</column> <column>ext_state</column> <row> - <value>foo</value> + <value>vendor2/foo</value> <value>1</value> <value></value> </row> diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php index b127daf2ed..cc32a6af4e 100644 --- a/tests/extension/manager_test.php +++ b/tests/extension/manager_test.php @@ -7,8 +7,8 @@ * */ -require_once dirname(__FILE__) . '/ext/bar/ext.php'; -require_once dirname(__FILE__) . '/ext/foo/ext.php'; +require_once dirname(__FILE__) . '/ext/vendor2/bar/ext.php'; +require_once dirname(__FILE__) . '/ext/vendor2/foo/ext.php'; require_once dirname(__FILE__) . '/ext/vendor/moo/ext.php'; class phpbb_extension_manager_test extends phpbb_database_test_case @@ -30,52 +30,53 @@ class phpbb_extension_manager_test extends phpbb_database_test_case public function test_available() { - $this->assertEquals(array('bar', 'barfoo', 'foo', 'vendor/moo'), array_keys($this->extension_manager->all_available())); + // barfoo and vendor3/bar should not listed due to missing composer.json. barfoo also has incorrect dir structure. + $this->assertEquals(array('vendor/moo', 'vendor2/bar', 'vendor2/foo'), array_keys($this->extension_manager->all_available())); } public function test_enabled() { - $this->assertEquals(array('foo'), array_keys($this->extension_manager->all_enabled())); + $this->assertEquals(array('vendor2/foo'), array_keys($this->extension_manager->all_enabled())); } public function test_configured() { - $this->assertEquals(array('foo', 'vendor/moo'), array_keys($this->extension_manager->all_configured())); + $this->assertEquals(array('vendor/moo', 'vendor2/foo'), array_keys($this->extension_manager->all_configured())); } public function test_enable() { - bar\ext::$state = 0; + vendor2\bar\ext::$state = 0; - $this->assertEquals(array('foo'), array_keys($this->extension_manager->all_enabled())); - $this->extension_manager->enable('bar'); - $this->assertEquals(array('bar', 'foo'), array_keys($this->extension_manager->all_enabled())); - $this->assertEquals(array('bar', 'foo', 'vendor/moo'), array_keys($this->extension_manager->all_configured())); + $this->assertEquals(array('vendor2/foo'), array_keys($this->extension_manager->all_enabled())); + $this->extension_manager->enable('vendor2/bar'); + $this->assertEquals(array('vendor2/bar', 'vendor2/foo'), array_keys($this->extension_manager->all_enabled())); + $this->assertEquals(array('vendor/moo', 'vendor2/bar', 'vendor2/foo'), array_keys($this->extension_manager->all_configured())); - $this->assertEquals(4, bar\ext::$state); + $this->assertEquals(4, vendor2\bar\ext::$state); } public function test_disable() { - foo\ext::$disabled = false; + vendor2\foo\ext::$disabled = false; - $this->assertEquals(array('foo'), array_keys($this->extension_manager->all_enabled())); - $this->extension_manager->disable('foo'); + $this->assertEquals(array('vendor2/foo'), array_keys($this->extension_manager->all_enabled())); + $this->extension_manager->disable('vendor2/foo'); $this->assertEquals(array(), array_keys($this->extension_manager->all_enabled())); - $this->assertEquals(array('foo', 'vendor/moo'), array_keys($this->extension_manager->all_configured())); + $this->assertEquals(array('vendor/moo', 'vendor2/foo'), array_keys($this->extension_manager->all_configured())); - $this->assertTrue(foo\ext::$disabled); + $this->assertTrue(vendor2\foo\ext::$disabled); } public function test_purge() { vendor\moo\ext::$purged = false; - $this->assertEquals(array('foo'), array_keys($this->extension_manager->all_enabled())); - $this->assertEquals(array('foo', 'vendor/moo'), array_keys($this->extension_manager->all_configured())); + $this->assertEquals(array('vendor2/foo'), array_keys($this->extension_manager->all_enabled())); + $this->assertEquals(array('vendor/moo', 'vendor2/foo'), array_keys($this->extension_manager->all_configured())); $this->extension_manager->purge('vendor/moo'); - $this->assertEquals(array('foo'), array_keys($this->extension_manager->all_enabled())); - $this->assertEquals(array('foo'), array_keys($this->extension_manager->all_configured())); + $this->assertEquals(array('vendor2/foo'), array_keys($this->extension_manager->all_enabled())); + $this->assertEquals(array('vendor2/foo'), array_keys($this->extension_manager->all_configured())); $this->assertTrue(vendor\moo\ext::$purged); } @@ -84,7 +85,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case { $extension_manager = $this->create_extension_manager(false); - $this->assertEquals(array('foo'), array_keys($extension_manager->all_enabled())); + $this->assertEquals(array('vendor2/foo'), array_keys($extension_manager->all_enabled())); } protected function create_extension_manager($with_cache = true) diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php index 09eb83cd86..592421f9e7 100644 --- a/tests/extension/metadata_manager_test.php +++ b/tests/extension/metadata_manager_test.php @@ -82,7 +82,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case // Should fail from missing composer.json public function test_bar() { - $ext_name = 'bar'; + $ext_name = 'vendor3/bar'; $manager = $this->get_metadata_manager($ext_name); @@ -98,7 +98,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case // Should be the same as a direct json_decode of the composer.json file public function test_foo() { - $ext_name = 'foo'; + $ext_name = 'vendor2/foo'; $manager = $this->get_metadata_manager($ext_name); @@ -111,7 +111,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $this->fail($e); } - $json = json_decode(file_get_contents($this->phpbb_root_path . 'ext/foo/composer.json'), true); + $json = json_decode(file_get_contents($this->phpbb_root_path . 'ext/vendor2/foo/composer.json'), true); $this->assertEquals($metadata, $json); } diff --git a/tests/extension/modules_test.php b/tests/extension/modules_test.php index ef21c943c2..5dcb24c691 100644 --- a/tests/extension/modules_test.php +++ b/tests/extension/modules_test.php @@ -7,10 +7,10 @@ * */ -require_once dirname(__FILE__) . '/ext/foo/acp/a_info.php'; -require_once dirname(__FILE__) . '/ext/foo/mcp/a_info.php'; -require_once dirname(__FILE__) . '/ext/foo/acp/fail_info.php'; -require_once dirname(__FILE__) . '/ext/barfoo/acp/a_info.php'; +require_once dirname(__FILE__) . '/ext/vendor2/foo/acp/a_info.php'; +require_once dirname(__FILE__) . '/ext/vendor2/foo/mcp/a_info.php'; +require_once dirname(__FILE__) . '/ext/vendor2/foo/acp/fail_info.php'; +require_once dirname(__FILE__) . '/ext/vendor2/bar/acp/a_info.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/acp/acp_modules.php'; class phpbb_extension_modules_test extends phpbb_test_case @@ -25,15 +25,15 @@ class phpbb_extension_modules_test extends phpbb_test_case $this->extension_manager = new phpbb_mock_extension_manager( dirname(__FILE__) . '/', array( - 'foo' => array( - 'ext_name' => 'foo', + 'vendor2/foo' => array( + 'ext_name' => 'vendor2/foo', 'ext_active' => '1', - 'ext_path' => 'ext/foo/', + 'ext_path' => 'ext/vendor2/foo/', ), - 'bar' => array( - 'ext_name' => 'bar', + 'vendor3/bar' => array( + 'ext_name' => 'vendor3/bar', 'ext_active' => '1', - 'ext_path' => 'ext/bar/', + 'ext_path' => 'ext/vendor3/bar/', ), )); $phpbb_extension_manager = $this->extension_manager; @@ -54,8 +54,8 @@ class phpbb_extension_modules_test extends phpbb_test_case $this->acp_modules->module_class = 'acp'; $acp_modules = $this->acp_modules->get_module_infos(); $this->assertEquals(array( - 'foo\\acp\\a_module' => array( - 'filename' => 'foo\\acp\\a_module', + 'vendor2\\foo\\acp\\a_module' => array( + 'filename' => 'vendor2\\foo\\acp\\a_module', 'title' => 'Foobar', 'version' => '3.1.0-dev', 'modes' => array( @@ -76,8 +76,8 @@ class phpbb_extension_modules_test extends phpbb_test_case $this->acp_modules->module_class = 'mcp'; $acp_modules = $this->acp_modules->get_module_infos(); $this->assertEquals(array( - 'foo\\mcp\\a_module' => array( - 'filename' => 'foo\\mcp\\a_module', + 'vendor2\\foo\\mcp\\a_module' => array( + 'filename' => 'vendor2\\foo\\mcp\\a_module', 'title' => 'Foobar', 'version' => '3.1.0-dev', 'modes' => array( @@ -90,8 +90,8 @@ class phpbb_extension_modules_test extends phpbb_test_case $this->acp_modules->module_class = 'mcp'; $acp_modules = $this->acp_modules->get_module_infos('mcp_a_module'); $this->assertEquals(array( - 'foo\\mcp\\a_module' => array( - 'filename' => 'foo\\mcp\\a_module', + 'vendor2\\foo\\mcp\\a_module' => array( + 'filename' => 'vendor2\\foo\\mcp\\a_module', 'title' => 'Foobar', 'version' => '3.1.0-dev', 'modes' => array( @@ -104,8 +104,8 @@ class phpbb_extension_modules_test extends phpbb_test_case $this->acp_modules->module_class = ''; $acp_modules = $this->acp_modules->get_module_infos('mcp_a_module', 'mcp'); $this->assertEquals(array( - 'foo\\mcp\\a_module' => array( - 'filename' => 'foo\\mcp\\a_module', + 'vendor2\\foo\\mcp\\a_module' => array( + 'filename' => 'vendor2\\foo\\mcp\\a_module', 'title' => 'Foobar', 'version' => '3.1.0-dev', 'modes' => array( @@ -128,8 +128,8 @@ class phpbb_extension_modules_test extends phpbb_test_case $this->acp_modules->module_class = 'acp'; $acp_modules = $this->acp_modules->get_module_infos('foo_acp_a_module'); $this->assertEquals(array( - 'foo\\acp\\a_module' => array ( - 'filename' => 'foo\\acp\\a_module', + 'vendor2\\foo\\acp\\a_module' => array ( + 'filename' => 'vendor2\\foo\\acp\\a_module', 'title' => 'Foobar', 'version' => '3.1.0-dev', 'modes' => array ( @@ -148,12 +148,12 @@ class phpbb_extension_modules_test extends phpbb_test_case $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 (barfoo) + // 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); $this->assertEquals(array( - 'foo\\acp\\a_module' => array( - 'filename' => 'foo\\acp\\a_module', + 'vendor2\\foo\\acp\\a_module' => array( + 'filename' => 'vendor2\\foo\\acp\\a_module', 'title' => 'Foobar', 'version' => '3.1.0-dev', 'modes' => array( @@ -168,9 +168,9 @@ class phpbb_extension_modules_test extends phpbb_test_case 'test' => array('title' => 'Test', 'auth' => '', 'cat' => array('ACP_GENERAL')), ), ), - 'barfoo\\acp\\a_module' => array( - 'filename' => 'barfoo\\acp\\a_module', - 'title' => 'Barfoo', + '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')), @@ -179,11 +179,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('barfoo_acp_a_module', 'acp', true); + $acp_modules = $this->acp_modules->get_module_infos('vendor2_bar_acp_a_module', 'acp', true); $this->assertEquals(array( - 'barfoo\\acp\\a_module' => array( - 'filename' => 'barfoo\\acp\\a_module', - 'title' => 'Barfoo', + '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')), diff --git a/tests/functional/extension_acp_test.php b/tests/functional/extension_acp_test.php index 5d391e42f7..53f62c4f19 100644 --- a/tests/functional/extension_acp_test.php +++ b/tests/functional/extension_acp_test.php @@ -45,7 +45,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case // Insert our base data $insert_rows = array( array( - 'ext_name' => 'foo', + 'ext_name' => 'vendor2/foo', 'ext_active' => true, 'ext_state' => 'b:0;', ), @@ -57,12 +57,12 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case // do not exist array( - 'ext_name' => 'test2', + 'ext_name' => 'vendor/test2', 'ext_active' => true, 'ext_state' => 'b:0;', ), array( - 'ext_name' => 'test3', + 'ext_name' => 'vendor/test3', 'ext_active' => false, 'ext_state' => 'b:0;', ), @@ -80,30 +80,38 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid); $this->assertCount(1, $crawler->filter('.ext_enabled')); - $this->assertCount(5, $crawler->filter('.ext_disabled')); + $this->assertCount(4, $crawler->filter('.ext_disabled')); $this->assertContains('phpBB Foo Extension', $crawler->filter('.ext_enabled')->eq(0)->text()); $this->assertContainsLang('EXTENSION_DISABLE', $crawler->filter('.ext_enabled')->eq(0)->text()); - $this->assertContains('The “test2” extension is not valid.', $crawler->filter('.ext_disabled')->eq(0)->text()); + $this->assertContains('phpBB Moo Extension', $crawler->filter('.ext_disabled')->eq(1)->text()); + $this->assertContainsLang('DETAILS', $crawler->filter('.ext_disabled')->eq(1)->text()); + $this->assertContainsLang('EXTENSION_ENABLE', $crawler->filter('.ext_disabled')->eq(1)->text()); + $this->assertContainsLang('EXTENSION_DELETE_DATA', $crawler->filter('.ext_disabled')->eq(1)->text()); - $this->assertContains('The “test3” extension is not valid.', $crawler->filter('.ext_disabled')->eq(1)->text()); + $this->assertContains('The “vendor/test2” extension is not valid.', $crawler->filter('.ext_disabled')->eq(0)->text()); - $this->assertContains('phpBB Moo Extension', $crawler->filter('.ext_disabled')->eq(2)->text()); - $this->assertContainsLang('DETAILS', $crawler->filter('.ext_disabled')->eq(2)->text()); - $this->assertContainsLang('EXTENSION_ENABLE', $crawler->filter('.ext_disabled')->eq(2)->text()); - $this->assertContainsLang('EXTENSION_DELETE_DATA', $crawler->filter('.ext_disabled')->eq(2)->text()); + $this->assertContains('The “vendor/test3” extension is not valid.', $crawler->filter('.ext_disabled')->eq(2)->text()); - $this->assertContains('The “bar” extension is not valid.', $crawler->filter('.ext_disabled')->eq(3)->text()); + $this->assertContains('phpBB Bar Extension', $crawler->filter('.ext_disabled')->eq(3)->text()); + $this->assertContainsLang('DETAILS', $crawler->filter('.ext_disabled')->eq(3)->text()); + $this->assertContainsLang('EXTENSION_ENABLE', $crawler->filter('.ext_disabled')->eq(3)->text()); + + // Check that invalid extensions are not listed. + $this->assertNotContains('phpBB BarFoo Extension', $crawler->filter('.table1')->text()); + $this->assertNotContains('barfoo', $crawler->filter('.table1')->text()); + + $this->assertNotContains('vendor3/bar', $crawler->filter('.table1')->text()); } public function test_details() { - $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=details&ext_name=foo&sid=' . $this->sid); + $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=details&ext_name=vendor2%2Ffoo&sid=' . $this->sid); $validation = array( 'DISPLAY_NAME' => 'phpBB Foo Extension', - 'CLEAN_NAME' => 'foo/example', + 'CLEAN_NAME' => 'vendor2/foo', 'TYPE' => 'phpbb-extension', 'DESCRIPTION' => 'An example/sample extension to be used for testing purposes in phpBB Development.', 'VERSION' => '1.0.0', @@ -143,7 +151,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case public function test_enable_pre() { // Foo is already enabled (redirect to list) - $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=foo&sid=' . $this->sid); + $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=vendor2%2Ffoo&sid=' . $this->sid); $this->assertContainsLang('EXTENSION_NAME', $crawler->filter('div.main thead')->text()); $this->assertContainsLang('EXTENSION_OPTIONS', $crawler->filter('div.main thead')->text()); $this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('div.main thead')->text()); @@ -160,7 +168,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case $this->assertContainsLang('EXTENSION_OPTIONS', $crawler->filter('div.main thead')->text()); $this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('div.main thead')->text()); - $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=foo&sid=' . $this->sid); + $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=vendor2%2Ffoo&sid=' . $this->sid); $this->assertContains($this->lang('EXTENSION_DISABLE_CONFIRM', 'phpBB Foo Extension'), $crawler->filter('.errorbox')->text()); } @@ -171,7 +179,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case $this->assertContains('The required file does not exist', $crawler->filter('.errorbox')->text()); // foo is not disabled (redirect to list) - $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data_pre&ext_name=foo&sid=' . $this->sid); + $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data_pre&ext_name=vendor2%2Ffoo&sid=' . $this->sid); $this->assertContainsLang('EXTENSION_NAME', $crawler->filter('div.main thead')->text()); $this->assertContainsLang('EXTENSION_OPTIONS', $crawler->filter('div.main thead')->text()); $this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('div.main thead')->text()); @@ -211,5 +219,9 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case $form = $crawler->selectButton('delete_data')->form(); $crawler = self::submit($form); $this->assertContainsLang('EXTENSION_DELETE_DATA_SUCCESS', $crawler->filter('.successbox')->text()); + + // Attempt to enable invalid extension + $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=barfoo&sid=' . $this->sid); + $this->assertContainsLang('EXTENSION_DIR_INVALID', $crawler->filter('.errorbox')->text()); } } diff --git a/tests/pagination/generate_template_test.php b/tests/pagination/generate_template_test.php deleted file mode 100644 index 587a948583..0000000000 --- a/tests/pagination/generate_template_test.php +++ /dev/null @@ -1,111 +0,0 @@ -<?php -/** -* -* @package testing -* @copyright (c) 2013 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 -* -*/ - -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../template/template_test_case.php'; - -class phpbb_pagination_generate_template_test extends phpbb_template_template_test_case -{ - protected $test_path = 'tests/pagination'; - - public function phpbb_generate_template_pagination_data() - { - return array( - array( - 'page.php', - 'start', - 95, - 10, - 10, - 'pagination - :previous::page.php - :else:1:page.php - :current:2:page.php?start=10 - :else:3:page.php?start=20 - :else:4:page.php?start=30 - :else:5:page.php?start=40 - :ellipsis:9:page.php?start=80 - :else:10:page.php?start=90 - :next::page.php?start=20 - :u_prev:page.php - :u_next:page.php?start=20', - ), - array( - 'page.php', - 'start', - 95, - 10, - 20, - 'pagination - :previous::page.php?start=10 - :else:1:page.php - :else:2:page.php?start=10 - :current:3:page.php?start=20 - :else:4:page.php?start=30 - :else:5:page.php?start=40 - :else:6:page.php?start=50 - :ellipsis:9:page.php?start=80 - :else:10:page.php?start=90 - :next::page.php?start=30 - :u_prev:page.php?start=10 - :u_next:page.php?start=30', - ), - array( - 'test/page/%d', - '/page/%d', - 95, - 10, - 10, - 'pagination - :previous::test - :else:1:test - :current:2:test/page/2 - :else:3:test/page/3 - :else:4:test/page/4 - :else:5:test/page/5 - :ellipsis:9:test/page/9 - :else:10:test/page/10 - :next::test/page/3 - :u_prev:test - :u_next:test/page/3', - ), - array( - 'test/page/%d', - '/page/%d', - 95, - 10, - 20, - 'pagination - :previous::test/page/2 - :else:1:test - :else:2:test/page/2 - :current:3:test/page/3 - :else:4:test/page/4 - :else:5:test/page/5 - :else:6:test/page/6 - :ellipsis:9:test/page/9 - :else:10:test/page/10 - :next::test/page/4 - :u_prev:test/page/2 - :u_next:test/page/4', - ), - ); - } - - /** - * @dataProvider phpbb_generate_template_pagination_data - */ - public function test_phpbb_generate_template_pagination($base_url, $start_name, $num_items, $per_page, $start_item, $expect) - { - phpbb_generate_template_pagination($this->template, $base_url, 'pagination', $start_name, $num_items, $per_page, $start_item); - $this->template->set_filenames(array('test' => 'pagination.html')); - - $this->assertEquals(str_replace("\t", '', $expect), $this->display('test')); - } -} diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php new file mode 100644 index 0000000000..4e8083b47f --- /dev/null +++ b/tests/pagination/pagination_test.php @@ -0,0 +1,240 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2013 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +require_once dirname(__FILE__) . '/../template/template_test_case.php'; + +class phpbb_pagination_pagination_test extends phpbb_template_template_test_case +{ + protected $test_path = 'tests/pagination'; + + public function return_callback_implode() + { + return implode('-', func_get_args()); + } + + public function setUp() + { + parent::setUp(); + $user = $this->getMock('\phpbb\user'); + $user->expects($this->any()) + ->method('lang') + ->will($this->returnCallback(array($this, 'return_callback_implode'))); + $this->pagination = new \phpbb\pagination($this->template, $user); + } + + public function generate_template_pagination_data() + { + return array( + array( + 'page.php', + 'start', + 95, + 10, + 10, + 'pagination + :previous::page.php + :else:1:page.php + :current:2:page.php?start=10 + :else:3:page.php?start=20 + :else:4:page.php?start=30 + :else:5:page.php?start=40 + :ellipsis:9:page.php?start=80 + :else:10:page.php?start=90 + :next::page.php?start=20 + :u_prev:page.php + :u_next:page.php?start=20', + ), + array( + 'page.php', + 'start', + 95, + 10, + 20, + 'pagination + :previous::page.php?start=10 + :else:1:page.php + :else:2:page.php?start=10 + :current:3:page.php?start=20 + :else:4:page.php?start=30 + :else:5:page.php?start=40 + :else:6:page.php?start=50 + :ellipsis:9:page.php?start=80 + :else:10:page.php?start=90 + :next::page.php?start=30 + :u_prev:page.php?start=10 + :u_next:page.php?start=30', + ), + array( + 'test/page/%d', + '/page/%d', + 95, + 10, + 10, + 'pagination + :previous::test + :else:1:test + :current:2:test/page/2 + :else:3:test/page/3 + :else:4:test/page/4 + :else:5:test/page/5 + :ellipsis:9:test/page/9 + :else:10:test/page/10 + :next::test/page/3 + :u_prev:test + :u_next:test/page/3', + ), + array( + 'test/page/%d', + '/page/%d', + 95, + 10, + 20, + 'pagination + :previous::test/page/2 + :else:1:test + :else:2:test/page/2 + :current:3:test/page/3 + :else:4:test/page/4 + :else:5:test/page/5 + :else:6:test/page/6 + :ellipsis:9:test/page/9 + :else:10:test/page/10 + :next::test/page/4 + :u_prev:test/page/2 + :u_next:test/page/4', + ), + ); + } + + /** + * @dataProvider generate_template_pagination_data + */ + public function test_generate_template_pagination($base_url, $start_name, $num_items, $per_page, $start_item, $expect) + { + $this->pagination->generate_template_pagination($base_url, 'pagination', $start_name, $num_items, $per_page, $start_item); + $this->template->set_filenames(array('test' => 'pagination.html')); + + $this->assertEquals(str_replace("\t", '', $expect), $this->display('test')); + } + + public function on_page_data() + { + return array( + array( + 'page.php', + 10, + 10, + 0, + 'PAGE_OF-1-1', + 'on_page + per_page:10 + on_page:1 + base_url:page.php', + ), + ); + } + + /** + * @dataProvider on_page_data + */ + public function test_on_page($base_url, $num_items, $per_page, $start_item, $expect_return, $expect) + { + $this->assertEquals($expect_return, $this->pagination->on_page($base_url, $num_items, $per_page, $start_item)); + + $this->template->set_filenames(array('test' => 'on_page.html')); + + $this->assertEquals(str_replace("\t", '', $expect), $this->display('test')); + } + + public function validate_start_data() + { + return array( + array( + -1, + 0, + ), + array( + 0, + 0, + ), + array( + 10, + 10, + ), + array( + 20, + 10, + ), + array( + 30, + 10, + ), + ); + } + + /** + * @dataProvider validate_start_data + */ + public function test_validate_start($start, $expect) + { + $this->assertEquals($expect, $this->pagination->validate_start($start, 10, 20)); + } + + public function reverse_start_data() + { + return array( + array( + 10, + 5, + 15, + 0, + ), + array( + 10, + 10, + 25, + 5, + ), + ); + } + + /** + * @dataProvider reverse_start_data + */ + public function test_reverse_start($start, $limit, $num_items, $expect) + { + $this->assertEquals($expect, $this->pagination->reverse_start($start, $limit, $num_items)); + } + + public function reverse_limit_data() + { + return array( + array( + 10, + 10, + 15, + 5, + ), + array( + 20, + 10, + 15, + 1, + ), + ); + } + + /** + * @dataProvider reverse_limit_data + */ + public function test_reverse_limit($start, $per_page, $num_items, $expect) + { + $this->assertEquals($expect, $this->pagination->reverse_limit($start, $per_page, $num_items)); + } +} diff --git a/tests/pagination/templates/on_page.html b/tests/pagination/templates/on_page.html new file mode 100644 index 0000000000..364bcf9f5e --- /dev/null +++ b/tests/pagination/templates/on_page.html @@ -0,0 +1,4 @@ +on_page +per_page:{PER_PAGE} +on_page:{ON_PAGE} +base_url:{BASE_URL} |