From c3fc2c704d1b235e410f155b9da201a1c2e939c0 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 | 33 ++++++++++++++++++++++++ 2 files changed, 36 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..7d26c72b 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 + 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 diff --git a/tests/fixtures/integration/TraceTest.php b/tests/fixtures/integration/TraceTest.php new file mode 100644 index 00000000..0764907b --- /dev/null +++ b/tests/fixtures/integration/TraceTest.php @@ -0,0 +1,33 @@ +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 <<