@@ -17,9 +17,9 @@ class ScriptHandlerTest extends IntegrationTestSuite
17
17
*
18
18
* @expectedException \InvalidArgumentException
19
19
*/
20
- function validateConfigurationExpectedExceptionOnNotExistingKey ()
20
+ public function validateConfigurationExpectedExceptionOnNotExistingKey ()
21
21
{
22
- $ this ->invokeMethod ( new ScriptHandler (), ' validateConfiguration ' , [[] ]);
22
+ $ this ->validateConfiguration ([ ]);
23
23
}
24
24
25
25
/**
@@ -28,9 +28,9 @@ function validateConfigurationExpectedExceptionOnNotExistingKey()
28
28
*
29
29
* @expectedException \InvalidArgumentException
30
30
*/
31
- function validateConfigurationExpectedExceptionOnEmpty ()
31
+ public function validateConfigurationExpectedExceptionOnEmpty ()
32
32
{
33
- $ this ->invokeMethod ( new ScriptHandler (), ' validateConfiguration ' , [[ ScriptHandler::CONFIG_MAIN_KEY ] ]);
33
+ $ this ->validateConfiguration ([ ScriptHandler::CONFIG_MAIN_KEY => '' ]);
34
34
}
35
35
36
36
/**
@@ -39,9 +39,9 @@ function validateConfigurationExpectedExceptionOnEmpty()
39
39
*
40
40
* @expectedException \InvalidArgumentException
41
41
*/
42
- function validateConfigurationExpectedExceptionOnNotArray ()
42
+ public function validateConfigurationExpectedExceptionOnNotArray ()
43
43
{
44
- $ this ->invokeMethod ( new ScriptHandler (), ' validateConfiguration ' , [[ ScriptHandler::CONFIG_MAIN_KEY => 'string ' ] ]);
44
+ $ this ->validateConfiguration ([ ScriptHandler::CONFIG_MAIN_KEY => 'string ' ]);
45
45
}
46
46
47
47
/**
@@ -50,44 +50,40 @@ function validateConfigurationExpectedExceptionOnNotArray()
50
50
*
51
51
* @expectedException \InvalidArgumentException
52
52
*/
53
- function validateConfigurationExpectedExceptionOptionIsNotArray ()
53
+ public function validateConfigurationExpectedExceptionOptionIsNotArray ()
54
54
{
55
- $ arr = [
56
- ScriptHandler::CONFIG_MAIN_KEY => [
57
- 'string '
58
- ]
59
- ];
60
- $ this ->invokeMethod (new ScriptHandler (), 'validateConfiguration ' , [$ arr ]);
55
+ $ this ->validateConfiguration ([ScriptHandler::CONFIG_MAIN_KEY => ['string ' ]]);
61
56
}
62
57
63
58
/**
64
59
* @see ScriptHandler::validateConfiguration
65
60
* @test
66
61
*/
67
- function validateConfigurationOnValid ()
62
+ public function validateConfigurationOnValid ()
68
63
{
69
- $ arr = [
64
+ $ args = [
70
65
ScriptHandler::CONFIG_MAIN_KEY => [
71
- [
72
- ScriptHandler::OPTION_KEY_INPUT => ['string ' ],
73
- ScriptHandler::OPTION_KEY_OUTPUT => 'string '
74
- ]
66
+ [ScriptHandler::OPTION_KEY_INPUT => ['string ' ], ScriptHandler::OPTION_KEY_OUTPUT => 'string ' ]
75
67
]
76
68
];
77
- $ result = $ this -> invokeMethod ( new ScriptHandler (), ' validateConfiguration ' , [ $ arr ]);
78
- $ this ->assertTrue ($ result );
69
+
70
+ $ this ->assertTrue ($ this -> validateConfiguration ( $ args ) );
79
71
}
80
72
73
+ private function validateConfiguration ($ args )
74
+ {
75
+ return $ this ->invokeMethod (new ScriptHandler (), 'validateConfiguration ' , [$ args ]);
76
+ }
81
77
/*** *************************** OPTIONS VALIDATION *************************** ***/
82
78
/**
83
79
* @see ScriptHandler::validateOptions
84
80
* @test
85
81
*
86
82
* @expectedException \InvalidArgumentException
87
83
*/
88
- function validateOptionsExpectedExceptionOnMissingInput ()
84
+ public function validateOptionsExpectedExceptionOnMissingInput ()
89
85
{
90
- $ this ->invokeMethod ( new ScriptHandler (), ' validateOptions ' , [[ScriptHandler::OPTION_KEY_OUTPUT ]]);
86
+ $ this ->validateOptions ( [[ScriptHandler::OPTION_KEY_OUTPUT => ' output ' ]]);
91
87
}
92
88
93
89
/**
@@ -96,9 +92,9 @@ function validateOptionsExpectedExceptionOnMissingInput()
96
92
*
97
93
* @expectedException \InvalidArgumentException
98
94
*/
99
- function validateOptionsExpectedExceptionOnMissingOutput ()
95
+ public function validateOptionsExpectedExceptionOnMissingOutput ()
100
96
{
101
- $ this ->invokeMethod ( new ScriptHandler (), ' validateOptions ' , [[ ScriptHandler::OPTION_KEY_INPUT ] ]);
97
+ $ this ->validateOptions ([ ScriptHandler::OPTION_KEY_INPUT => ' input ' ]);
102
98
}
103
99
104
100
/**
@@ -107,12 +103,12 @@ function validateOptionsExpectedExceptionOnMissingOutput()
107
103
*
108
104
* @expectedException \InvalidArgumentException
109
105
*/
110
- function validateOptionsExpectedExceptionOnInputNotArray ()
106
+ public function validateOptionsExpectedExceptionOnInputNotArray ()
111
107
{
112
- $ this ->invokeMethod ( new ScriptHandler (), ' validateOptions ' , [ [
108
+ $ this ->validateOptions ( [
113
109
ScriptHandler::OPTION_KEY_INPUT => 'string ' ,
114
110
ScriptHandler::OPTION_KEY_OUTPUT => 'string '
115
- ]] );
111
+ ]);
116
112
}
117
113
118
114
/**
@@ -121,25 +117,35 @@ function validateOptionsExpectedExceptionOnInputNotArray()
121
117
*
122
118
* @expectedException \InvalidArgumentException
123
119
*/
124
- function validateOptionsExpectedExceptionOnOutputNotString ()
120
+ public function validateOptionsExpectedExceptionOnOutputNotString ()
125
121
{
126
- $ this ->invokeMethod ( new ScriptHandler (), ' validateOptions ' , [ [
122
+ $ this ->validateOptions ( [
127
123
ScriptHandler::OPTION_KEY_INPUT => ['string ' ],
128
124
ScriptHandler::OPTION_KEY_OUTPUT => ['string ' ]
129
- ]] );
125
+ ]);
130
126
}
131
127
132
128
/**
133
129
* @see ScriptHandler::validateOptions
134
130
* @test
135
131
*/
136
- function validateOptionsOnValid ()
132
+ public function validateOptionsOnValid ()
137
133
{
138
- $ options = [
139
- [ScriptHandler::OPTION_KEY_INPUT => ['string ' ], ScriptHandler::OPTION_KEY_OUTPUT => 'string ' ]
140
- ];
141
- $ result = $ this ->invokeMethod (new ScriptHandler (), 'validateOptions ' , [$ options ]);
134
+ $ this ->assertTrue (
135
+ $ this ->validateOptions ([
136
+ ScriptHandler::OPTION_KEY_INPUT => ['string ' ],
137
+ ScriptHandler::OPTION_KEY_OUTPUT => 'string '
138
+ ])
139
+ );
140
+ }
142
141
143
- $ this ->assertTrue ($ result );
142
+ /**
143
+ * @param array $config
144
+ *
145
+ * @return bool
146
+ */
147
+ private function validateOptions ($ config )
148
+ {
149
+ return $ this ->invokeMethod (new ScriptHandler (), 'validateOptions ' , [[$ config ]]);
144
150
}
145
151
}
0 commit comments