10
10
use WordPress \Blueprints \Runner \Step \RmStepRunner ;
11
11
use WordPress \Blueprints \Runtime \Runtime ;
12
12
13
- class RmStepRunnerTest extends PHPUnitTestCase
14
- {
13
+ class RmStepRunnerTest extends PHPUnitTestCase {
15
14
/**
16
15
* @var string
17
16
*/
18
- private $ documentRoot ;
17
+ private $ document_root ;
19
18
20
19
/**
21
20
* @var Runtime
@@ -25,151 +24,140 @@ class RmStepRunnerTest extends PHPUnitTestCase
25
24
/**
26
25
* @var RmStepRunner
27
26
*/
28
- private $ step ;
27
+ private $ step_runner ;
29
28
30
29
/**
31
30
* @var Filesystem
32
31
*/
33
- private $ fileSystem ;
32
+ private $ filesystem ;
34
33
35
34
/**
36
35
* @before
37
36
*/
38
- public function before ()
39
- {
40
- $ this ->documentRoot = Path::makeAbsolute ("test " , sys_get_temp_dir ());
41
- $ this ->runtime = new Runtime ($ this ->documentRoot );
37
+ public function before () {
38
+ $ this ->document_root = Path::makeAbsolute ( "test " , sys_get_temp_dir () );
39
+ $ this ->runtime = new Runtime ( $ this ->document_root );
42
40
43
- $ this ->step = new RmStepRunner ();
44
- $ this ->step ->setRuntime ($ this ->runtime );
41
+ $ this ->step_runner = new RmStepRunner ();
42
+ $ this ->step_runner ->setRuntime ( $ this ->runtime );
45
43
46
- $ this ->fileSystem = new Filesystem ();
44
+ $ this ->filesystem = new Filesystem ();
47
45
}
48
46
49
47
/**
50
48
* @after
51
49
*/
52
- public function after ()
53
- {
54
- $ this ->fileSystem ->remove ($ this ->documentRoot );
50
+ public function after () {
51
+ $ this ->filesystem ->remove ( $ this ->document_root );
55
52
}
56
53
57
- public function testRemoveDirectoryWhenUsingAbsolutePath ()
58
- {
59
- $ absolutePath = $ this ->runtime ->resolvePath ("dir " );
60
- $ this ->fileSystem ->mkdir ($ absolutePath );
54
+ public function testRemoveDirectoryWhenUsingAbsolutePath () {
55
+ $ absolute_path = $ this ->runtime ->resolvePath ( "dir " );
56
+ $ this ->filesystem ->mkdir ( $ absolute_path );
61
57
62
- $ input = new RmStep ();
63
- $ input ->path = $ absolutePath ;
58
+ $ step = new RmStep ();
59
+ $ step ->path = $ absolute_path ;
64
60
65
- $ this ->step ->run ($ input );
61
+ $ this ->step_runner ->run ( $ step );
66
62
67
- $ this -> assertDirectoryDoesNotExist ($ absolutePath );
63
+ self :: assertDirectoryDoesNotExist ( $ absolute_path );
68
64
}
69
65
70
- public function testRemoveDirectoryWhenUsingRelativePath ()
71
- {
72
- $ relativePath = "dir " ;
73
- $ absolutePath = $ this ->runtime ->resolvePath ($ relativePath );
74
- $ this ->fileSystem ->mkdir ($ absolutePath );
66
+ public function testRemoveDirectoryWhenUsingRelativePath () {
67
+ $ relative_path = "dir " ;
68
+ $ absolute_path = $ this ->runtime ->resolvePath ( $ relative_path );
69
+ $ this ->filesystem ->mkdir ( $ absolute_path );
75
70
76
- $ input = new RmStep ();
77
- $ input ->path = $ relativePath ;
71
+ $ step = new RmStep ();
72
+ $ step ->path = $ relative_path ;
78
73
79
- $ this ->step ->run ($ input );
74
+ $ this ->step_runner ->run ( $ step );
80
75
81
- $ this -> assertDirectoryDoesNotExist ($ absolutePath );
76
+ self :: assertDirectoryDoesNotExist ( $ absolute_path );
82
77
}
83
78
84
- public function testRemoveDirectoryWithSubdirectory ()
85
- {
86
- $ relativePath = "dir/subdir " ;
87
- $ absolutePath = $ this ->runtime ->resolvePath ($ relativePath );
88
- $ this ->fileSystem ->mkdir ($ absolutePath );
79
+ public function testRemoveDirectoryWithSubdirectory () {
80
+ $ relative_path = "dir/subdir " ;
81
+ $ absolute_path = $ this ->runtime ->resolvePath ( $ relative_path );
82
+ $ this ->filesystem ->mkdir ( $ absolute_path );
89
83
90
- $ input = new RmStep ();
91
- $ input ->path = dirname ($ relativePath );
84
+ $ step = new RmStep ();
85
+ $ step ->path = dirname ( $ relative_path );
92
86
93
- $ this ->step ->run ($ input );
87
+ $ this ->step_runner ->run ( $ step );
94
88
95
- $ this -> assertDirectoryDoesNotExist ($ absolutePath );
89
+ self :: assertDirectoryDoesNotExist ( $ absolute_path );
96
90
}
97
91
98
- public function testRemoveDirectoryWithFile ()
99
- {
100
- $ relativePath = "dir/file.txt " ;
101
- $ absolutePath = $ this ->runtime ->resolvePath ($ relativePath );
102
- $ this ->fileSystem ->dumpFile ($ absolutePath , "test " );
92
+ public function testRemoveDirectoryWithFile () {
93
+ $ relative_path = "dir/file.txt " ;
94
+ $ absolute_pPath = $ this ->runtime ->resolvePath ( $ relative_path );
95
+ $ this ->filesystem ->dumpFile ( $ absolute_pPath , "test " );
103
96
104
- $ input = new RmStep ();
105
- $ input ->path = dirname ($ relativePath );
97
+ $ step = new RmStep ();
98
+ $ step ->path = dirname ( $ relative_path );
106
99
107
- $ this ->step ->run ($ input );
100
+ $ this ->step_runner ->run ( $ step );
108
101
109
- $ this -> assertDirectoryDoesNotExist (dirname ($ absolutePath ) );
102
+ self :: assertDirectoryDoesNotExist ( dirname ( $ absolute_pPath ) );
110
103
}
111
104
112
- public function testRemoveFile ()
113
- {
114
- $ relativePath = "file.txt " ;
115
- $ absolutePath = $ this ->runtime ->resolvePath ($ relativePath );
116
- $ this ->fileSystem ->dumpFile ($ absolutePath , "test " );
105
+ public function testRemoveFile () {
106
+ $ relative_path = "file.txt " ;
107
+ $ absolute_path = $ this ->runtime ->resolvePath ( $ relative_path );
108
+ $ this ->filesystem ->dumpFile ( $ absolute_path , "test " );
117
109
118
- $ input = new RmStep ();
119
- $ input ->path = $ relativePath ;
110
+ $ step = new RmStep ();
111
+ $ step ->path = $ relative_path ;
120
112
121
- $ this ->step ->run ($ input );
113
+ $ this ->step_runner ->run ( $ step );
122
114
123
- $ this -> assertDirectoryDoesNotExist ($ absolutePath );
115
+ self :: assertDirectoryDoesNotExist ( $ absolute_path );
124
116
}
125
117
126
- public function testThrowExceptionWhenRemovingNonexistentDirectoryAndUsingRelativePath ()
127
- {
128
- $ relativePath = "dir " ;
129
- $ absolutePath = $ this ->runtime ->resolvePath ($ relativePath );
118
+ public function testThrowExceptionWhenRemovingNonexistentDirectoryAndUsingRelativePath () {
119
+ $ relative_path = "dir " ;
120
+ $ absolute_path = $ this ->runtime ->resolvePath ( $ relative_path );
130
121
131
- $ input = new RmStep ();
132
- $ input ->path = $ relativePath ;
122
+ $ step = new RmStep ();
123
+ $ step ->path = $ relative_path ;
133
124
134
- $ this -> expectException (BlueprintException::class);
135
- $ this -> expectExceptionMessage ("Failed to remove \"$ absolutePath \": the directory or file does not exist. " );
136
- $ this ->step ->run ($ input );
125
+ self :: expectException ( BlueprintException::class );
126
+ self :: expectExceptionMessage ( "Failed to remove \"$ absolute_path \": the directory or file does not exist. " );
127
+ $ this ->step_runner ->run ( $ step );
137
128
}
138
129
139
- public function testThrowExceptionWhenRemovingNonexistentDirectoryAndUsingAbsolutePath ()
140
- {
141
- $ absolutePath = "/dir " ;
130
+ public function testThrowExceptionWhenRemovingNonexistentDirectoryAndUsingAbsolutePath () {
131
+ $ absolute_path = "/dir " ;
142
132
143
- $ input = new RmStep ();
144
- $ input ->path = $ absolutePath ;
133
+ $ step = new RmStep ();
134
+ $ step ->path = $ absolute_path ;
145
135
146
- $ this -> expectException (BlueprintException::class);
147
- $ this -> expectExceptionMessage ("Failed to remove \"$ absolutePath \": the directory or file does not exist. " );
148
- $ this ->step ->run ($ input );
136
+ self :: expectException ( BlueprintException::class );
137
+ self :: expectExceptionMessage ( "Failed to remove \"$ absolute_path \": the directory or file does not exist. " );
138
+ $ this ->step_runner ->run ( $ step );
149
139
}
150
140
151
- public function testThrowExceptionWhenRemovingNonexistentFileAndUsingAbsolutePath ()
152
- {
153
- $ relativePath = "/file.txt " ;
141
+ public function testThrowExceptionWhenRemovingNonexistentFileAndUsingAbsolutePath () {
142
+ $ relative_path = "/file.txt " ;
154
143
155
- $ input = new RmStep ();
156
- $ input ->path = $ relativePath ;
144
+ $ step = new RmStep ();
145
+ $ step ->path = $ relative_path ;
157
146
158
- $ this -> expectException (BlueprintException::class);
159
- $ this -> expectExceptionMessage ("Failed to remove \"$ relativePath \": the directory or file does not exist. " );
160
- $ this ->step ->run ($ input );
147
+ self :: expectException ( BlueprintException::class );
148
+ self :: expectExceptionMessage ( "Failed to remove \"$ relative_path \": the directory or file does not exist. " );
149
+ $ this ->step_runner ->run ( $ step );
161
150
}
162
151
163
- public function testThrowExceptionWhenRemovingNonexistentFileAndUsingRelativePath ()
164
- {
152
+ public function testThrowExceptionWhenRemovingNonexistentFileAndUsingRelativePath () {
165
153
$ relativePath = "file.txt " ;
166
154
$ absolutePath = $ this ->runtime ->resolvePath ($ relativePath );
167
155
168
- $ input = new RmStep ();
169
- $ input ->path = $ relativePath ;
156
+ $ step = new RmStep ();
157
+ $ step ->path = $ relativePath ;
170
158
171
- $ this -> expectException (BlueprintException::class);
172
- $ this -> expectExceptionMessage ("Failed to remove \"$ absolutePath \": the directory or file does not exist. " );
173
- $ this ->step ->run ($ input );
159
+ self :: expectException ( BlueprintException::class );
160
+ self :: expectExceptionMessage ( "Failed to remove \"$ absolutePath \": the directory or file does not exist. " );
161
+ $ this ->step_runner ->run ( $ step );
174
162
}
175
163
}
0 commit comments