1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-05 00:07:44 +02:00

Merge branch '3.2.x'

This commit is contained in:
Marc Alexander
2016-12-05 18:13:36 +01:00
22 changed files with 633 additions and 136 deletions

View File

@@ -0,0 +1,110 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
use phpbb\console\command\update\check;
require_once dirname(__FILE__) . '/../../../phpBB/includes/functions_admin.php';
require_once dirname(__FILE__) . '/../../../phpBB/includes/functions.php';
require_once dirname(__FILE__) . '/../../../phpBB/includes/utf/utf_tools.php';
/**
* @slow
*/
class phpbb_console_command_check_test extends phpbb_test_case
{
protected $command_name;
protected $version_helper;
/** @var \phpbb\language\language */
protected $language;
public function test_up_to_date()
{
$command_tester = $this->get_command_tester('100000');
$status = $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true));
$this->assertSame('', $command_tester->getDisplay());
$this->assertSame($status, 0);
}
public function test_up_to_date_verbose()
{
$command_tester = $this->get_command_tester('100000');
$status = $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true, '--verbose' => true));
$this->assertContains($this->language->lang('UPDATE_NOT_NEEDED'), $command_tester->getDisplay());
$this->assertSame($status, 0);
}
public function test_not_up_to_date()
{
$command_tester = $this->get_command_tester('0');
$status = $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true));
$this->assertContains($this->language->lang('UPDATE_NEEDED'), $command_tester->getDisplay());
$this->assertSame($status, 1);
}
public function test_not_up_to_date_verbose()
{
$command_tester = $this->get_command_tester('0');
$status = $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true, '--verbose' => true));
$this->assertContains($this->language->lang('UPDATE_NEEDED'), $command_tester->getDisplay());
$this->assertContains($this->language->lang('UPDATES_AVAILABLE'), $command_tester->getDisplay());
$this->assertSame($status, 1);
}
/**
* @expectedException phpbb\exception\runtime_exception
*/
public function test_error()
{
$command_tester = $this->get_command_tester('1');
$this->version_helper->set_file_location('acme.corp','foo', 'bar.json');
$status = $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true));
$this->assertContains('VERSIONCHECK_FAIL', $command_tester->getDisplay());
$this->assertSame($status, 2);
}
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);
}
}

View File

@@ -180,7 +180,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case
'phpbb_ext',
dirname(__FILE__) . '/',
$php_ext,
($with_cache) ? new phpbb_mock_cache() : null
($with_cache) ? new \phpbb\cache\service(new phpbb_mock_cache(), $config, $db, $phpbb_root_path, $php_ext) : null
);
}
}

View File

@@ -36,7 +36,6 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
{
parent::setUp();
$this->cache = new phpbb_mock_cache();
$this->config = new \phpbb\config\config(array(
'version' => '3.1.0',
));
@@ -45,6 +44,9 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
$this->db_tools = $factory->get($this->db);
$this->phpbb_root_path = dirname(__FILE__) . '/';
$this->phpEx = 'php';
$this->cache = new \phpbb\cache\service(new phpbb_mock_cache(), $this->config, $this->db, $this->phpbb_root_path, $this->phpEx);
$this->table_prefix = 'phpbb_';
$container = new phpbb_mock_container_builder();
@@ -364,7 +366,6 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
$ext_name,
$this->config,
$this->extension_manager,
$this->template,
$this->phpbb_root_path
);
}

View File

@@ -37,10 +37,11 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
->method('lang')
->will($this->returnCallback(array($this, 'return_callback_implode')));
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
$filesystem = new \phpbb\filesystem\filesystem();
$manager = new phpbb_mock_extension_manager(dirname(__FILE__) . '/', array());
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
$loader = new \Symfony\Component\Routing\Loader\YamlFileLoader(
new \phpbb\routing\file_locator($filesystem, dirname(__FILE__) . '/')

View File

@@ -263,7 +263,7 @@ class phpbb_functional_test_case extends phpbb_test_case
self::$config['table_prefix'] . 'ext',
dirname(__FILE__) . '/',
$phpEx,
$this->get_cache_driver()
new \phpbb\cache\service($this->get_cache_driver(), $config, $this->db, $phpbb_root_path, $phpEx)
);
return $extension_manager;

View File

@@ -28,15 +28,12 @@ class phpbb_version_helper_fetch_test extends phpbb_test_case
->disableOriginalConstructor()
->getMock();
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
$this->version_helper = new \phpbb\version_helper(
$this->cache,
new \phpbb\config\config(array(
'version' => '3.1.0',
)),
new \phpbb\file_downloader(),
new \phpbb\user(new \phpbb\language\language($lang_loader), '\phpbb\datetime')
new \phpbb\file_downloader()
);
}

View File

@@ -42,8 +42,7 @@ class version_helper_remote_test extends \phpbb_test_case
$this->version_helper = new \phpbb\version_helper(
$this->cache,
$config,
$this->file_downloader,
new \phpbb\user(new \phpbb\language\language($lang_loader), '\phpbb\datetime')
$this->file_downloader
);
$this->user = new \phpbb\user(new \phpbb\language\language($lang_loader), '\phpbb\datetime');
$this->user->add_lang('acp/common');
@@ -161,8 +160,8 @@ class version_helper_remote_test extends \phpbb_test_case
{
try {
$return = $this->version_helper->get_versions();
} catch (\RuntimeException $e) {
$this->assertEquals((string)$e->getMessage(), $this->user->lang('VERSIONCHECK_FAIL'));
} catch (\phpbb\exception\runtime_exception $e) {
$this->assertEquals((string)$e->getMessage(), 'VERSIONCHECK_FAIL');
}
}
else

View File

@@ -25,15 +25,12 @@ class phpbb_version_helper_test extends phpbb_test_case
->disableOriginalConstructor()
->getMock();
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
$this->version_helper = new \phpbb\version_helper(
$this->cache,
new \phpbb\config\config(array(
'version' => '3.1.0',
)),
new \phpbb\file_downloader(),
new \phpbb\user(new \phpbb\language\language($lang_loader), '\phpbb\datetime')
new \phpbb\file_downloader()
);
}