@@ -27,8 +27,7 @@ protected function setUp(): void
2727
2828 public function test_static_site_generate_command (): void
2929 {
30- $ appConfig = new AppConfig (baseUri: 'https://test.com ' );
31- $ this ->container ->config ($ appConfig );
30+ $ this ->container ->config (new AppConfig (baseUri: 'https://test.com ' ));
3231
3332 $ this ->console
3433 ->call (StaticGenerateCommand::class)
@@ -56,8 +55,7 @@ public function test_failure_status_code(): void
5655 $ this ->registerRoute ([StaticPageController::class, 'http500 ' ]);
5756 $ this ->registerStaticPage ([StaticPageController::class, 'http500 ' ]);
5857
59- $ appConfig = new AppConfig (baseUri: 'https://test.com ' );
60- $ this ->container ->config ($ appConfig );
58+ $ this ->container ->config (new AppConfig (baseUri: 'https://test.com ' ));
6159
6260 $ this ->console
6361 ->call (StaticGenerateCommand::class)
@@ -70,8 +68,7 @@ public function test_failure_no_textual_content(): void
7068 $ this ->registerRoute ([StaticPageController::class, 'noTextualContent ' ]);
7169 $ this ->registerStaticPage ([StaticPageController::class, 'noTextualContent ' ]);
7270
73- $ appConfig = new AppConfig (baseUri: 'https://test.com ' );
74- $ this ->container ->config ($ appConfig );
71+ $ this ->container ->config (new AppConfig (baseUri: 'https://test.com ' ));
7572
7673 $ this ->console
7774 ->call (StaticGenerateCommand::class)
@@ -84,12 +81,40 @@ public function test_failure_no_build(): void
8481 $ this ->registerRoute ([StaticPageController::class, 'vite ' ]);
8582 $ this ->registerStaticPage ([StaticPageController::class, 'vite ' ]);
8683
87- $ appConfig = new AppConfig (baseUri: 'https://test.com ' );
88- $ this ->container ->config ($ appConfig );
84+ $ this ->container ->config (new AppConfig (baseUri: 'https://test.com ' ));
8985
9086 $ this ->console
9187 ->call (StaticGenerateCommand::class)
9288 ->assertSee ('A Vite build is needed for [/static/vite/a/b] ' )
9389 ->assertExitCode (ExitCode::ERROR );
9490 }
91+
92+ public function test_dead_link (): void
93+ {
94+ $ this ->registerRoute ([StaticPageController::class, 'deadLink ' ]);
95+ $ this ->registerStaticPage ([StaticPageController::class, 'deadLink ' ]);
96+
97+ $ this ->container ->config (new AppConfig (baseUri: 'https://test.com ' ));
98+
99+ $ this ->console
100+ ->call (StaticGenerateCommand::class)
101+ ->assertSee ('1 DEAD LINK ' )
102+ ->assertSee ('https://test.com/404 ' )
103+ ->assertExitCode (ExitCode::ERROR );
104+ }
105+
106+ public function test_external_dead_links (): void
107+ {
108+ $ this ->registerRoute ([StaticPageController::class, 'deadLink ' ]);
109+ $ this ->registerStaticPage ([StaticPageController::class, 'deadLink ' ]);
110+
111+ $ this ->container ->config (new AppConfig (baseUri: 'https://test.com ' ));
112+
113+ $ this ->console
114+ ->call (StaticGenerateCommand::class, ['--allow-external-dead-links ' => false ])
115+ ->assertSee ('2 DEAD LINKS ' )
116+ ->assertSee ('https://test.com/404 ' )
117+ ->assertSee ('https://google.com/404 ' )
118+ ->assertExitCode (ExitCode::ERROR );
119+ }
95120}
0 commit comments