@@ -50,12 +50,24 @@ public function testInvalidAutoloadFile(): void
50
50
51
51
public function testValidAutoloadFile (): void
52
52
{
53
+ $ originalDir = getcwd ();
54
+ if ($ originalDir === false ) {
55
+ throw new ShouldNotHappenException ();
56
+ }
57
+
53
58
$ autoloadFile = __DIR__ . DIRECTORY_SEPARATOR . 'data/autoload-file.php ' ;
54
59
55
- $ output = $ this ->runCommand (0 , ['--autoload-file ' => $ autoloadFile ]);
56
- $ this ->assertStringContainsString ('[OK] No errors ' , $ output );
57
- $ this ->assertStringNotContainsString (sprintf ('Autoload file "%s" not found. ' . PHP_EOL , $ autoloadFile ), $ output );
58
- $ this ->assertSame ('magic value ' , SOME_CONSTANT_IN_AUTOLOAD_FILE );
60
+ chdir (__DIR__ );
61
+
62
+ try {
63
+ $ output = $ this ->runCommand (0 , ['--autoload-file ' => $ autoloadFile ]);
64
+ $ this ->assertStringContainsString ('[OK] No errors ' , $ output );
65
+ $ this ->assertStringNotContainsString (sprintf ('Autoload file "%s" not found. ' . PHP_EOL , $ autoloadFile ), $ output );
66
+ $ this ->assertSame ('magic value ' , SOME_CONSTANT_IN_AUTOLOAD_FILE );
67
+ } catch (Throwable $ e ) {
68
+ chdir ($ originalDir );
69
+ throw $ e ;
70
+ }
59
71
}
60
72
61
73
/**
@@ -96,9 +108,10 @@ private function runCommand(int $expectedStatusCode, array $parameters = []): st
96
108
97
109
$ commandTester ->execute ([
98
110
'paths ' => [__DIR__ . DIRECTORY_SEPARATOR . 'test ' ],
99
- ] + $ parameters );
111
+ '--debug ' => true ,
112
+ ] + $ parameters , ['debug ' => true ]);
100
113
101
- $ this ->assertSame ($ expectedStatusCode , $ commandTester ->getStatusCode ());
114
+ $ this ->assertSame ($ expectedStatusCode , $ commandTester ->getStatusCode (), $ commandTester -> getDisplay () );
102
115
103
116
return $ commandTester ->getDisplay ();
104
117
}
0 commit comments