-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support generating non-html files (#64)
- Loading branch information
1 parent
f723c48
commit e281815
Showing
2 changed files
with
65 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace Tests; | ||
|
||
use Illuminate\Filesystem\Filesystem; | ||
use Mockery; | ||
use Statamic\Contracts\Entries\Entry; | ||
use Statamic\StaticSite\Page; | ||
|
||
class PageTest extends TestCase | ||
{ | ||
/** @test */ | ||
public function it_gets_the_path() | ||
{ | ||
$entry = $this->mock(Entry::class); | ||
$entry->shouldReceive('urlWithoutRedirect')->andReturn('/foo/bar'); | ||
|
||
$page = $this->page($entry, ['destination' => '/path/to/static']); | ||
|
||
$this->assertEquals('/path/to/static/foo/bar/index.html', $page->path()); | ||
$this->assertEquals('/path/to/static/foo/bar', $page->directory()); | ||
} | ||
|
||
/** @test */ | ||
public function it_gets_the_path_of_a_url_with_a_file_extension() | ||
{ | ||
$entry = $this->mock(Entry::class); | ||
$entry->shouldReceive('urlWithoutRedirect')->andReturn('/foo/bar/sitemap.xml'); | ||
|
||
$page = $this->page($entry, ['destination' => '/path/to/static']); | ||
|
||
$this->assertEquals('/path/to/static/foo/bar/sitemap.xml', $page->path()); | ||
$this->assertEquals('/path/to/static/foo/bar', $page->directory()); | ||
} | ||
|
||
/** @test */ | ||
public function it_gets_the_path_of_the_404_url() | ||
{ | ||
$entry = $this->mock(Entry::class); | ||
$entry->shouldReceive('urlWithoutRedirect')->andReturn('/404'); | ||
|
||
$page = $this->page($entry, ['destination' => '/path/to/static']); | ||
|
||
$this->assertEquals('/path/to/static/404.html', $page->path()); | ||
$this->assertEquals('/path/to/static', $page->directory()); | ||
} | ||
|
||
private function page($entry, $config) | ||
{ | ||
return new Page($this->mock(Filesystem::class), $config, $entry); | ||
} | ||
} |