From 0aacd50e86d960380fdf733ac632f8a8b5d35e43 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 12 Dec 2023 14:47:07 +0000 Subject: [PATCH] [15.x] Stops using `loadMigrationsFrom` (#1613) * Stops using `loadMigrationsFrom` * Adjusts upgrade guide * Bumps testbench --- UPGRADE.md | 10 ++++++++++ composer.json | 2 +- src/Cashier.php | 19 ------------------- src/CashierServiceProvider.php | 13 ------------- testbench.yaml | 5 +++++ tests/Feature/FeatureTestCase.php | 8 ++------ tests/TestCase.php | 9 +++------ 7 files changed, 21 insertions(+), 45 deletions(-) create mode 100644 testbench.yaml diff --git a/UPGRADE.md b/UPGRADE.md index 32cfc8bc..2a7bb768 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,15 @@ # Upgrade Guide +## Upgrading To 15.0 From 14.x + +### Migration Changes + +Cashier 15.0 no longer automatically loads migrations from its own migrations directory. Instead, you should run the following command to publish Cashier's migrations to your application: + +```bash +php artisan vendor:publish --tag=cashier-migrations +``` + ## Upgrading To 14.12.2 From 14.12 ### Webhook Added diff --git a/composer.json b/composer.json index af00df3f..8ce02c6c 100644 --- a/composer.json +++ b/composer.json @@ -39,7 +39,7 @@ "require-dev": { "dompdf/dompdf": "^2.0", "mockery/mockery": "^1.0", - "orchestra/testbench": "^7.0|^8.0", + "orchestra/testbench": "^7.14|^8.14", "phpstan/phpstan": "^1.10", "phpunit/phpunit": "^9.0" }, diff --git a/src/Cashier.php b/src/Cashier.php index dcf3cc69..5a975c78 100644 --- a/src/Cashier.php +++ b/src/Cashier.php @@ -42,13 +42,6 @@ class Cashier */ protected static $formatCurrencyUsing; - /** - * Indicates if Cashier migrations will be run. - * - * @var bool - */ - public static $runsMigrations = true; - /** * Indicates if Cashier routes will be registered. * @@ -173,18 +166,6 @@ public static function formatAmount($amount, $currency = null, $locale = null, a return $moneyFormatter->format($money); } - /** - * Configure Cashier to not register its migrations. - * - * @return static - */ - public static function ignoreMigrations() - { - static::$runsMigrations = false; - - return new static; - } - /** * Configure Cashier to not register its routes. * diff --git a/src/CashierServiceProvider.php b/src/CashierServiceProvider.php index cb091ef1..aa656528 100644 --- a/src/CashierServiceProvider.php +++ b/src/CashierServiceProvider.php @@ -22,7 +22,6 @@ public function boot() $this->registerLogger(); $this->registerRoutes(); $this->registerResources(); - $this->registerMigrations(); $this->registerPublishing(); $this->registerCommands(); @@ -123,18 +122,6 @@ protected function registerResources() $this->loadViewsFrom(__DIR__.'/../resources/views', 'cashier'); } - /** - * Register the package migrations. - * - * @return void - */ - protected function registerMigrations() - { - if (Cashier::$runsMigrations && $this->app->runningInConsole()) { - $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); - } - } - /** * Register the package's publishable resources. * diff --git a/testbench.yaml b/testbench.yaml new file mode 100644 index 00000000..c0b21f4a --- /dev/null +++ b/testbench.yaml @@ -0,0 +1,5 @@ +providers: + - Laravel\Cashier\CashierServiceProvider + +migrations: + - database/migrations diff --git a/tests/Feature/FeatureTestCase.php b/tests/Feature/FeatureTestCase.php index 937b4660..8046a2d0 100644 --- a/tests/Feature/FeatureTestCase.php +++ b/tests/Feature/FeatureTestCase.php @@ -6,13 +6,14 @@ use Laravel\Cashier\Cashier; use Laravel\Cashier\Tests\Fixtures\User; use Laravel\Cashier\Tests\TestCase; +use Orchestra\Testbench\Concerns\WithLaravelMigrations; use Stripe\ApiRequestor as StripeApiRequestor; use Stripe\HttpClient\CurlClient as StripeCurlClient; use Stripe\StripeClient; abstract class FeatureTestCase extends TestCase { - use RefreshDatabase; + use RefreshDatabase, WithLaravelMigrations; protected function setUp(): void { @@ -27,11 +28,6 @@ protected function setUp(): void StripeApiRequestor::setHttpClient($curl); } - protected function defineDatabaseMigrations() - { - $this->loadLaravelMigrations(); - } - protected static function stripe(array $options = []): StripeClient { return Cashier::stripe(array_merge(['api_key' => getenv('STRIPE_SECRET')], $options)); diff --git a/tests/TestCase.php b/tests/TestCase.php index 9c6affa4..8f0e47ca 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -5,12 +5,14 @@ use Illuminate\Support\Str; use InvalidArgumentException; use Laravel\Cashier\Cashier; -use Laravel\Cashier\CashierServiceProvider; use Laravel\Cashier\Tests\Fixtures\User; +use Orchestra\Testbench\Concerns\WithWorkbench; use Orchestra\Testbench\TestCase as OrchestraTestCase; abstract class TestCase extends OrchestraTestCase { + use WithWorkbench; + protected function getEnvironmentSetUp($app) { $apiKey = config('cashier.secret'); @@ -21,9 +23,4 @@ protected function getEnvironmentSetUp($app) Cashier::useCustomerModel(User::class); } - - protected function getPackageProviders($app) - { - return [CashierServiceProvider::class]; - } }