-
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* install Pest * wip * change directory structure * cleanup * cleanup * change test suite in Github action and `composer.json` * Fix styling --------- Co-authored-by: alexmanase <[email protected]> Co-authored-by: Ruben Van Assche <[email protected]>
- Loading branch information
1 parent
a26ddbd
commit 8569775
Showing
11 changed files
with
142 additions
and
152 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
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 @@ | ||
dist |
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,99 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Route; | ||
|
||
use function PHPUnit\Framework\assertEquals; | ||
|
||
use function PHPUnit\Framework\assertFileExists; | ||
|
||
use Spatie\Export\Exporter; | ||
|
||
const HOME_CONTENT = '<a href="feed/blog.atom" title="all blogposts">Feed</a>Home <a href="about">About</a>'; | ||
const ABOUT_CONTENT = 'About'; | ||
const FEED_CONTENT = 'Feed'; | ||
|
||
function assertHomeExists(): void | ||
{ | ||
assertExportedFile(__DIR__ . '/dist/index.html', HOME_CONTENT); | ||
} | ||
|
||
function assertAboutExists(): void | ||
{ | ||
assertExportedFile(__DIR__ . '/dist/about/index.html', ABOUT_CONTENT); | ||
} | ||
|
||
function assertFeedBlogAtomExists(): void | ||
{ | ||
assertExportedFile(__DIR__ . '/dist/feed/blog.atom', FEED_CONTENT); | ||
} | ||
|
||
function assertExportedFile(string $path, string $content): void | ||
{ | ||
assertFileExists($path); | ||
assertEquals($content, file_get_contents($path)); | ||
} | ||
|
||
beforeEach(function () { | ||
$this->distDirectory = __DIR__ . DIRECTORY_SEPARATOR . 'dist'; | ||
|
||
if (file_exists($this->distDirectory)) { | ||
exec(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' | ||
? 'del ' . $this->distDirectory . ' /q' | ||
: 'rm -r ' . $this->distDirectory); | ||
} | ||
|
||
Route::get('/', function () { | ||
return HOME_CONTENT; | ||
}); | ||
|
||
Route::get('about', function () { | ||
return ABOUT_CONTENT; | ||
}); | ||
|
||
Route::get('feed/blog.atom', function () { | ||
return FEED_CONTENT; | ||
}); | ||
}); | ||
|
||
afterEach(function () { | ||
assertHomeExists(); | ||
assertAboutExists(); | ||
assertFeedBlogAtomExists(); | ||
}); | ||
|
||
it('crawls and exports routes', function () { | ||
app(Exporter::class)->export(); | ||
}); | ||
|
||
it('exports paths', function () { | ||
app(Exporter::class) | ||
->crawl(false) | ||
->paths(['/', '/about', '/feed/blog.atom']) | ||
->export(); | ||
}); | ||
|
||
it('exports urls', function () { | ||
app(Exporter::class) | ||
->crawl(false) | ||
->urls([url('/'), url('/about'), url('/feed/blog.atom')]) | ||
->export(); | ||
}); | ||
|
||
it('exports mixed', function () { | ||
app(Exporter::class) | ||
->crawl(false) | ||
->paths('/') | ||
->urls(url('/about'), url('/feed/blog.atom')) | ||
->export(); | ||
}); | ||
|
||
it('exports included files', function () { | ||
app(Exporter::class) | ||
->includeFiles([__DIR__ . '/stubs/public' => '']) | ||
->export(); | ||
|
||
assertFileExists(__DIR__ . '/dist/favicon.ico'); | ||
assertFileExists(__DIR__ . '/dist/media/image.png'); | ||
|
||
expect(file_exists(__DIR__ . '/dist/index.php'))->toBeFalse(); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,3 @@ | ||
<?php | ||
|
||
uses(Spatie\Export\Tests\TestCase::class)->in('.'); |
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,25 @@ | ||
<?php | ||
|
||
namespace Spatie\Export\Tests; | ||
|
||
use Orchestra\Testbench\TestCase as BaseTestCase; | ||
use Spatie\Export\ExportServiceProvider; | ||
|
||
class TestCase extends BaseTestCase | ||
{ | ||
protected function getPackageProviders($app) | ||
{ | ||
return [ExportServiceProvider::class]; | ||
} | ||
|
||
protected function getEnvironmentSetUp($app) | ||
{ | ||
$app['config']->set('filesystems.disks.export', [ | ||
'driver' => 'local', | ||
'root' => __DIR__ . '/dist', | ||
]); | ||
|
||
$app['config']->set('export.disk', 'export'); | ||
$app['config']->set('export.include_files', []); | ||
} | ||
} |
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 @@ | ||
About |
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 @@ | ||
Feed |
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 @@ | ||
<a href="feed/blog.atom" title="all blogposts">Feed</a>Home <a href="about">About</a> |