-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathGetOptionParserTest.php
More file actions
100 lines (88 loc) · 2.68 KB
/
GetOptionParserTest.php
File metadata and controls
100 lines (88 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
/**
* InstallShell::getOptionParser()のテスト
*
* @author Noriko Arai <arai@nii.ac.jp>
* @author Shohei Nakajima <nakajimashouhei@gmail.com>
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
* @copyright Copyright 2014, NetCommons Project
*/
App::uses('NetCommonsConsoleTestCase', 'NetCommons.TestSuite');
/**
* InstallShell::getOptionParser()のテスト
*
* @author Shohei Nakajima <nakajimashouhei@gmail.com>
* @package NetCommons\Install\Test\Case\Console\Command\InstallShell
*/
class InstallConsoleCommandInstallShellGetOptionParserTest extends NetCommonsConsoleTestCase {
/**
* Fixture merge
*
* @var array
*/
protected $_isFixtureMerged = false;
/**
* Fixtures
*
* @var array
*/
public $fixtures = array();
/**
* Plugin name
*
* @var string
*/
public $plugin = 'install';
/**
* Shell name
*
* @var string
*/
protected $_shellName = 'InstallShell';
/**
* getOptionParser()のテスト
*
* @return void
*/
public function testGetOptionParser() {
$shell = $this->_shellName;
$this->$shell = $this->loadShell($shell, 'h');
//事前準備
$tasks = array(
'InstallStart', 'InstallPermission', 'CreateDatabase', 'InstallMigrations',
'InstallBower', 'SaveAdministrator', 'InstallFinish', 'CheckLibVersion',
'InstallSiteSetting', 'SaveInitData',
);
foreach ($tasks as $task) {
$this->$shell->$task = $this->getMock($task,
array('getOptionParser'), array(), '', false);
$this->$shell->$task->expects($this->once())->method('getOptionParser')
->will($this->returnValue(true));
}
//テスト実施
$result = $this->$shell->getOptionParser();
//チェック
$this->assertEquals('ConsoleOptionParser', get_class($result));
//サブタスクヘルプのチェック
$expected = array();
$actual = array();
$subCommands = array(
'install_start' => __d('install', 'Install Step 1'),
'check_lib_version' => __d('install', 'Install Step 2(1)'),
'install_permission' => __d('install', 'Install Step 2(2)'),
'create_database' => __d('install', 'Install Step 3'),
'install_migrations' => __d('install', 'Install Step 4'),
'install_bower' => __d('install', 'Install Step 5'),
'save_administrator' => __d('install', 'Install Step 6'),
'install_site_setting' => __d('install', 'Install Step 7'),
'save_init_data' => __d('install', 'Install Step 8'),
'install_finish' => __d('install', 'Install End')
);
foreach ($subCommands as $subCommand => $helpMessage) {
$expected[] = $subCommand . ' ' . $helpMessage;
$actual[] = $result->subcommands()[$subCommand]->help(strlen($subCommand) + 1);
}
$this->assertEquals($expected, $actual);
}
}