Skip to content

Commit 140f9eb

Browse files
authored
feat: use directories instead of file names to allow default server config setup (tempestphp#479)
1 parent c1f6cc4 commit 140f9eb

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

src/Tempest/Http/src/Static/StaticCleanCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function __invoke(): void
3939
foreach ($dataProvider->provide() as $params) {
4040
$uri = parse_url(uri($staticPage->handler, ...$params), PHP_URL_PATH);
4141

42-
$file = path($publicPath, $uri . '.html');
42+
$file = path($publicPath, $uri . '/index.html');
4343

4444
if (! file_exists($file)) {
4545
continue;

src/Tempest/Http/src/Static/StaticGenerateCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,9 @@ public function __invoke(): void
5151

5252
$uri = parse_url(uri($staticPage->handler, ...$params), PHP_URL_PATH);
5353

54-
// TODO: test!
5554
$fileName = $uri === '/'
5655
? 'index.html'
57-
: $uri . '.html';
56+
: $uri . '/index.html';
5857

5958
$file = path($publicPath, $fileName);
6059

tests/Integration/Http/Static/StaticCleanCommandTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ public function test_generate(): void
2222

2323
$this->console->call('static:clean')
2424
->assertDoesNotContain('https://test.com/static/a/b')
25-
->assertContains('/public/static/a/b.html')
26-
->assertContains('/public/static/c/d.html');
25+
->assertContains('/public/static/a/b/index.html')
26+
->assertContains('/public/static/c/d/index.html');
2727

2828
$root = $this->kernel->root;
2929

30-
$this->assertFileDoesNotExist(path($root, '/public/static/a/b.html'));
31-
$this->assertFileDoesNotExist(path($root, '/public/static/c/d.html'));
30+
$this->assertFileDoesNotExist(path($root, '/public/static/a/b/index.html'));
31+
$this->assertFileDoesNotExist(path($root, '/public/static/c/d/index.html'));
3232
}
3333
}

tests/Integration/Http/Static/StaticGenerateCommandTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ public function test_generate(): void
2626

2727
$root = $this->kernel->root;
2828

29-
$this->assertFileExists(path($root, '/public/static/a/b.html'));
30-
$this->assertFileExists(path($root, '/public/static/c/d.html'));
29+
$this->assertFileExists(path($root, '/public/static/a/b/index.html'));
30+
$this->assertFileExists(path($root, '/public/static/c/d/index.html'));
3131

32-
$b = file_get_contents(path($root, '/public/static/a/b.html'));
33-
$d = file_get_contents(path($root, '/public/static/c/d.html'));
32+
$b = file_get_contents(path($root, '/public/static/a/b/index.html'));
33+
$d = file_get_contents(path($root, '/public/static/c/d/index.html'));
3434

3535
$this->assertStringContainsString('a', $b);
3636
$this->assertStringContainsString('b', $b);

0 commit comments

Comments
 (0)