1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-13 20:24:08 +02:00

[ticket/12610] Add command to check if the board is up to date.

PHPBB3-12610
This commit is contained in:
Etienne Baroux
2014-06-02 10:12:18 +02:00
committed by Tristan Darricau
parent 17e8726582
commit 346f31a031
14 changed files with 491 additions and 72 deletions

View File

@@ -0,0 +1,99 @@
<?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;
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('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('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('UPDATE_NEEDED', $command_tester->getDisplay());
$this->assertContains('UPDATES_AVAILABLE', $command_tester->getDisplay());
$this->assertSame($status, 1);
}
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;
$user = $this->getMock('\phpbb\user');
$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, $user);
$container = new phpbb_mock_container_builder;
$container->set('version_helper', $this->version_helper);
$application = new Application();
$application->add(new check($user, $config, $container));
$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;