-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGetOptionParserTest.php
More file actions
78 lines (67 loc) · 1.84 KB
/
GetOptionParserTest.php
File metadata and controls
78 lines (67 loc) · 1.84 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
<?php
/**
* UsersShell::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');
/**
* UsersShell::getOptionParser()のテスト
*
* @author Shohei Nakajima <nakajimashouhei@gmail.com>
* @package NetCommons\Users\Test\Case\Console\Command\UsersShell
*/
class UsersConsoleCommandUsersShellGetOptionParserTest extends NetCommonsConsoleTestCase {
/**
* Fixtures
*
* @var array
*/
public $fixtures = array();
/**
* Plugin name
*
* @var string
*/
public $plugin = 'users';
/**
* Shell name
*
* @var string
*/
protected $_shellName = 'UsersShell';
/**
* getOptionParser()のテスト
*
* @return void
*/
public function testGetOptionParser() {
$shell = $this->_shellName;
$this->$shell = $this->loadShell($shell);
//事前準備
$task = 'UserImport';
$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(
'user_import' => __d('user_manager', 'Import description'),
);
foreach ($subCommands as $subCommand => $helpMessage) {
$expected[] = $subCommand . ' ' . $helpMessage;
$actual[] = $result->subcommands()[$subCommand]->help(strlen($subCommand) + 1);
}
$this->assertEquals($expected, $actual);
}
}