From 5e57700625a487305c1958c0b5c2b394dd343bff Mon Sep 17 00:00:00 2001 From: Jason McCreary Date: Fri, 1 Mar 2024 10:05:43 -0500 Subject: [PATCH] Use test to verify trace output --- .github/workflows/demo.yml | 8 ++---- tests/fixtures/integration/TraceTest.php | 35 ++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 tests/fixtures/integration/TraceTest.php diff --git a/.github/workflows/demo.yml b/.github/workflows/demo.yml index 902fb081..2619bfae 100644 --- a/.github/workflows/demo.yml +++ b/.github/workflows/demo.yml @@ -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 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 migrate 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 diff --git a/tests/fixtures/integration/TraceTest.php b/tests/fixtures/integration/TraceTest.php new file mode 100644 index 00000000..35b67fd9 --- /dev/null +++ b/tests/fixtures/integration/TraceTest.php @@ -0,0 +1,35 @@ +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(), trim($actual)); + } + + private function expectedStub(): string + { + return <<