@@ -7,19 +7,6 @@ function removeTrailingSpaces(string $output): string
77 return preg_replace ("/ * \n/ " , "\n" , $ output );
88}
99
10- function whenExecutePhpFileWillHaveStatusCodeAndOutput ($ harness , $ test , $ name , $ expectedStatusCode , $ expectedOutput )
11- {
12- $ test ->diag ($ name );
13-
14- ob_start ();
15- $ exitCode = (new lime_harness ())->executePhpFile (__DIR__ .'/fixtures/ ' .$ name .'.php ' );
16- $ output = ob_get_clean ();
17-
18- $ test ->is ($ exitCode , $ expectedStatusCode , 'with test ' .$ name .' will exit with status code ' .$ expectedStatusCode );
19-
20- $ test ->is (removeTrailingSpaces ($ output ), $ expectedOutput , 'test ' .$ name .' output ' );
21- }
22-
2310function whenExecuteHarnessWithFilesWillHaveResultAndOutput ($ test , $ files , $ expectedOverallSucceed , $ expectedOutput , $ message )
2411{
2512 $ harness = new lime_harness ();
@@ -33,7 +20,7 @@ function whenExecuteHarnessWithFilesWillHaveResultAndOutput($test, $files, $expe
3320
3421 $ test ->is ($ expectedOverallSucceed , $ allTestsSucceed , $ message );
3522
36- $ test ->is (removeTrailingSpaces ($ output ), $ expectedOutput , 'test harness result ' );
23+ $ test ->is (removeTrailingSpaces ($ output ), $ expectedOutput , 'test harness result output ' );
3724}
3825
3926class lime_no_colorizer extends lime_colorizer
@@ -43,7 +30,7 @@ public function __construct()
4330 }
4431}
4532
46- $ test = new lime_test (22 );
33+ $ test = new lime_test (12 );
4734
4835$ files = [
4936 __DIR__ .'/fixtures/failed.php ' ,
@@ -83,6 +70,7 @@ public function __construct()
8370$ message = 'with at least one failed test file will fail the overall test suite ' ;
8471whenExecuteHarnessWithFilesWillHaveResultAndOutput ($ test , $ files , $ expectedOverallSucceed , $ expectedOutput , $ message );
8572
73+
8674$ files = [__DIR__ .'/fixtures/pass_with_plan_less_than_total.php ' ];
8775$ expectedOverallSucceed = false ;
8876$ expectedOutput = <<<'EOF'
@@ -98,12 +86,13 @@ public function __construct()
9886$ message = 'with at least one test file that not follow the plan will fail the overall test suite ' ;
9987whenExecuteHarnessWithFilesWillHaveResultAndOutput ($ test , $ files , $ expectedOverallSucceed , $ expectedOutput , $ message );
10088
89+
10190$ files = [__DIR__ .'/fixtures/pass_with_one_error.php ' ];
10291$ expectedOverallSucceed = false ;
10392$ expectedOutput = <<<'EOF'
10493test/unit/vendor/lime/fixtures/pass_with_one_error...................errors
10594 Errors:
106- - Notice: some use error message
95+ - Notice: some user error message
10796Failed Test Stat Total Fail Errors List of Failed
10897--------------------------------------------------------------------------
10998e/fixtures/pass_with_one_error 1 1 0 1
@@ -113,6 +102,7 @@ public function __construct()
113102$ message = 'with at least one error will fail the overall test suite ' ;
114103whenExecuteHarnessWithFilesWillHaveResultAndOutput ($ test , $ files , $ expectedOverallSucceed , $ expectedOutput , $ message );
115104
105+
116106$ files = [__DIR__ .'/fixtures/pass_with_one_throw_exception.php ' ];
117107$ expectedOverallSucceed = false ;
118108$ expectedOutput = <<<'EOF'
@@ -128,6 +118,7 @@ public function __construct()
128118$ message = 'with at least one thrown Exception will fail the overall test suite ' ;
129119whenExecuteHarnessWithFilesWillHaveResultAndOutput ($ test , $ files , $ expectedOverallSucceed , $ expectedOutput , $ message );
130120
121+
131122$ files = [__DIR__ .'/fixtures/pass.php ' ];
132123$ expectedOverallSucceed = true ;
133124$ expectedOutput = <<<'EOF'
@@ -136,78 +127,21 @@ public function __construct()
136127 Files=1, Tests=1
137128
138129EOF;
139- $ message = 'with all tests passes without error or exception will succeed the overall test suite ' ;
130+ $ message = 'with all tests passes without error and exception will succeed the overall test suite ' ;
140131whenExecuteHarnessWithFilesWillHaveResultAndOutput ($ test , $ files , $ expectedOverallSucceed , $ expectedOutput , $ message );
141132
142- $ name = 'pass ' ;
143- $ expectedStatusCode = 0 ;
144- $ expectedOutput = <<<'EOF'
145- ok 1
146- 1..1
147- # Looks like everything went fine.
148-
149- EOF;
150- whenExecutePhpFileWillHaveStatusCodeAndOutput ($ harness , $ test , $ name , $ expectedStatusCode , $ expectedOutput );
151-
152- $ name = 'failed ' ;
153- $ expectedStatusCode = 1 ;
154- $ expectedOutput = <<<'EOF'
155- not ok 1
156- # Failed test (./test/unit/vendor/lime/fixtures/failed.php at line 7)
157- # got: false
158- # expected: true
159- 1..1
160- # Looks like you failed 1 tests of 1.
161-
162- EOF;
163- whenExecutePhpFileWillHaveStatusCodeAndOutput ($ harness , $ test , $ name , $ expectedStatusCode , $ expectedOutput );
164133
165- $ name = 'failed_with_plan_less_than_total ' ;
166- $ expectedStatusCode = 1 ;
167- $ expectedOutput = <<<'EOF'
168- 1..1
169- not ok 1
170- # Failed test (./test/unit/vendor/lime/fixtures/failed_with_plan_less_than_total.php at line 7)
171- # got: false
172- # expected: true
173- ok 2
174- # Looks like you planned 1 tests but ran 1 extra.
175- # Looks like you failed 1 tests of 2.
176-
177- EOF;
178- whenExecutePhpFileWillHaveStatusCodeAndOutput ($ harness , $ test , $ name , $ expectedStatusCode , $ expectedOutput );
179-
180- $ name = 'failed_with_plan_more_than_total ' ;
181- $ expectedStatusCode = 1 ;
182- $ expectedOutput = <<<'EOF'
183- 1..2
184- not ok 1
185- # Failed test (./test/unit/vendor/lime/fixtures/failed_with_plan_more_than_total.php at line 7)
186- # got: false
187- # expected: true
188- # Looks like you planned 2 tests but only ran 1.
189- # Looks like you failed 1 tests of 1.
190-
191- EOF;
192- whenExecutePhpFileWillHaveStatusCodeAndOutput ($ harness , $ test , $ name , $ expectedStatusCode , $ expectedOutput );
193-
194- $ name = 'pass_with_plan_less_than_total ' ;
195- $ expectedStatusCode = 255 ;
196- $ expectedOutput = <<<'EOF'
197- 1..1
198- ok 1
199- ok 2
200- # Looks like you planned 1 tests but ran 1 extra.
201-
202- EOF;
203- whenExecutePhpFileWillHaveStatusCodeAndOutput ($ harness , $ test , $ name , $ expectedStatusCode , $ expectedOutput );
204-
205- $ name = 'pass_with_plan_more_than_total ' ;
206- $ expectedStatusCode = 255 ;
134+ $ files = [__DIR__ .'/fixtures/pass_with_one_parse_error.php ' ];
135+ $ expectedOverallSucceed = false ;
207136$ expectedOutput = <<<'EOF'
208- 1..2
209- ok 1
210- # Looks like you planned 2 tests but only ran 1.
137+ test/unit/vendor/lime/fixtures/pass_with_one_parse_error.............errors
138+ Errors:
139+ - Missing test report. It is probably due to a Parse error.
140+ Failed Test Stat Total Fail Errors List of Failed
141+ --------------------------------------------------------------------------
142+ ures/pass_with_one_parse_error 255 0 0 1
143+ Failed 1/1 test scripts, 0.00% okay. 0/0 subtests failed, 0.00% okay.
211144
212145EOF;
213- whenExecutePhpFileWillHaveStatusCodeAndOutput ($ harness , $ test , $ name , $ expectedStatusCode , $ expectedOutput );
146+ $ message = 'with parse error will fail the overall test suite ' ;
147+ whenExecuteHarnessWithFilesWillHaveResultAndOutput ($ test , $ files , $ expectedOverallSucceed , $ expectedOutput , $ message );
0 commit comments