-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathIsVisibleTest.php
More file actions
129 lines (118 loc) · 2.77 KB
/
IsVisibleTest.php
File metadata and controls
129 lines (118 loc) · 2.77 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
/**
* Block::isVisible()のテスト
*
* @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('NetCommonsModelTestCase', 'NetCommons.TestSuite');
/**
* Block::isVisible()のテスト
*
* @author Shohei Nakajima <nakajimashouhei@gmail.com>
* @package NetCommons\Blocks\Test\Case\Model\Block
*/
class BlockIsVisibleTest extends NetCommonsModelTestCase {
/**
* Fixtures
*
* @var array
*/
public $fixtures = array(
'plugin.blocks.block',
'plugin.blocks.block_role_permission',
);
/**
* Plugin name
*
* @var string
*/
public $plugin = 'blocks';
/**
* Model name
*
* @var string
*/
protected $_modelName = 'Block';
/**
* Method name
*
* @var string
*/
protected $_methodName = 'isVisible';
/**
* ValidationErrorのDataProvider
*
* ### 戻り値
* - block ブロックデータ
* - expected 期待値
*
* @return array テストデータ
*/
public function dataProvider() {
return array(
// * 非公開
array(
'block' => array('Block' => array('public_type' => '0')),
'expected' => false
),
// * 公開
array(
'block' => array('Block' => array('public_type' => '1')),
'expected' => true
),
// * 期限付き公開(開始+終了が指定なし)
array(
'block' => array('Block' => array(
'public_type' => '2', 'publish_start' => null, 'publish_end' => null
)),
'expected' => true
),
// * 期限付き公開(開始<現在<終了)
array(
'block' => array('Block' => array(
'public_type' => '2', 'publish_start' => '2014-01-01 00:00:00', 'publish_end' => '2099-01-01 00:00:00'
)),
'expected' => true
),
// * 期限付き公開(未来)
array(
'block' => array('Block' => array(
'public_type' => '2', 'publish_start' => '2099-01-01 00:00:00', 'publish_end' => null
)),
'expected' => false
),
// * 期限付き公開(過去)
array(
'block' => array('Block' => array(
'public_type' => '2', 'publish_start' => null, 'publish_end' => '2014-01-01 00:00:00'
)),
'expected' => false
),
// * 不正
array(
'block' => array('Block' => array('public_type' => '3')),
'expected' => false
),
);
}
/**
* isVisible()のテスト
*
* @param array $block ブロックデータ
* @param bool $expected 期待値
* @dataProvider dataProvider
* @return void
*/
public function testIsVisible($block, $expected) {
$model = $this->_modelName;
$methodName = $this->_methodName;
//テスト実施
$result = $this->$model->$methodName($block);
//チェック
$this->assertEquals($expected, $result);
}
}