Skip to content

Commit

Permalink
Use test to verify trace output
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonmccreary committed Mar 1, 2024
1 parent 1a635cf commit c3fc2c7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,9 @@ jobs:
DB_USERNAME: root
DB_PASSWORD: 'null'
run: |
cp /home/runner/work/blueprint/blueprint/tests/fixtures/integration/TraceTest.php tests/Feature/TraceTest.php
ls -laR tests
php artisan migrate:refresh --force
php artisan blueprint:build /home/runner/work/blueprint/blueprint/tests/fixtures/drafts/readme-example.yaml
php artisan test
php artisan blueprint:trace
- name: Output the trace
working-directory: /home/runner/work/blueprint/laravel${{ matrix.laravel-version }}-example
run: cat .blueprint
php artisan test
33 changes: 33 additions & 0 deletions tests/fixtures/integration/TraceTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Tests\Feature;

use PHPUnit\Framework\TestCase;

final class TraceTest extends TestCase
{
public function it_stores_readme_example(): void
{
$this->assertFileExists('.blueprint');

$prefix = date('Y_m_d_');
$actual = preg_replace(
'/database\/migrations\/' . $prefix . '\d{6}/',
'database/migrations/',
file_get_contents('.blueprint')
);

$this->assertEquals($this->expectedStub(), $actual);
}

private function expectedStub(): string
{
return <<<STUB
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'
updated: routes/web.php
models:
Post: { title: 'string:400', content: longtext, published_at: 'timestamp nullable', author_id: 'biginteger unsigned' }
User: { name: string, email: string, email_verified_at: 'timestamp nullable', password: string, remember_token: 'string:100 nullable' }
STUB;
}
}

0 comments on commit c3fc2c7

Please sign in to comment.