22
33declare (strict_types=1 );
44
5+ /*
6+ * This file is part of WickedOne\PHPUnitPrinter.
7+ *
8+ * (c) wicliff <wicliff.wolda@gmail.com>
9+ *
10+ * For the full copyright and license information, please view the LICENSE
11+ * file that was distributed with this source code.
12+ */
13+
514namespace WickedOne \PHPUnitPrinter \Tests ;
615
716use PHPUnit \Framework \AssertionFailedError ;
817use PHPUnit \Framework \ErrorTestCase ;
918use PHPUnit \Framework \TestCase ;
1019use PHPUnit \Framework \TestResult ;
20+ use PHPUnit \Framework \TestSuite ;
1121use WickedOne \PHPUnitPrinter \PhpStormPrinter ;
22+ use WickedOne \PHPUnitPrinter \Tests \Stub \EmptyTestClass ;
1223
1324/**
1425 * PhpStorm Printer Test.
1728 */
1829class PhpStormPrinterTest extends TestCase
1930{
20-
2131 /**
2232 * check for presence of editor url in output file
23- * and whether original messages are still printed
33+ * and whether original messages are still printed.
2434 */
2535 public function testPrintDefectFooter (): void
2636 {
@@ -30,10 +40,9 @@ public function testPrintDefectFooter(): void
3040
3141 $ result ->addFailure ($ test , $ throwable , time ());
3242
33- $ filename = sys_get_temp_dir () . '/phpunit-printer.txt ' ;
34- touch ($ filename );
43+ $ filename = sys_get_temp_dir ().'/phpunit-printer.txt ' ;
3544
36- $ printer = new PhpStormPrinter (fopen ($ filename , 'rb + ' ));
45+ $ printer = new PhpStormPrinter (fopen ($ filename , 'wb + ' ));
3746 $ printer ->printResult ($ result );
3847
3948 $ result = file_get_contents ($ filename );
@@ -45,4 +54,29 @@ public function testPrintDefectFooter(): void
4554
4655 @unlink ($ filename );
4756 }
57+
58+ /**
59+ * in some occasions no trace is provided.
60+ * make sure printing editor url isn't printed in those occasions.
61+ */
62+ public function testSkipDefectFooterOnWarning (): void
63+ {
64+ $ result = (new TestSuite (EmptyTestClass::class))->run ();
65+
66+ $ filename = sys_get_temp_dir ().'/phpunit-printer.txt ' ;
67+
68+ $ list = $ GLOBALS ['__PHPUNIT_ISOLATION_EXCLUDE_LIST ' ] ?? null ;
69+ $ GLOBALS ['__PHPUNIT_ISOLATION_EXCLUDE_LIST ' ] = [__FILE__ ];
70+
71+ $ printer = new PhpStormPrinter (fopen ($ filename , 'wb+ ' ));
72+ $ printer ->printResult ($ result );
73+
74+ $ GLOBALS ['__PHPUNIT_ISOLATION_EXCLUDE_LIST ' ] = $ list ;
75+
76+ $ result = file_get_contents ($ filename );
77+
78+ self ::assertStringNotContainsString ('phpstorm://open?file= ' , $ result );
79+
80+ @unlink ($ filename );
81+ }
4882}
0 commit comments