Skip to content

Commit

Permalink
Added exception stack trace test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilge committed Aug 16, 2017
1 parent d134cc1 commit df2b810
Show file tree
Hide file tree
Showing 13 changed files with 172 additions and 111 deletions.
2 changes: 1 addition & 1 deletion test/NestedStackTraceException.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace ScriptFUSIONTest\PHPUnitImmediateExceptionPrinter;

class NestedStackTraceException extends StackTraceException
final class NestedStackTraceException extends StackTraceException
{
// Intentionally empty.
}
4 changes: 2 additions & 2 deletions test/functional/data provider.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ PHPUnit runner.php
--EXPECTF--
PHPUnit %s

50% . [32;1mScriptFUSIONTest\PHPUnitImmediateExceptionPrinter\CapabilitiesTest::testDataProvider with data set "foo" ('bar')[0m[32m (%i ms)[0m
100% . [32;1mScriptFUSIONTest\PHPUnitImmediateExceptionPrinter\CapabilitiesTest::testDataProvider with data set "baz" ('qux')[0m[32m (%i ms)[0m
50% . [32;1mScriptFUSIONTest\PHPUnitImmediateExceptionPrinter\CapabilitiesTest::testDataProvider with data set "foo" ('bar')[0m[32m (%d ms)[0m
100% . [32;1mScriptFUSIONTest\PHPUnitImmediateExceptionPrinter\CapabilitiesTest::testDataProvider with data set "baz" ('qux')[0m[32m (%d ms)[0m


Time: %s
Expand Down
6 changes: 3 additions & 3 deletions test/functional/diff failure.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ PHPUnit runner.php
--EXPECTF--
PHPUnit %s

100% [31;1mF[0m [31;1mScriptFUSIONTest\PHPUnitImmediateExceptionPrinter\CapabilitiesTest::testDiffFailure[0m[32m (%i ms)[0m
100% [31;1mF[0m [31;1mScriptFUSIONTest\PHPUnitImmediateExceptionPrinter\CapabilitiesTest::testDiffFailure[0m[32m (%d ms)[0m

Failed asserting that two strings are identical.
--- Expected
Expand All @@ -19,7 +19,7 @@ PHPUnit %s
-%Sfoo%S
+%SLogicException: foo%S

[31m%s%eCapabilitiesTest.php:%i[0m
[31m%s%eCapabilitiesTest.php:%d[0m



Expand All @@ -35,7 +35,7 @@ Failed asserting that two strings are identical.
-%Sfoo%S
+%SLogicException: foo%S

%s%eCapabilitiesTest.php:%i
%s%eCapabilitiesTest.php:%d

FAILURES!
Tests: 1, Assertions: 1, Failures: 1.
61 changes: 61 additions & 0 deletions test/functional/exception stack trace.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
--TEST--
An exception message containing its own stack trace is formatted correctly.

--ARGS--
-c test --colors=always test/CapabilitiesTest --filter ::testExceptionStackTrace$

--FILE_EXTERNAL--
PHPUnit runner.php

--EXPECTF--
PHPUnit %s

100% E ScriptFUSIONTest\PHPUnitImmediateExceptionPrinter\CapabilitiesTest::testExceptionStackTrace (%d ms)

 
 ScriptFUSIONTest\PHPUnitImmediateExceptionPrinter\StackTraceException  %s in %s%eCapabilitiesTest.php:25
 
Stack trace:
#0 [internal function]: ScriptFUSIONTest\PHPUnitImmediateExceptionPrinter\CapabilitiesTest->testExceptionStackTrace()
%a
#%d {main}

%s%eCapabilitiesTest.php:25

Caused by
 
 ScriptFUSIONTest\PHPUnitImmediateExceptionPrinter\NestedStackTraceException  %s in %s%eCapabilitiesTest.php:%d
 
Stack trace:
#0 [internal function]: ScriptFUSIONTest\PHPUnitImmediateExceptionPrinter\CapabilitiesTest->testExceptionStackTrace()
%a
#%d {main}

%s%eCapabilitiesTest.php:%d



Time: %s

There was 1 error:

1) ScriptFUSIONTest\PHPUnitImmediateExceptionPrinter\CapabilitiesTest::testExceptionStackTrace
ScriptFUSIONTest\PHPUnitImmediateExceptionPrinter\StackTraceException: %s in %s%eCapabilitiesTest.php:%d
Stack trace:
#0 [internal function]: ScriptFUSIONTest\PHPUnitImmediateExceptionPrinter\CapabilitiesTest->testExceptionStackTrace()
%a
#%d {main}

%s%eCapabilitiesTest.php:25

Caused by
ScriptFUSIONTest\PHPUnitImmediateExceptionPrinter\NestedStackTraceException: %s in %s%eCapabilitiesTest.php:%d
Stack trace:
#0 [internal function]: ScriptFUSIONTest\PHPUnitImmediateExceptionPrinter\CapabilitiesTest->testExceptionStackTrace()
%a
#%d {main}

%s%eCapabilitiesTest.php:25

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
6 changes: 3 additions & 3 deletions test/functional/exception.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ PHPUnit runner.php
--EXPECTF--
PHPUnit %s

100% [31;1mE[0m [31;1mScriptFUSIONTest\PHPUnitImmediateExceptionPrinter\CapabilitiesTest::testException[0m[32m (%i ms)[0m
100% [31;1mE[0m [31;1mScriptFUSIONTest\PHPUnitImmediateExceptionPrinter\CapabilitiesTest::testException[0m[32m (%d ms)[0m

 
 LogicException  foo
 

[31m%s%eCapabilitiesTest.php:%i[0m
[31m%s%eCapabilitiesTest.php:%d[0m



Expand All @@ -27,7 +27,7 @@ There was 1 error:
1) ScriptFUSIONTest\PHPUnitImmediateExceptionPrinter\CapabilitiesTest::testException
LogicException: foo

%s%eCapabilitiesTest.php:%i
%s%eCapabilitiesTest.php:%d

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
6 changes: 3 additions & 3 deletions test/functional/failure.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ PHPUnit runner.php
--EXPECTF--
PHPUnit %s

100% [31;1mF[0m [31;1mScriptFUSIONTest\PHPUnitImmediateExceptionPrinter\CapabilitiesTest::testFailure[0m[32m (%i ms)[0m
100% [31;1mF[0m [31;1mScriptFUSIONTest\PHPUnitImmediateExceptionPrinter\CapabilitiesTest::testFailure[0m[32m (%d ms)[0m

Failed asserting that false is true.

[31m%s%eCapabilitiesTest.php:%i[0m
[31m%s%eCapabilitiesTest.php:%d[0m



Expand All @@ -25,7 +25,7 @@ There was 1 failure:
1) ScriptFUSIONTest\PHPUnitImmediateExceptionPrinter\CapabilitiesTest::testFailure
Failed asserting that false is true.

%s%eCapabilitiesTest.php:%i
%s%eCapabilitiesTest.php:%d

FAILURES!
Tests: 1, Assertions: 1, Failures: 1.
2 changes: 1 addition & 1 deletion test/functional/incomplete.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ PHPUnit runner.php
--EXPECTF--
PHPUnit %s

100% [33;1mI[0m [33;1mScriptFUSIONTest\PHPUnitImmediateExceptionPrinter\CapabilitiesTest::testIncomplete[0m[32m (%i ms)[0m
100% [33;1mI[0m [33;1mScriptFUSIONTest\PHPUnitImmediateExceptionPrinter\CapabilitiesTest::testIncomplete[0m[32m (%d ms)[0m


Time: %s
Expand Down
18 changes: 9 additions & 9 deletions test/functional/nested exception.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ PHPUnit runner.php
--EXPECTF--
PHPUnit %s

100% [31;1mE[0m [31;1mScriptFUSIONTest\PHPUnitImmediateExceptionPrinter\CapabilitiesTest::testNestedException[0m[32m (%i ms)[0m
100% [31;1mE[0m [31;1mScriptFUSIONTest\PHPUnitImmediateExceptionPrinter\CapabilitiesTest::testNestedException[0m[32m (%d ms)[0m

 
 LogicException  foo
 

[31m%s%eExceptionThrower.php:%i[0m
[31m%s%eCapabilitiesTest.php:%i[0m
[31m%s%eExceptionThrower.php:%d[0m
[31m%s%eCapabilitiesTest.php:%d[0m

Caused by
 
 RuntimeException  bar
 

[31m%s%eExceptionThrower.php:%i[0m
[31m%s%eCapabilitiesTest.php:%i[0m
[31m%s%eExceptionThrower.php:%d[0m
[31m%s%eCapabilitiesTest.php:%d[0m



Expand All @@ -36,14 +36,14 @@ There was 1 error:
1) ScriptFUSIONTest\PHPUnitImmediateExceptionPrinter\CapabilitiesTest::testNestedException
LogicException: foo

%s%eExceptionThrower.php:%i
%s%eCapabilitiesTest.php:%i
%s%eExceptionThrower.php:%d
%s%eCapabilitiesTest.php:%d

Caused by
RuntimeException: bar

%s%eExceptionThrower.php:%i
%s%eCapabilitiesTest.php:%i
%s%eExceptionThrower.php:%d
%s%eCapabilitiesTest.php:%d

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
Loading

0 comments on commit df2b810

Please sign in to comment.