Skip to content

Commit 5e57700

Browse files
committed
Use test to verify trace output
1 parent 1a635cf commit 5e57700

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed

.github/workflows/demo.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,9 @@ jobs:
8787
DB_USERNAME: root
8888
DB_PASSWORD: 'null'
8989
run: |
90+
cp /home/runner/work/blueprint/blueprint/tests/fixtures/integration/TraceTest.php tests/Feature/TraceTest.php
9091
php artisan migrate:refresh --force
9192
php artisan blueprint:build /home/runner/work/blueprint/blueprint/tests/fixtures/drafts/readme-example.yaml
92-
php artisan test
93+
php artisan migrate
9394
php artisan blueprint:trace
94-
95-
- name: Output the trace
96-
working-directory: /home/runner/work/blueprint/laravel${{ matrix.laravel-version }}-example
97-
run: cat .blueprint
95+
php artisan test
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace Tests\Feature;
4+
5+
use PHPUnit\Framework\Attributes\Test;
6+
use PHPUnit\Framework\TestCase;
7+
8+
final class TraceTest extends TestCase
9+
{
10+
#[Test]
11+
public function it_stores_readme_example(): void
12+
{
13+
$this->assertFileExists('.blueprint');
14+
15+
$prefix = date('Y_m_d_');
16+
$actual = preg_replace(
17+
'/database\/migrations\/' . $prefix . '\d{6}/',
18+
'database/migrations/',
19+
file_get_contents('.blueprint')
20+
);
21+
22+
$this->assertEquals($this->expectedStub(), trim($actual));
23+
}
24+
25+
private function expectedStub(): string
26+
{
27+
return <<<STUB
28+
created: 'app/Http/Controllers/PostController.php database/factories/PostFactory.php database/migrations/_create_posts_table.php app/Models/Post.php tests/Feature/Http/Controllers/PostControllerTest.php app/Events/NewPost.php app/Http/Requests/PostStoreRequest.php app/Jobs/SyncMedia.php app/Mail/ReviewPost.php resources/views/emails/review-post.blade.php resources/views/post/index.blade.php'
29+
updated: routes/web.php
30+
models:
31+
Post: { title: 'string:400', content: longtext, published_at: 'timestamp nullable', author_id: 'biginteger unsigned' }
32+
User: { name: string, email: string, email_verified_at: 'timestamp nullable', password: string, remember_token: 'string:100 nullable' }
33+
STUB;
34+
}
35+
}

0 commit comments

Comments
 (0)