@@ -38,55 +38,44 @@ protected function setUp(): void
3838
3939 public function testDumpPages ()
4040 {
41- $ fs = new Filesystem ();
42- $ fs ->mkdir ($ this ->tmpDir );
43- $ fs ->touch ($ this ->tmpDir .\DIRECTORY_SEPARATOR .'400.html ' );
44-
4541 $ tester = $ this ->getCommandTester ($ this ->getKernel (), []);
46- $ tester ->execute ([]);
42+ $ tester ->execute ([
43+ 'path ' => $ this ->tmpDir ,
44+ ]);
4745
48- $ this ->assertFileExists ($ this ->tmpDir .\DIRECTORY_SEPARATOR .'400.html ' );
4946 $ this ->assertFileExists ($ this ->tmpDir .\DIRECTORY_SEPARATOR .'404.html ' );
5047 $ this ->assertStringContainsString ('Error 404 ' , file_get_contents ($ this ->tmpDir .\DIRECTORY_SEPARATOR .'404.html ' ));
5148 }
5249
5350 public function testDumpPagesOnlyForGivenStatusCodes ()
5451 {
52+ $ fs = new Filesystem ();
53+ $ fs ->mkdir ($ this ->tmpDir );
54+ $ fs ->touch ($ this ->tmpDir .\DIRECTORY_SEPARATOR .'test.html ' );
55+
5556 $ tester = $ this ->getCommandTester ($ this ->getKernel ());
5657 $ tester ->execute ([
58+ 'path ' => $ this ->tmpDir ,
5759 'status-codes ' => ['400 ' , '500 ' ],
5860 ]);
5961
62+ $ this ->assertFileExists ($ this ->tmpDir .\DIRECTORY_SEPARATOR .'test.html ' );
6063 $ this ->assertFileDoesNotExist ($ this ->tmpDir .\DIRECTORY_SEPARATOR .'404.html ' );
6164
6265 $ this ->assertFileExists ($ this ->tmpDir .\DIRECTORY_SEPARATOR .'400.html ' );
6366 $ this ->assertStringContainsString ('Error 400 ' , file_get_contents ($ this ->tmpDir .\DIRECTORY_SEPARATOR .'400.html ' ));
6467 }
6568
66- public function testDumpPagesAtCustomPath ()
69+ public function testForceRemovalPages ()
6770 {
68- $ path = sys_get_temp_dir ().'/error_pages_custom ' ;
69-
7071 $ fs = new Filesystem ();
71- $ fs ->remove ($ path );
72-
73- $ tester = $ this ->getCommandTester ($ this ->getKernel ());
74- $ tester ->execute ([
75- '--path ' => $ path ,
76- ]);
77-
78- $ this ->assertFileExists ($ path .\DIRECTORY_SEPARATOR .'400.html ' );
79- $ this ->assertStringContainsString ('Error 400 ' , file_get_contents ($ path .\DIRECTORY_SEPARATOR .'400.html ' ));
80- }
81-
82- public function testClearPages ()
83- {
84- mkdir ($ this ->tmpDir );
85- touch ($ this ->tmpDir .\DIRECTORY_SEPARATOR .'test.html ' );
72+ $ fs ->mkdir ($ this ->tmpDir );
73+ $ fs ->touch ($ this ->tmpDir .\DIRECTORY_SEPARATOR .'test.html ' );
8674
8775 $ tester = $ this ->getCommandTester ($ this ->getKernel ());
8876 $ tester ->execute ([
89- '--clear ' => true ,
77+ 'path ' => $ this ->tmpDir ,
78+ '--force ' => true ,
9079 ]);
9180
9281 $ this ->assertFileDoesNotExist ($ this ->tmpDir .\DIRECTORY_SEPARATOR .'test.html ' );
@@ -95,27 +84,14 @@ public function testClearPages()
9584
9685 private function getKernel (): MockObject &KernelInterface
9786 {
98- $ kernel = $ this ->createMock (KernelInterface::class);
99- $ kernel
100- ->expects ($ this ->any ())
101- ->method ('getContainer ' )
102- ->willReturn (new Container ());
103-
104- $ kernel
105- ->expects ($ this ->once ())
106- ->method ('getBundles ' )
107- ->willReturn ([]);
108-
109- return $ kernel ;
87+ return $ this ->createMock (KernelInterface::class);
11088 }
11189
11290 private function getCommandTester (KernelInterface $ kernel ): CommandTester
11391 {
114- $ errorRenderer = $ this ->createMock (ErrorRendererInterface::class);
92+ $ errorRenderer = $ this ->createStub (ErrorRendererInterface::class);
11593 $ errorRenderer
116- ->expects ($ this ->any ())
11794 ->method ('render ' )
118- ->with ($ this ->isInstanceOf (HttpException::class))
11995 ->willReturnCallback (function (HttpException $ e ) {
12096 $ exception = FlattenException::createFromThrowable ($ e );
12197 $ exception ->setAsString (\sprintf ('<html><body>Error %s</body></html> ' , $ e ->getStatusCode ()));
@@ -125,14 +101,9 @@ private function getCommandTester(KernelInterface $kernel): CommandTester
125101 ;
126102
127103 $ entrypointLookup = $ this ->createMock (EntrypointLookupInterface::class);
128- $ entrypointLookup
129- ->expects ($ this ->any ())
130- ->method ('reset ' )
131- ;
132104
133105 $ application = new Application ($ kernel );
134106 $ application ->add (new ErrorDumpCommand (
135- $ this ->tmpDir ,
136107 new Filesystem (),
137108 $ errorRenderer ,
138109 $ entrypointLookup ,
0 commit comments