-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathNetCommonsTimeHelperTest.php
More file actions
67 lines (58 loc) · 1.62 KB
/
NetCommonsTimeHelperTest.php
File metadata and controls
67 lines (58 loc) · 1.62 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
<?php
/**
* NetCommonsTimeHelper Test Case
*
* @author Ryuji AMANO <ryuji@ryus.co.jp>
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
*/
App::uses('View', 'View');
App::uses('Helper', 'View');
App::uses('NetCommonsTimeHelper', 'NetCommons.View/Helper');
/**
* Summary for NetCommonsTimeHelper Test Case
*/
class NetCommonsTimeHelperTest extends CakeTestCase {
/**
* setUp method
*
* @return void
*/
public function setUp() {
parent::setUp();
$View = new View();
$this->NetCommonsTime = new NetCommonsTimeHelper($View);
Configure::write('Config.language', 'ja');
Current::$current['Language']['id'] = 2; // ja
}
/**
* tearDown method
*
* @return void
*/
public function tearDown() {
unset($this->NetCommonsTime);
parent::tearDown();
}
/**
* NetCommonsTimeHelperでNetCommonsTimeをwrapできてるかのテスト
*
* @return void
*/
public function testWrapMethods() {
$methods = [
'toUserDatetime',
'toServerDatetime',
];
// NetCommonsTimeHelperで使うNetCommonsTimeをモックにさしかえる
$netCommonsTimeMock = $this->getMock('NetCommonsTime', $methods);
$property = new ReflectionProperty($this->NetCommonsTime, '_netCommonsTime');
$property->setAccessible(true);
$property->setValue($this->NetCommonsTime, $netCommonsTimeMock);
// NetCommonsTimeMockで同じ名前のメソッドが呼び出されているかテスト
foreach ($methods as $method) {
$netCommonsTimeMock->expects($this->at(0))->method($method);
$this->NetCommonsTime->{$method}('who', 'what', 'when', 'where', 'how');
}
}
}