mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
[ticket/12658] Add test for base case of command config:set
PHPBB3-12658
This commit is contained in:
parent
d2ed2c4e1e
commit
1662ee64e0
1 changed files with 71 additions and 0 deletions
71
tests/console/config/config_test.php
Normal file
71
tests/console/config/config_test.php
Normal file
|
@ -0,0 +1,71 @@
|
|||
<?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;
|
||||
|
||||
class phpbb_console_command_config_test extends phpbb_test_case
|
||||
{
|
||||
protected $config;
|
||||
protected $command_name;
|
||||
protected $comand_namespace;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->config = new \phpbb\config\config(array());
|
||||
}
|
||||
|
||||
public function test_set_dynamic()
|
||||
{
|
||||
$this->assertEmpty($this->config);
|
||||
|
||||
$this->command_namespace = '\phpbb\console\command\config';
|
||||
$this->command_name = 'set';
|
||||
$command_tester = $this->get_command_tester();
|
||||
$command_tester->execute(array(
|
||||
'command' => $this->command_name,
|
||||
'key' => 'test_key',
|
||||
'value' => 'test_value',
|
||||
'--dynamic' => true,
|
||||
));
|
||||
|
||||
$this->assertSame($this->config['test_key'],'test_value');
|
||||
}
|
||||
|
||||
public function test_set_no_dynamic()
|
||||
{
|
||||
$this->assertEmpty($this->config);
|
||||
|
||||
$this->command_namespace = '\phpbb\console\command\config';
|
||||
$this->command_name = 'set';
|
||||
$command_tester = $this->get_command_tester();
|
||||
$command_tester->execute(array(
|
||||
'command' => $this->command_name,
|
||||
'key' => 'test_key',
|
||||
'value' => 'test_value',
|
||||
'--dynamic' => false,
|
||||
));
|
||||
|
||||
$this->assertSame($this->config['test_key'],'test_value');
|
||||
}
|
||||
|
||||
public function get_command_tester()
|
||||
{
|
||||
$command_complete_name = $this->command_namespace . '\\' . $this->command_name;
|
||||
$application = new Application();
|
||||
$application->add(new $command_complete_name($this->config));
|
||||
$command = $application->find('config:' . $this->command_name);
|
||||
$this->command_name = $command->getName();
|
||||
return new CommandTester($command);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue