diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/extension/ext/vendor2/bar/migrations/bar.php | 7 | ||||
| -rw-r--r-- | tests/extension/ext/vendor2/bar/migrations/foo.php | 54 | ||||
| -rw-r--r-- | tests/extension/extension_base_test.php | 11 | ||||
| -rw-r--r-- | tests/files/types_remote_test.php | 12 | ||||
| -rw-r--r-- | tests/functional/plupload_test.php | 12 | ||||
| -rw-r--r-- | tests/language/language_test.php | 19 | ||||
| -rw-r--r-- | tests/mock/migrator.php | 4 | ||||
| -rw-r--r-- | tests/mock/phpbb_di_container_builder.php | 10 | ||||
| -rw-r--r-- | tests/test_framework/phpbb_database_test_connection_manager.php | 15 | ||||
| -rw-r--r-- | tests/test_framework/phpbb_functional_test_case.php | 12 |
10 files changed, 126 insertions, 30 deletions
diff --git a/tests/extension/ext/vendor2/bar/migrations/bar.php b/tests/extension/ext/vendor2/bar/migrations/bar.php new file mode 100644 index 0000000000..ea5ddb6b8b --- /dev/null +++ b/tests/extension/ext/vendor2/bar/migrations/bar.php @@ -0,0 +1,7 @@ +<?php + +namespace vendor2\foo\migrations; + +class bar +{ +} diff --git a/tests/extension/ext/vendor2/bar/migrations/foo.php b/tests/extension/ext/vendor2/bar/migrations/foo.php new file mode 100644 index 0000000000..d727c2f954 --- /dev/null +++ b/tests/extension/ext/vendor2/bar/migrations/foo.php @@ -0,0 +1,54 @@ +<?php + +namespace vendor2\foo\migrations; + +class foo implements \phpbb\db\migration\migration_interface +{ + /** + * {@inheritdoc} + */ + static public function depends_on() + { + return array(); + } + + /** + * {@inheritdoc} + */ + public function effectively_installed() + { + return false; + } + + /** + * {@inheritdoc} + */ + public function update_schema() + { + return array(); + } + + /** + * {@inheritdoc} + */ + public function revert_schema() + { + return array(); + } + + /** + * {@inheritdoc} + */ + public function update_data() + { + return array(); + } + + /** + * {@inheritdoc} + */ + public function revert_data() + { + return array(); + } +} diff --git a/tests/extension/extension_base_test.php b/tests/extension/extension_base_test.php index eee38186db..775a23e198 100644 --- a/tests/extension/extension_base_test.php +++ b/tests/extension/extension_base_test.php @@ -11,6 +11,9 @@ * */ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/ext/vendor2/bar/migrations/bar.php'; +require_once dirname(__FILE__) . '/ext/vendor2/bar/migrations/foo.php'; +require_once dirname(__FILE__) . '/ext/vendor2/bar/migrations/migration.php'; class phpbb_extension_extension_base_test extends phpbb_test_case { @@ -61,9 +64,7 @@ class phpbb_extension_extension_base_test extends phpbb_test_case return array( array( 'vendor2/bar', - array( - '\vendor2\bar\migrations\migration', - ), + array('\vendor2\bar\migrations\migration'), ), ); } @@ -74,6 +75,8 @@ class phpbb_extension_extension_base_test extends phpbb_test_case public function test_suffix_get_classes($extension_name, $expected) { $extension = $this->extension_manager->get_extension($extension_name); - $this->assertEquals($expected, self::$reflection_method_get_migration_file_list->invoke($extension)); + $migration_classes = self::$reflection_method_get_migration_file_list->invoke($extension); + sort($migration_classes); + $this->assertEquals($expected, $migration_classes); } } diff --git a/tests/files/types_remote_test.php b/tests/files/types_remote_test.php index a85844ee78..caed5c9e05 100644 --- a/tests/files/types_remote_test.php +++ b/tests/files/types_remote_test.php @@ -85,8 +85,8 @@ class phpbb_files_types_remote_test extends phpbb_test_case array('500k', 'http://example.com/foo/bar.png'), array('500M', 'http://example.com/foo/bar.png'), array('500m', 'http://example.com/foo/bar.png'), - array('500k', 'http://google.com/.png', 'DISALLOWED_CONTENT'), - array('1', 'http://google.com/.png', 'WRONG_FILESIZE'), + array('500k', 'http://google.com/?.png', array('DISALLOWED_EXTENSION', 'DISALLOWED_CONTENT')), + array('1', 'http://google.com/?.png', array('WRONG_FILESIZE')), array('500g', 'http://example.com/foo/bar.png'), array('foobar', 'http://example.com/foo/bar.png'), array('-5k', 'http://example.com/foo/bar.png'), @@ -96,7 +96,7 @@ class phpbb_files_types_remote_test extends phpbb_test_case /** * @dataProvider data_get_max_file_size */ - public function test_get_max_file_size($max_file_size, $link, $expected = 'URL_NOT_FOUND') + public function test_get_max_file_size($max_file_size, $link, $expected = array('URL_NOT_FOUND')) { $php_ini = $this->getMock('\bantu\IniGetWrapper\IniGetWrapper', array('getString')); $php_ini->expects($this->any()) @@ -109,7 +109,7 @@ class phpbb_files_types_remote_test extends phpbb_test_case $file = $type_remote->upload($link); - $this->assertSame(array($expected), $file->error); + $this->assertSame($expected, $file->error); } public function test_upload_timeout() @@ -120,7 +120,7 @@ class phpbb_files_types_remote_test extends phpbb_test_case $type_remote->set_upload($upload); $upload->upload_timeout = -5; - $file = $type_remote->upload('http://google.com/.png'); + $file = $type_remote->upload('http://google.com/?.png'); $this->assertSame(array('REMOTE_UPLOAD_TIMEOUT'), $file->error); } @@ -133,7 +133,7 @@ class phpbb_files_types_remote_test extends phpbb_test_case $type_remote->set_upload($upload); $type_remote::$tempnam_path = $this->phpbb_root_path . 'cache/wrong/path'; - $file = $type_remote->upload('http://google.com/.png'); + $file = $type_remote->upload('http://google.com/?.png'); $this->assertSame(array('NOT_UPLOADED'), $file->error); $type_remote::$tempnam_path = ''; diff --git a/tests/functional/plupload_test.php b/tests/functional/plupload_test.php index d358681ad1..9d284a7e57 100644 --- a/tests/functional/plupload_test.php +++ b/tests/functional/plupload_test.php @@ -107,11 +107,11 @@ class phpbb_functional_plupload_test extends phpbb_functional_test_case if ($i < self::CHUNKS - 1) { - $this->assertContains('{"jsonrpc":"2.0","id":"id","result":null}', self::$client->getResponse()->getContent()); + $this->assertContains('{"jsonrpc":"2.0","id":"id","result":null}', self::get_content()); } else { - $response = json_decode(self::$client->getResponse()->getContent(), true); + $response = json_decode(self::get_content(), true); $this->assertEquals('valid.jpg', $response['data'][0]['real_filename']); } @@ -134,7 +134,8 @@ class phpbb_functional_plupload_test extends phpbb_functional_test_case 'error' => UPLOAD_ERR_OK, ); - $crawler = self::$client->request( + self::$client->setServerParameter('HTTP_X_PHPBB_USING_PLUPLOAD', '1'); + self::$client->request( 'POST', $url . '&sid=' . $this->sid, array( @@ -144,11 +145,10 @@ class phpbb_functional_plupload_test extends phpbb_functional_test_case 'real_filename' => 'valid.jpg', 'add_file' => $this->lang('ADD_FILE'), ), - array('fileupload' => $file), - array('X-PHPBB-USING-PLUPLOAD' => '1') + array('fileupload' => $file) ); - $response = json_decode(self::$client->getResponse()->getContent(), true); + $response = json_decode(self::get_content(), true); $this->assertEquals('valid.jpg', $response['data'][0]['real_filename']); } } diff --git a/tests/language/language_test.php b/tests/language/language_test.php index 6a814e39dc..29b4873dcb 100644 --- a/tests/language/language_test.php +++ b/tests/language/language_test.php @@ -53,6 +53,25 @@ class phpbb_language_test extends phpbb_test_case $this->assertFalse($this->lang->is_set(array('PHPBB', 'PHP'))); } + public function test_lang_raw() + { + $this->assertEquals($this->lang->lang_raw('FOO'), 'BAR'); + $this->assertEquals($this->lang->lang_raw('VOID'), 'VOID'); + $this->assertEquals($this->lang->lang_raw('ARRY'), array( + 0 => 'No posts', // 0 + 1 => '1 post', // 1 + 2 => '%d posts', // 2+ + )); + } + + public function test_lang_array() + { + $this->assertEquals($this->lang->lang_array('FOO'), 'BAR'); + $this->assertEquals($this->lang->lang_array('VOID'), 'VOID'); + $this->assertEquals($this->lang->lang_array('ARRY', [0]), 'No posts'); + $this->assertEquals($this->lang->lang_array('FOO', [2, 3, 'BARZ']), 'BAR'); + } + public function test_lang() { // No param diff --git a/tests/mock/migrator.php b/tests/mock/migrator.php index 293f115335..4d1aca0a0a 100644 --- a/tests/mock/migrator.php +++ b/tests/mock/migrator.php @@ -21,10 +21,6 @@ class phpbb_mock_migrator extends \phpbb\db\migrator { } - public function set_migrations($class_names) - { - } - public function update() { } diff --git a/tests/mock/phpbb_di_container_builder.php b/tests/mock/phpbb_di_container_builder.php index 59cdf0bb2b..23dc3d1e8b 100644 --- a/tests/mock/phpbb_di_container_builder.php +++ b/tests/mock/phpbb_di_container_builder.php @@ -17,4 +17,14 @@ class phpbb_mock_phpbb_di_container_builder extends \phpbb\di\container_builder { return $this->phpbb_root_path . '../../tmp/container.' . $this->php_ext; } + + /** + * Get the filename under which the dumped extensions autoloader will be stored. + * + * @return string Path for dumped extensions autoloader + */ + protected function get_autoload_filename() + { + return $this->phpbb_root_path . '../../tmp/autoload.' . $this->php_ext; + } } diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index fa50d89a70..27ac64e21d 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -84,11 +84,18 @@ class phpbb_database_test_connection_manager break; default: - $dsn .= 'host=' . $this->config['dbhost']; - - if ($this->config['dbport']) + if (!empty($this->config['dbport']) && !is_numeric($this->config['dbport']) && $this->dbms['PDO'] != 'pgsql') + { + $dsn .= 'unix_socket=' . $this->config['dbport']; + } + else { - $dsn .= ';port=' . $this->config['dbport']; + $dsn .= 'host=' . $this->config['dbhost']; + + if ($this->config['dbport']) + { + $dsn .= ';port=' . $this->config['dbport']; + } } if ($use_db) diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index b91894f9c0..34fbcec0e2 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -16,6 +16,7 @@ require_once __DIR__ . '/mock/phpbb_mock_null_installer_task.php'; class phpbb_functional_test_case extends phpbb_test_case { + /** @var \Goutte\Client */ static protected $client; static protected $cookieJar; static protected $root_url; @@ -81,9 +82,6 @@ class phpbb_functional_test_case extends phpbb_test_case self::$cookieJar = new CookieJar; self::$client = new Goutte\Client(array(), null, self::$cookieJar); - // Reset the curl handle because it is 0 at this point and not a valid - // resource - self::$client->getClient()->getCurlMulti()->reset(true); // Clear the language array so that things // that were added in other tests are gone @@ -94,6 +92,8 @@ class phpbb_functional_test_case extends phpbb_test_case foreach (static::setup_extensions() as $extension) { + $this->purge_cache(); + $sql = 'SELECT ext_active FROM ' . EXT_TABLE . " WHERE ext_name = '" . $db->sql_escape($extension). "'"; @@ -167,7 +167,7 @@ class phpbb_functional_test_case extends phpbb_test_case */ static public function get_content() { - return self::$client->getResponse()->getContent(); + return (string) self::$client->getResponse()->getContent(); } // bootstrap, called after board is set up @@ -841,7 +841,7 @@ class phpbb_functional_test_case extends phpbb_test_case static public function assert_response_html($status_code = 200) { // Any output before the doc type means there was an error - $content = self::$client->getResponse()->getContent(); + $content = self::get_content(); self::assertNotContains('[phpBB Debug]', $content); self::assertStringStartsWith('<!DOCTYPE', trim($content), 'Output found before DOCTYPE specification.'); @@ -862,7 +862,7 @@ class phpbb_functional_test_case extends phpbb_test_case static public function assert_response_xml($status_code = 200) { // Any output before the xml opening means there was an error - $content = self::$client->getResponse()->getContent(); + $content = self::get_content(); self::assertNotContains('[phpBB Debug]', $content); self::assertStringStartsWith('<?xml', trim($content), 'Output found before XML specification.'); |
