diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index f9421e78..cb393f56 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -14,17 +14,9 @@ jobs: fail-fast: true matrix: os: [ ubuntu-latest ] - php: [ 8.2, 8.1, 8.0] - laravel: [ 10.*, 9.* ] + php: [8.3, 8.2, 8.1] + laravel: [ 11.*, 10.* ] dependency-version: [ prefer-stable ] - include: - - laravel: 9.* - testbench: 7.* - - laravel: 10.* - testbench: 8.* - exclude: - - laravel: 10.* - php: 8.0 name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} - ${{ matrix.os }} diff --git a/composer.json b/composer.json index c2fe549e..28ae8550 100644 --- a/composer.json +++ b/composer.json @@ -30,22 +30,22 @@ } ], "require": { - "php": "^8.0", + "php": "^8.1", "ext-json": "*", "ext-intl": "*", "dompdf/dompdf": "^2.0", - "illuminate/database": "^9.0|^10", - "illuminate/support": "^9.0|^10", - "mollie/laravel-mollie": "^2.22", - "mollie/mollie-api-php": "^2.27", + "illuminate/database": "^10|^11", + "illuminate/support": "^10|^11", + "mollie/laravel-mollie": "^3.0", + "mollie/mollie-api-php": "^2.65", "moneyphp/money": "^4.1", - "nesbot/carbon": "^2.31" + "nesbot/carbon": "^2.72|^3.0" }, "require-dev": { "guzzlehttp/guzzle": "^7.0", "mockery/mockery": "^1.4", - "orchestra/testbench": "^7.0|^8.0", - "phpunit/phpunit": "^9.5" + "orchestra/testbench": "^8.0|^9.0", + "phpunit/phpunit": "^10.0" }, "autoload": { "files": [ diff --git a/database/migrations/create_applied_coupons_table.php.stub b/database/migrations/create_applied_coupons_table.php.stub index 8bda7635..98ef8f1b 100644 --- a/database/migrations/create_applied_coupons_table.php.stub +++ b/database/migrations/create_applied_coupons_table.php.stub @@ -11,7 +11,7 @@ class CreateAppliedCouponsTable extends Migration * * @return void */ - public function up() + public function up(): void { Schema::create('applied_coupons', function (Blueprint $table) { $table->bigIncrements('id'); @@ -26,7 +26,7 @@ class CreateAppliedCouponsTable extends Migration * * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('applied_coupons'); } diff --git a/database/migrations/create_credits_table.php.stub b/database/migrations/create_credits_table.php.stub index 2496e8ac..c9da278d 100644 --- a/database/migrations/create_credits_table.php.stub +++ b/database/migrations/create_credits_table.php.stub @@ -11,7 +11,7 @@ class CreateCreditsTable extends Migration * * @return void */ - public function up() + public function up(): void { Schema::create('credits', function (Blueprint $table) { $table->bigIncrements('id'); @@ -28,7 +28,7 @@ class CreateCreditsTable extends Migration * * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('credits'); } diff --git a/database/migrations/create_order_items_table.php.stub b/database/migrations/create_order_items_table.php.stub index 60ffa0c0..1b1512ca 100644 --- a/database/migrations/create_order_items_table.php.stub +++ b/database/migrations/create_order_items_table.php.stub @@ -11,7 +11,7 @@ class CreateOrderItemsTable extends Migration * * @return void */ - public function up() + public function up(): void { Schema::create('order_items', function (Blueprint $table) { $table->bigIncrements('id'); @@ -36,7 +36,7 @@ class CreateOrderItemsTable extends Migration * * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('order_items'); } diff --git a/database/migrations/create_orders_table.php.stub b/database/migrations/create_orders_table.php.stub index eaf38291..370c0227 100644 --- a/database/migrations/create_orders_table.php.stub +++ b/database/migrations/create_orders_table.php.stub @@ -11,7 +11,7 @@ class CreateOrdersTable extends Migration * * @return void */ - public function up() + public function up(): void { Schema::create('orders', function (Blueprint $table) { $table->bigIncrements('id'); @@ -39,7 +39,7 @@ class CreateOrdersTable extends Migration * * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('orders'); } diff --git a/database/migrations/create_payments_table.php.stub b/database/migrations/create_payments_table.php.stub index 31a347c1..48bdd769 100644 --- a/database/migrations/create_payments_table.php.stub +++ b/database/migrations/create_payments_table.php.stub @@ -11,7 +11,7 @@ class CreatePaymentsTable extends Migration * * @return void */ - public function up() + public function up(): void { Schema::create('payments', function (Blueprint $table) { $table->bigIncrements('id'); @@ -35,7 +35,7 @@ class CreatePaymentsTable extends Migration * * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('payments'); } diff --git a/database/migrations/create_redeemed_coupons_table.php.stub b/database/migrations/create_redeemed_coupons_table.php.stub index 973f3aad..0a31505f 100644 --- a/database/migrations/create_redeemed_coupons_table.php.stub +++ b/database/migrations/create_redeemed_coupons_table.php.stub @@ -11,7 +11,7 @@ class CreateRedeemedCouponsTable extends Migration * * @return void */ - public function up() + public function up(): void { Schema::create('redeemed_coupons', function (Blueprint $table) { $table->bigIncrements('id'); @@ -30,7 +30,7 @@ class CreateRedeemedCouponsTable extends Migration * * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('redeemed_coupons'); } diff --git a/database/migrations/create_refund_items_table.php.stub b/database/migrations/create_refund_items_table.php.stub index 3f30c692..42f324d1 100644 --- a/database/migrations/create_refund_items_table.php.stub +++ b/database/migrations/create_refund_items_table.php.stub @@ -11,7 +11,7 @@ class CreateRefundItemsTable extends Migration * * @return void */ - public function up() + public function up(): void { Schema::create('refund_items', function (Blueprint $table) { $table->bigIncrements('id'); @@ -34,7 +34,7 @@ class CreateRefundItemsTable extends Migration * * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('refund_items'); } diff --git a/database/migrations/create_refunds_table.php.stub b/database/migrations/create_refunds_table.php.stub index c6f66924..7190f937 100644 --- a/database/migrations/create_refunds_table.php.stub +++ b/database/migrations/create_refunds_table.php.stub @@ -11,7 +11,7 @@ class CreateRefundsTable extends Migration * * @return void */ - public function up() + public function up(): void { Schema::create('refunds', function (Blueprint $table) { $table->bigIncrements('id'); @@ -32,7 +32,7 @@ class CreateRefundsTable extends Migration * * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('refunds'); } diff --git a/database/migrations/create_subscriptions_table.php.stub b/database/migrations/create_subscriptions_table.php.stub index d53e0ec3..10f97e90 100644 --- a/database/migrations/create_subscriptions_table.php.stub +++ b/database/migrations/create_subscriptions_table.php.stub @@ -11,7 +11,7 @@ class CreateSubscriptionsTable extends Migration * * @return void */ - public function up() + public function up(): void { Schema::create('subscriptions', function (Blueprint $table) { $table->bigIncrements('id'); @@ -36,7 +36,7 @@ class CreateSubscriptionsTable extends Migration * * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('subscriptions'); } diff --git a/database/migrations/upgrade_to_cashier_v2.php.stub b/database/migrations/upgrade_to_cashier_v2.php.stub index 0b7aa345..2eac55e2 100644 --- a/database/migrations/upgrade_to_cashier_v2.php.stub +++ b/database/migrations/upgrade_to_cashier_v2.php.stub @@ -11,7 +11,7 @@ class UpgradeToCashierV2 extends Migration * * @return void */ - public function up() + public function up(): void { Schema::table('orders', function (Blueprint $table) { $table->unsignedInteger('amount_refunded')->after('total_due')->default(0); @@ -67,9 +67,8 @@ class UpgradeToCashierV2 extends Migration * * @return void */ - public function down() + public function down(): void { - // Requires "doctrine/dbal" in composer.json // Schema::table('orders', function (Blueprint $table) { // $table->dropColumn(['amount_refunded', 'amount_charged_back']); // }); diff --git a/docs/01-installation.md b/docs/01-installation.md index 7fac8465..b3417665 100644 --- a/docs/01-installation.md +++ b/docs/01-installation.md @@ -70,7 +70,7 @@ Once you have pulled in the package: { return [$this->name, $this->email]; } - + /** * Get additional information to be displayed on the invoice. Typically a note provided by the customer. * @@ -82,10 +82,13 @@ Once you have pulled in the package: } ``` -6. Schedule a periodic job to execute the `cashier:run` command. When processing lots of orders, consider increasing the job frequency to prevent hitting Mollie's rate limiter. +6. Schedule a periodic command to execute the `CashierRun` command. When processing lots of orders, consider increasing the job frequency to prevent hitting Mollie's rate limiter. ```php - $schedule->command('cashier:run') + use Illuminate\Support\Facades\Schedule; + use Laravel\Cashier\Console\Commands\CashierRun; + + Schedule::command(CashierRun::class) ->hourly() // run as often as you like (daily, monthly, every minute, ...) ->withoutOverlapping(); // make sure to include this ``` diff --git a/resources/lang/en/order_item.php b/lang/en/order_item.php similarity index 100% rename from resources/lang/en/order_item.php rename to lang/en/order_item.php diff --git a/resources/lang/en/payment.php b/lang/en/payment.php similarity index 100% rename from resources/lang/en/payment.php rename to lang/en/payment.php diff --git a/resources/lang/en/receipt.php b/lang/en/receipt.php similarity index 100% rename from resources/lang/en/receipt.php rename to lang/en/receipt.php diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 9cf16c65..f095de41 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,10 +1,5 @@ - - - - src/ - - + tests @@ -34,4 +29,9 @@ + + + src/ + + diff --git a/src/CashierServiceProvider.php b/src/CashierServiceProvider.php index c9d0c51d..5b06fee0 100644 --- a/src/CashierServiceProvider.php +++ b/src/CashierServiceProvider.php @@ -2,6 +2,7 @@ namespace Laravel\Cashier; +use Illuminate\Foundation\Console\AboutCommand; use Illuminate\Support\ServiceProvider; use Laravel\Cashier\Console\Commands\CashierInstall; use Laravel\Cashier\Console\Commands\CashierRun; @@ -13,37 +14,27 @@ use Laravel\Cashier\Order\Contracts\MinimumPayment as MinimumPaymentContract; use Laravel\Cashier\Plan\ConfigPlanRepository; use Laravel\Cashier\Plan\Contracts\PlanRepository; -use Mollie\Laravel\MollieServiceProvider; +use Mollie\Api\MollieApiClient; class CashierServiceProvider extends ServiceProvider { use RegistersMollieInteractions; - const PACKAGE_VERSION = '2.11.1'; + const PACKAGE_VERSION = '2.12.0'; /** * Bootstrap the application services. */ public function boot() { - $this->mergeConfig(); - - if (Cashier::$registersRoutes) { - $this->loadRoutesFrom(__DIR__.'/../routes/webhooks.php'); - } - - $this->loadViewsFrom(__DIR__.'/../resources/views', 'cashier'); - $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'cashier'); - - mollie()->addVersionString('MollieLaravelCashier/'.self::PACKAGE_VERSION); + $this->registerCommands(); + $this->registerPublishing(); + $this->registerRoutes(); + $this->registerResources(); - if ($this->app->runningInConsole()) { - $this->publishMigrations('cashier-migrations'); - $this->publishConfig('cashier-configs'); - $this->publishViews('cashier-views'); - $this->publishTranslations('cashier-translations'); - $this->publishUpdate('cashier-update'); - } + $this->app->resolved(MollieApiClient::class, function (MollieApiClient $mollie) { + return $mollie->addVersionString('MollieLaravelCashier/' . self::PACKAGE_VERSION); + }); $this->configureCurrency(); $this->configureCurrencyLocale(); @@ -54,7 +45,8 @@ public function boot() */ public function register() { - $this->app->register(MollieServiceProvider::class); + $this->mergeConfig(); + $this->registerMollieInteractions($this->app); $this->app->bind(PlanRepository::class, ConfigPlanRepository::class); $this->app->singleton(CouponRepository::class, function () { @@ -66,37 +58,61 @@ public function register() $this->app->bind(MinimumPaymentContract::class, MinimumPayment::class); $this->app->bind(MaximumPaymentContract::class, MaximumPayment::class); - $this->commands([ - CashierInstall::class, - CashierRun::class, - CashierUpdate::class, - ]); - $this->app->register(EventServiceProvider::class); } - protected function mergeConfig() + protected function registerCommands(): void { - $this->mergeConfigFrom(__DIR__.'/../config/cashier.php', 'cashier'); - $this->mergeConfigFrom(__DIR__.'/../config/cashier_coupons.php', 'cashier_coupons'); - $this->mergeConfigFrom(__DIR__.'/../config/cashier_plans.php', 'cashier_plans'); + if ($this->app->runningInConsole()) { + AboutCommand::add('Laravel Cashier Mollie', fn () => ['Version' => static::PACKAGE_VERSION]); + + $this->commands([ + CashierInstall::class, + CashierRun::class, + CashierUpdate::class, + ]); + } + } + + protected function registerPublishing(): void + { + if ($this->app->runningInConsole()) { + $this->publishMigrations('cashier-migrations'); + $this->publishConfig('cashier-configs'); + $this->publishViews('cashier-views'); + $this->publishTranslations('cashier-translations'); + $this->publishUpdate('cashier-update'); + } + } + + protected function registerRoutes(): void + { + if (Cashier::$registersRoutes) { + $this->loadRoutesFrom(__DIR__ . '/../routes/webhooks.php'); + } + } + + protected function registerResources(): void + { + $this->loadViewsFrom(__DIR__ . '/../resources/views', 'cashier'); + $this->loadTranslationsFrom(__DIR__ . '/../lang', 'cashier'); } protected function publishMigrations(string $tag) { if (Cashier::$runsMigrations) { - $prefix = 'migrations/'.date('Y_m_d_His', time()); + $prefix = 'migrations/' . date('Y_m_d_His', time()); $this->publishes([ - __DIR__.'/../database/migrations/create_applied_coupons_table.php.stub' => database_path($prefix.'_create_applied_coupons_table.php'), - __DIR__.'/../database/migrations/create_redeemed_coupons_table.php.stub' => database_path($prefix.'_create_redeemed_coupons_table.php'), - __DIR__.'/../database/migrations/create_credits_table.php.stub' => database_path($prefix.'_create_credits_table.php'), - __DIR__.'/../database/migrations/create_orders_table.php.stub' => database_path($prefix.'_create_orders_table.php'), - __DIR__.'/../database/migrations/create_order_items_table.php.stub' => database_path($prefix.'_create_order_items_table.php'), - __DIR__.'/../database/migrations/create_subscriptions_table.php.stub' => database_path($prefix.'_create_subscriptions_table.php'), - __DIR__.'/../database/migrations/create_payments_table.php.stub' => database_path($prefix.'_create_payments_table.php'), - __DIR__.'/../database/migrations/create_refund_items_table.php.stub' => database_path($prefix.'_create_refund_items_table.php'), - __DIR__.'/../database/migrations/create_refunds_table.php.stub' => database_path($prefix.'_create_refunds_table.php'), + __DIR__ . '/../database/migrations/create_applied_coupons_table.php.stub' => database_path($prefix . '_create_applied_coupons_table.php'), + __DIR__ . '/../database/migrations/create_redeemed_coupons_table.php.stub' => database_path($prefix . '_create_redeemed_coupons_table.php'), + __DIR__ . '/../database/migrations/create_credits_table.php.stub' => database_path($prefix . '_create_credits_table.php'), + __DIR__ . '/../database/migrations/create_orders_table.php.stub' => database_path($prefix . '_create_orders_table.php'), + __DIR__ . '/../database/migrations/create_order_items_table.php.stub' => database_path($prefix . '_create_order_items_table.php'), + __DIR__ . '/../database/migrations/create_subscriptions_table.php.stub' => database_path($prefix . '_create_subscriptions_table.php'), + __DIR__ . '/../database/migrations/create_payments_table.php.stub' => database_path($prefix . '_create_payments_table.php'), + __DIR__ . '/../database/migrations/create_refund_items_table.php.stub' => database_path($prefix . '_create_refund_items_table.php'), + __DIR__ . '/../database/migrations/create_refunds_table.php.stub' => database_path($prefix . '_create_refunds_table.php'), ], $tag); } } @@ -104,10 +120,10 @@ protected function publishMigrations(string $tag) protected function publishUpdate(string $tag) { if (Cashier::$runsMigrations) { - $prefix = 'migrations/'.date('Y_m_d_His', time()); + $prefix = 'migrations/' . date('Y_m_d_His', time()); $this->publishes([ - __DIR__.'/../database/migrations/upgrade_to_cashier_v2.php.stub' => database_path($prefix.'_upgrade_to_cashier_v2.php'), + __DIR__ . '/../database/migrations/upgrade_to_cashier_v2.php.stub' => database_path($prefix . '_upgrade_to_cashier_v2.php'), ], $tag); } } @@ -115,26 +131,33 @@ protected function publishUpdate(string $tag) protected function publishConfig(string $tag) { $this->publishes([ - __DIR__.'/../config/cashier.php' => config_path('cashier.php'), - __DIR__.'/../config/cashier_coupons.php' => config_path('cashier_coupons.php'), - __DIR__.'/../config/cashier_plans.php' => config_path('cashier_plans.php'), + __DIR__ . '/../config/cashier.php' => config_path('cashier.php'), + __DIR__ . '/../config/cashier_coupons.php' => config_path('cashier_coupons.php'), + __DIR__ . '/../config/cashier_plans.php' => config_path('cashier_plans.php'), ], $tag); } protected function publishTranslations(string $tag) { $this->publishes([ - __DIR__.'/../resources/lang' => $this->app->langPath('vendor/cashier'), + __DIR__ . '/../lang' => $this->app->langPath('vendor/cashier'), ], $tag); } protected function publishViews(string $tag) { $this->publishes([ - __DIR__.'/../resources/views' => $this->app->basePath('resources/views/vendor/cashier'), + __DIR__ . '/../resources/views' => $this->app->basePath('resources/views/vendor/cashier'), ], $tag); } + protected function mergeConfig(): void + { + $this->mergeConfigFrom(__DIR__ . '/../config/cashier.php', 'cashier'); + $this->mergeConfigFrom(__DIR__ . '/../config/cashier_coupons.php', 'cashier_coupons'); + $this->mergeConfigFrom(__DIR__ . '/../config/cashier_plans.php', 'cashier_plans'); + } + protected function configureCurrency() { $currency = config('cashier.currency', false); diff --git a/src/Mollie/BaseMollieInteraction.php b/src/Mollie/BaseMollieInteraction.php index 7eca0081..e7e5b4c3 100644 --- a/src/Mollie/BaseMollieInteraction.php +++ b/src/Mollie/BaseMollieInteraction.php @@ -4,12 +4,12 @@ namespace Laravel\Cashier\Mollie; -use Mollie\Laravel\Wrappers\MollieApiWrapper as Mollie; +use Mollie\Api\MollieApiClient as Mollie; abstract class BaseMollieInteraction { /** - * @var \Mollie\Laravel\Facades\Mollie + * @var \Mollie\Api\MollieApiClient */ protected $mollie; diff --git a/src/Mollie/CreateMollieCustomer.php b/src/Mollie/CreateMollieCustomer.php index d0f6614a..1e8d7caf 100644 --- a/src/Mollie/CreateMollieCustomer.php +++ b/src/Mollie/CreateMollieCustomer.php @@ -11,6 +11,6 @@ class CreateMollieCustomer extends BaseMollieInteraction implements Contract { public function execute(array $payload): Customer { - return $this->mollie->customers()->create($payload); + return $this->mollie->customers->create($payload); } } diff --git a/src/Mollie/CreateMolliePayment.php b/src/Mollie/CreateMolliePayment.php index bfdd1e26..3cc71382 100644 --- a/src/Mollie/CreateMolliePayment.php +++ b/src/Mollie/CreateMolliePayment.php @@ -11,6 +11,6 @@ class CreateMolliePayment extends BaseMollieInteraction implements Contract { public function execute(array $payload): Payment { - return $this->mollie->payments()->create($payload); + return $this->mollie->payments->create($payload); } } diff --git a/src/Mollie/CreateMollieRefund.php b/src/Mollie/CreateMollieRefund.php index 56bebf24..b9428950 100644 --- a/src/Mollie/CreateMollieRefund.php +++ b/src/Mollie/CreateMollieRefund.php @@ -7,7 +7,7 @@ use Laravel\Cashier\Mollie\Contracts\CreateMollieRefund as Contract; use Laravel\Cashier\Mollie\Contracts\GetMolliePayment; use Mollie\Api\Resources\Refund; -use Mollie\Laravel\Wrappers\MollieApiWrapper as Mollie; +use Mollie\Api\MollieApiClient as Mollie; class CreateMollieRefund extends BaseMollieInteraction implements Contract { diff --git a/src/Mollie/GetMollieCustomer.php b/src/Mollie/GetMollieCustomer.php index 424b2d08..6c18f162 100644 --- a/src/Mollie/GetMollieCustomer.php +++ b/src/Mollie/GetMollieCustomer.php @@ -11,6 +11,6 @@ class GetMollieCustomer extends BaseMollieInteraction implements Contract { public function execute(string $id): Customer { - return $this->mollie->customers()->get($id); + return $this->mollie->customers->get($id); } } diff --git a/src/Mollie/GetMollieMandate.php b/src/Mollie/GetMollieMandate.php index 025fc9d3..9b6a7c3d 100644 --- a/src/Mollie/GetMollieMandate.php +++ b/src/Mollie/GetMollieMandate.php @@ -11,6 +11,6 @@ class GetMollieMandate extends BaseMollieInteraction implements Contract { public function execute(string $customerId, string $mandateId): Mandate { - return $this->mollie->mandates()->getForId($customerId, $mandateId); + return $this->mollie->mandates->getForId($customerId, $mandateId); } } diff --git a/src/Mollie/GetMollieMethodMaximumAmount.php b/src/Mollie/GetMollieMethodMaximumAmount.php index 2a9101eb..5af12f39 100644 --- a/src/Mollie/GetMollieMethodMaximumAmount.php +++ b/src/Mollie/GetMollieMethodMaximumAmount.php @@ -11,7 +11,7 @@ class GetMollieMethodMaximumAmount extends BaseMollieInteraction implements Cont public function execute(string $method, string $currency): ?Money { $maximumAmount = $this->mollie - ->methods() + ->methods ->get($method, ['currency' => $currency]) ->maximumAmount; diff --git a/src/Mollie/GetMollieMethodMinimumAmount.php b/src/Mollie/GetMollieMethodMinimumAmount.php index 86429ecb..b9ac3029 100644 --- a/src/Mollie/GetMollieMethodMinimumAmount.php +++ b/src/Mollie/GetMollieMethodMinimumAmount.php @@ -11,7 +11,7 @@ class GetMollieMethodMinimumAmount extends BaseMollieInteraction implements Cont public function execute(string $method, string $currency): Money { $minimumAmount = $this->mollie - ->methods() + ->methods ->get($method, ['currency' => $currency]) ->minimumAmount; diff --git a/src/Mollie/GetMolliePayment.php b/src/Mollie/GetMolliePayment.php index b64eabb5..44c36518 100644 --- a/src/Mollie/GetMolliePayment.php +++ b/src/Mollie/GetMolliePayment.php @@ -11,6 +11,6 @@ class GetMolliePayment extends BaseMollieInteraction implements Contract { public function execute(string $id, array $parameters = []): Payment { - return $this->mollie->payments()->get($id, $parameters); + return $this->mollie->payments->get($id, $parameters); } } diff --git a/src/Mollie/GetMollieRefund.php b/src/Mollie/GetMollieRefund.php index d9d3038e..9b389659 100644 --- a/src/Mollie/GetMollieRefund.php +++ b/src/Mollie/GetMollieRefund.php @@ -7,12 +7,12 @@ use Laravel\Cashier\Mollie\Contracts\GetMolliePayment; use Laravel\Cashier\Mollie\Contracts\GetMollieRefund as Contract; use Mollie\Api\Resources\Refund; -use Mollie\Laravel\Wrappers\MollieApiWrapper as Mollie; +use Mollie\Api\MollieApiClient as Mollie; class GetMollieRefund implements Contract { /** - * @var \Mollie\Laravel\Wrappers\MollieApiWrapper + * @var \Mollie\Api\MollieApiClient */ protected Mollie $mollie; diff --git a/src/Order/Order.php b/src/Order/Order.php index 61689765..0974b3d7 100644 --- a/src/Order/Order.php +++ b/src/Order/Order.php @@ -219,6 +219,7 @@ public function processPayment() case $totalDue->isZero(): // No payment processing required $this->mollie_payment_id = null; + logger()->info('no payment processing'); break; @@ -626,7 +627,7 @@ public function getCurrency() /** * Get the description used when creating a mollie order. - * + * * @return string */ public function getDescription() diff --git a/src/Subscription.php b/src/Subscription.php index ce87ac6a..01b5e017 100644 --- a/src/Subscription.php +++ b/src/Subscription.php @@ -237,7 +237,7 @@ public function getCycleProgressAttribute($now = null, $precision = 5) $total_cycle_seconds = $cycle_started_at->diffInSeconds($cycle_ends_at); $seconds_progressed = $cycle_started_at->diffInSeconds($now); - return round($seconds_progressed / $total_cycle_seconds, $precision); + return abs(round($seconds_progressed / $total_cycle_seconds, $precision)); } /** @@ -882,7 +882,7 @@ public function restartCycleWithModifications(\Closure $applyNewSettings, ?Carbo $this->save(); - if (! $onTrial && $invoiceNow) { + if (!$onTrial && $invoiceNow) { $order = Cashier::$orderModel::createFromItems($orderItems); $order->processPayment(); } diff --git a/tests/BaseTestCase.php b/tests/BaseTestCase.php index 64a32080..7b91ca76 100644 --- a/tests/BaseTestCase.php +++ b/tests/BaseTestCase.php @@ -7,9 +7,9 @@ use Laravel\Cashier\CashierServiceProvider; use Laravel\Cashier\Coupon\CouponOrderItemPreprocessor; use Laravel\Cashier\Plan\AdvancedIntervalGenerator; -use Laravel\Cashier\Tests\Database\Migrations\CreateUsersTable; use Laravel\Cashier\Tests\Fixtures\User; use Laravel\Cashier\Tests\Traits\InteractsWithMocks; +use Mollie\Laravel\MollieServiceProvider; use Money\Currency; use Money\Money; use Orchestra\Testbench\TestCase; @@ -27,6 +27,7 @@ protected function setUp(): void { parent::setUp(); + $this->setupDatabase(); $this->withFixtureModels(); config(['cashier.webhook_url' => 'https://www.example.com/webhook']); @@ -40,15 +41,13 @@ protected function setUp(): void */ protected function getPackageProviders($app) { - return [CashierServiceProvider::class]; + return [ + CashierServiceProvider::class, + MollieServiceProvider::class, + ]; } - /** - * Execute table migrations. - * - * @return $this - */ - protected function withPackageMigrations() + protected function setupDatabase(): void { $migrations_dir = __DIR__ . '/../database/migrations'; @@ -56,8 +55,8 @@ protected function withPackageMigrations() collect( [ [ - 'class' => CreateUsersTable::class, - 'file_path' => __DIR__ . '/Database/Migrations/create_users_table.php', + 'class' => \Laravel\Cashier\Tests\Database\Migrations\CreateUsersTable::class, + 'file_path' => __DIR__ . '/Database/Migrations/create_users_table.php' ], [ 'class' => '\CreateSubscriptionsTable', @@ -98,10 +97,7 @@ protected function withPackageMigrations() ] ) ); - - return $this; } - /** * Runs a collection of migrations. * @@ -109,19 +105,17 @@ protected function withPackageMigrations() */ protected function runMigrations(Collection $migrations) { - $migrations->each(function ($migration) { - $this->runMigration($migration['class'], $migration['file_path']); - }); + $migrations->each(fn ($info) => $this->runMigration($info['class'], $info['file_path'])); } /** * @param string $class * @param string $file_path */ - protected function runMigration($class, $file_path) + protected function runMigration(string $className, string $file_path) { - include_once $file_path; - (new $class)->up(); + require_once $file_path; + (new $className)->up(); } /** diff --git a/tests/BillableTest.php b/tests/BillableTest.php index b7756621..fd87070b 100644 --- a/tests/BillableTest.php +++ b/tests/BillableTest.php @@ -20,7 +20,6 @@ class BillableTest extends BaseTestCase /** @test */ public function testTaxPercentage() { - $this->withPackageMigrations(); $user = User::factory()->create([ 'tax_percentage' => 21.5, ]); @@ -43,7 +42,6 @@ public function returnsFirstPaymentSubscriptionBuilderIfMandateIdOnOwnerIsNull() public function returnsFirstPaymentSubscriptionBuilderIfOwnerMandateIsInvalid() { $this->withConfiguredPlans(); - $this->withPackageMigrations(); $this->withMockedGetMollieCustomer(); $this->withMockedGetMollieMandateRevoked(1, [['mandateId' => 'mdt_unique_revoked_mandate_id']]); @@ -89,8 +87,6 @@ public function returnsDefaultSubscriptionBuilderIfOwnerHasValidMandateId() /** @test */ public function canRetrieveRedeemedCoupons() { - $this->withPackageMigrations(); - $user = User::factory()->create(); $redeemedCoupons = $user->redeemedCoupons; @@ -101,7 +97,6 @@ public function canRetrieveRedeemedCoupons() /** @test */ public function canRedeemCouponForExistingSubscription() { - $this->withPackageMigrations(); $this->withConfiguredPlans(); $this->withMockedCouponRepository(); // 'test-coupon' $this->withMockedGetMollieCustomer(3); @@ -125,7 +120,6 @@ public function canRedeemCouponForExistingSubscription() /** @test */ public function canRedeemCouponAndRevokeOtherCoupons() { - $this->withPackageMigrations(); $this->withConfiguredPlans(); $this->withMockedCouponRepository(); // 'test-coupon' $this->withMockedGetMollieCustomer(3); @@ -153,7 +147,6 @@ public function canRedeemCouponAndRevokeOtherCoupons() public function clearMollieMandate() { Event::fake(); - $this->withPackageMigrations(); $user = $this->getUser(true, ['mollie_mandate_id' => 'foo-bar']); $this->assertEquals('foo-bar', $user->mollieMandateId()); @@ -171,7 +164,6 @@ public function clearMollieMandate() /** @test */ public function canFindInvoice() { - $this->withPackageMigrations(); $user = $this->getUser(); OrderFactory::times(2)->create([ 'owner_id' => $user->id, @@ -187,7 +179,6 @@ public function canFindInvoice() /** @test */ public function findInvoiceReturnsNullIfInvoiceDoesNotExist() { - $this->withPackageMigrations(); $user = $this->getUser(); $invoice = $user->findInvoice('does_not_exist'); @@ -198,7 +189,6 @@ public function findInvoiceReturnsNullIfInvoiceDoesNotExist() /** @test */ public function findInvoiceThrowsExceptionIfInvoiceExistButIsAssociatedWithOtherBillableModel() { - $this->withPackageMigrations(); $userA = $this->getUser(); OrderFactory::new()->create([ 'number' => 'foo-bar', @@ -215,7 +205,6 @@ public function findInvoiceThrowsExceptionIfInvoiceExistButIsAssociatedWithOther /** @test */ public function canFindInvoiceUsingFindInvoiceOrFail() { - $this->withPackageMigrations(); $user = $this->getUser(); OrderFactory::times(2)->create([ 'owner_id' => $user->id, @@ -231,7 +220,6 @@ public function canFindInvoiceUsingFindInvoiceOrFail() /** @test */ public function findInvoiceOrFailThrowsExceptionWhenNotFindingTheInvoice() { - $this->withPackageMigrations(); $user = $this->getUser(); $this->expectException(NotFoundHttpException::class); @@ -242,7 +230,6 @@ public function findInvoiceOrFailThrowsExceptionWhenNotFindingTheInvoice() /** @test */ public function findInvoiceOrFailThrowsExceptionIfInvoiceExistButIsAssociatedWithOtherBillableModel() { - $this->withPackageMigrations(); $userA = $this->getUser(); OrderFactory::new()->create([ 'number' => 'foo-bar', @@ -259,7 +246,6 @@ public function findInvoiceOrFailThrowsExceptionIfInvoiceExistButIsAssociatedWit /** @test */ public function canFindInvoiceByOrderId() { - $this->withPackageMigrations(); $user = $this->getUser(); $user->orders()->saveMany([ @@ -282,7 +268,6 @@ public function canFindInvoiceByOrderId() /** @test */ public function canFindInvoiceByOrderIdUsingFindInvoiceByOrderIdOrFail() { - $this->withPackageMigrations(); $user = $this->getUser(); $user->orders()->saveMany([ diff --git a/tests/CashierTest.php b/tests/CashierTest.php index 829e0036..501cbca1 100644 --- a/tests/CashierTest.php +++ b/tests/CashierTest.php @@ -37,7 +37,6 @@ protected function setUp(): void { parent::setUp(); - $this->withPackageMigrations(); $this->withConfiguredPlans(); } diff --git a/tests/Charge/FirstPaymentChargeBuilderTest.php b/tests/Charge/FirstPaymentChargeBuilderTest.php index c096d519..351eb78f 100644 --- a/tests/Charge/FirstPaymentChargeBuilderTest.php +++ b/tests/Charge/FirstPaymentChargeBuilderTest.php @@ -14,7 +14,6 @@ protected function setUp(): void { parent::setUp(); - $this->withPackageMigrations(); $this->withMockedCreateMollieCustomer(); } diff --git a/tests/Charge/ManageChargesTest.php b/tests/Charge/ManageChargesTest.php index c8694327..969e8a55 100644 --- a/tests/Charge/ManageChargesTest.php +++ b/tests/Charge/ManageChargesTest.php @@ -9,12 +9,6 @@ class ManageChargesTest extends BaseTestCase { - protected function setUp(): void - { - parent::setUp(); - $this->withPackageMigrations(); - } - /** @test */ public function usingMandatedChargeBuilderWhenValidMandate() { diff --git a/tests/Coupon/CouponOrderItemPreprocessorTest.php b/tests/Coupon/CouponOrderItemPreprocessorTest.php index 9812fbd4..f517cdfe 100644 --- a/tests/Coupon/CouponOrderItemPreprocessorTest.php +++ b/tests/Coupon/CouponOrderItemPreprocessorTest.php @@ -13,12 +13,6 @@ class CouponOrderItemPreprocessorTest extends BaseTestCase { - protected function setUp(): void - { - parent::setUp(); - $this->withPackageMigrations(); - } - /** @test */ public function appliesCoupon() { diff --git a/tests/Coupon/MultiCurrencyCouponOrderItemPreprocessorTest.php b/tests/Coupon/MultiCurrencyCouponOrderItemPreprocessorTest.php index 2cabef23..ccb4f4ac 100644 --- a/tests/Coupon/MultiCurrencyCouponOrderItemPreprocessorTest.php +++ b/tests/Coupon/MultiCurrencyCouponOrderItemPreprocessorTest.php @@ -14,12 +14,6 @@ class MultiCurrencyCouponOrderItemPreprocessorTest extends BaseTestCase { - protected function setUp(): void - { - parent::setUp(); - $this->withPackageMigrations(); - } - /** @test */ public function appliesCoupon() { diff --git a/tests/Coupon/PercentageCouponTest.php b/tests/Coupon/PercentageCouponTest.php index f8c55fdb..41d06170 100644 --- a/tests/Coupon/PercentageCouponTest.php +++ b/tests/Coupon/PercentageCouponTest.php @@ -14,12 +14,6 @@ class PercentageCouponTest extends BaseTestCase { - protected function setUp(): void - { - parent::setUp(); - $this->withPackageMigrations(); - } - /** @test */ public function couponCalculatesTheRightPrice() { diff --git a/tests/Coupon/RedeemedCouponTest.php b/tests/Coupon/RedeemedCouponTest.php index 392b9a11..792d4b63 100644 --- a/tests/Coupon/RedeemedCouponTest.php +++ b/tests/Coupon/RedeemedCouponTest.php @@ -12,8 +12,6 @@ class RedeemedCouponTest extends BaseTestCase /** @test */ public function canBeRevoked() { - $this->withPackageMigrations(); - /** @var RedeemedCoupon $redeemedCoupon */ $redeemedCoupon = RedeemedCouponFactory::new()->create(['times_left' => 5]); diff --git a/tests/Credit/CreditTest.php b/tests/Credit/CreditTest.php index 2cd09f26..d4b910e0 100644 --- a/tests/Credit/CreditTest.php +++ b/tests/Credit/CreditTest.php @@ -12,7 +12,6 @@ class CreditTest extends BaseTestCase /** @test */ public function testAddAmountForOwner() { - $this->withPackageMigrations(); $user = User::factory()->create(); Cashier::$creditModel::addAmountForOwner($user, Money::EUR(12345)); @@ -33,7 +32,6 @@ public function testAddAmountForOwner() /** @test */ public function testMaxOutForOwner() { - $this->withPackageMigrations(); $user = User::factory()->create(); Cashier::$creditModel::addAmountForOwner($user, Money::USD(12348)); diff --git a/tests/Database/Migrations/create_users_table.php b/tests/Database/Migrations/create_users_table.php index 32386269..d87e82ed 100644 --- a/tests/Database/Migrations/create_users_table.php +++ b/tests/Database/Migrations/create_users_table.php @@ -13,7 +13,7 @@ class CreateUsersTable extends Migration * * @return void */ - public function up() + public function up(): void { Schema::create('users', function (Blueprint $table) { $table->increments('id'); @@ -33,7 +33,7 @@ public function up() * * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('users'); } diff --git a/tests/FirstPayment/Actions/AddBalanceTest.php b/tests/FirstPayment/Actions/AddBalanceTest.php index 3d6235ae..dbc85a24 100644 --- a/tests/FirstPayment/Actions/AddBalanceTest.php +++ b/tests/FirstPayment/Actions/AddBalanceTest.php @@ -15,7 +15,6 @@ class AddBalanceTest extends BaseTestCase /** @test */ public function canGetPayload() { - $this->withPackageMigrations(); $action = new AddBalance( $this->getMandatedUser(), new Money(1000, new Currency('EUR')), @@ -60,7 +59,6 @@ public function canCreateFromPayload() /** @test */ public function canExecute() { - $this->withPackageMigrations(); $user = User::factory()->create(); $this->assertFalse($user->hasCredit()); diff --git a/tests/FirstPayment/Actions/AddGenericOrderItemTest.php b/tests/FirstPayment/Actions/AddGenericOrderItemTest.php index d66531fa..f1889935 100644 --- a/tests/FirstPayment/Actions/AddGenericOrderItemTest.php +++ b/tests/FirstPayment/Actions/AddGenericOrderItemTest.php @@ -15,8 +15,6 @@ class AddGenericOrderItemTest extends BaseTestCase /** @test */ public function canGetPayload() { - $this->withPackageMigrations(); - $action = new AddGenericOrderItem( $this->getMandatedUser(true, ['tax_percentage' => 20]), new Money(5, new Currency('EUR')), @@ -78,7 +76,6 @@ public function canCreateFromPayloadWithoutTaxPercentage() /** @test */ public function canExecute() { - $this->withPackageMigrations(); $user = User::factory()->create(['tax_percentage' => 20]); $this->assertFalse($user->hasCredit()); diff --git a/tests/FirstPayment/Actions/StartSubscriptionTest.php b/tests/FirstPayment/Actions/StartSubscriptionTest.php index faf5e9c5..dbb8deb0 100644 --- a/tests/FirstPayment/Actions/StartSubscriptionTest.php +++ b/tests/FirstPayment/Actions/StartSubscriptionTest.php @@ -13,7 +13,7 @@ class StartSubscriptionTest extends BaseTestCase protected function setUp(): void { parent::setUp(); - $this->withPackageMigrations() + $this ->withConfiguredPlans() ->withTestNow('2019-01-01'); } diff --git a/tests/FirstPayment/Actions/StartSubscriptionWithPlanIntervalArrayTest.php b/tests/FirstPayment/Actions/StartSubscriptionWithPlanIntervalArrayTest.php index 22dbd05d..af3c9692 100644 --- a/tests/FirstPayment/Actions/StartSubscriptionWithPlanIntervalArrayTest.php +++ b/tests/FirstPayment/Actions/StartSubscriptionWithPlanIntervalArrayTest.php @@ -11,7 +11,7 @@ class StartSubscriptionWithPlanIntervalArrayTest extends BaseTestCase protected function setUp(): void { parent::setUp(); - $this->withPackageMigrations() + $this ->withConfiguredPlansWithIntervalArray() ->withTestNow('2019-01-29'); } diff --git a/tests/FirstPayment/FirstPaymentBuilderTest.php b/tests/FirstPayment/FirstPaymentBuilderTest.php index 7720e611..c9784bc2 100644 --- a/tests/FirstPayment/FirstPaymentBuilderTest.php +++ b/tests/FirstPayment/FirstPaymentBuilderTest.php @@ -19,7 +19,6 @@ protected function setUp(): void { parent::setUp(); - $this->withPackageMigrations(); $this->withMockedCreateMollieCustomer(); } diff --git a/tests/FirstPayment/FirstPaymentHandlerTest.php b/tests/FirstPayment/FirstPaymentHandlerTest.php index 8fbdcefa..962a198a 100644 --- a/tests/FirstPayment/FirstPaymentHandlerTest.php +++ b/tests/FirstPayment/FirstPaymentHandlerTest.php @@ -18,7 +18,6 @@ class FirstPaymentHandlerTest extends BaseTestCase /** @test */ public function handlesMolliePayments() { - $this->withPackageMigrations(); Event::fake(); $molliePayment = $this->getMandatePaymentStub(); diff --git a/tests/Http/Controllers/AftercareWebhookControllerTest.php b/tests/Http/Controllers/AftercareWebhookControllerTest.php index b0005ae9..7a65e3da 100644 --- a/tests/Http/Controllers/AftercareWebhookControllerTest.php +++ b/tests/Http/Controllers/AftercareWebhookControllerTest.php @@ -27,7 +27,6 @@ class AftercareWebhookControllerTest extends BaseTestCase public function itDetectsNewChargebacks() { Event::fake(); - $this->withPackageMigrations(); $molliePayment = new MolliePayment(new MollieApiClient); $molliePayment->id = 'tr_123xyz'; @@ -69,7 +68,6 @@ public function itDetectsNewChargebacks() public function itDetectsNewRefunds() { Event::fake(); - $this->withPackageMigrations(); $this->withConfiguredPlans(); $molliePaymentId = 'tr_123xyz'; diff --git a/tests/Http/Controllers/WebhookControllerTest.php b/tests/Http/Controllers/WebhookControllerTest.php index 723c4c03..84c9273a 100644 --- a/tests/Http/Controllers/WebhookControllerTest.php +++ b/tests/Http/Controllers/WebhookControllerTest.php @@ -71,7 +71,6 @@ public function handlesUnexistingIdGracefully() /** @test **/ public function handlesPaymentFailed() { - $this->withPackageMigrations(); $this->withConfiguredPlans(); $this->withTestNow('2019-01-01'); Event::fake(); @@ -144,7 +143,6 @@ public function handlesPaymentFailed() /** @test **/ public function handlesPaymentPaid() { - $this->withPackageMigrations(); $this->withConfiguredPlans(); Event::fake(); @@ -196,7 +194,6 @@ public function handlesPaymentPaid() /** @test **/ public function skipsIfPaymentStatusUnchanged() { - $this->withPackageMigrations(); Event::fake(); $paymentId = 'tr_payment_paid_id'; diff --git a/tests/ManageSubscriptionTest.php b/tests/ManageSubscriptionTest.php index 4c13addd..3b47c4f4 100644 --- a/tests/ManageSubscriptionTest.php +++ b/tests/ManageSubscriptionTest.php @@ -15,7 +15,6 @@ class ManageSubscriptionTest extends BaseTestCase protected function setUp(): void { parent::setUp(); - $this->withPackageMigrations(); $this->withConfiguredPlans(); } diff --git a/tests/Mollie/BaseMollieInteractionTest.php b/tests/Mollie/BaseMollieInteraction.php similarity index 72% rename from tests/Mollie/BaseMollieInteractionTest.php rename to tests/Mollie/BaseMollieInteraction.php index f26c5f36..cc894654 100644 --- a/tests/Mollie/BaseMollieInteractionTest.php +++ b/tests/Mollie/BaseMollieInteraction.php @@ -6,7 +6,7 @@ use Laravel\Cashier\Tests\BaseTestCase; -abstract class BaseMollieInteractionTest extends BaseTestCase +abstract class BaseMollieInteraction extends BaseTestCase { protected $interactWithMollieAPI = true; } diff --git a/tests/Mollie/CreateMollieCustomerTest.php b/tests/Mollie/CreateMollieCustomerTest.php index 2c8dfab0..2cfdfbf4 100644 --- a/tests/Mollie/CreateMollieCustomerTest.php +++ b/tests/Mollie/CreateMollieCustomerTest.php @@ -7,7 +7,7 @@ use Laravel\Cashier\Mollie\Contracts\CreateMollieCustomer; use Mollie\Api\Resources\Customer; -class CreateMollieCustomerTest extends BaseMollieInteractionTest +class CreateMollieCustomerTest extends BaseMollieInteraction { protected $interactWithMollieAPI = true; diff --git a/tests/Mollie/CreateMolliePaymentTest.php b/tests/Mollie/CreateMolliePaymentTest.php index c493147f..e505a87a 100644 --- a/tests/Mollie/CreateMolliePaymentTest.php +++ b/tests/Mollie/CreateMolliePaymentTest.php @@ -7,7 +7,7 @@ use Laravel\Cashier\Mollie\Contracts\CreateMolliePayment; use Mollie\Api\Resources\Payment; -class CreateMolliePaymentTest extends BaseMollieInteractionTest +class CreateMolliePaymentTest extends BaseMollieInteraction { /** * @test diff --git a/tests/Mollie/CreateMollieRefundTest.php b/tests/Mollie/CreateMollieRefundTest.php index 6d3e7a1d..161d19cc 100644 --- a/tests/Mollie/CreateMollieRefundTest.php +++ b/tests/Mollie/CreateMollieRefundTest.php @@ -7,7 +7,7 @@ use Laravel\Cashier\Mollie\Contracts\CreateMollieRefund; use Mollie\Api\Resources\Refund; -class CreateMollieRefundTest extends BaseMollieInteractionTest +class CreateMollieRefundTest extends BaseMollieInteraction { /** * @test diff --git a/tests/Mollie/GetMollieCustomerTest.php b/tests/Mollie/GetMollieCustomerTest.php index 543f17a3..53db9704 100644 --- a/tests/Mollie/GetMollieCustomerTest.php +++ b/tests/Mollie/GetMollieCustomerTest.php @@ -7,7 +7,7 @@ use Laravel\Cashier\Mollie\Contracts\GetMollieCustomer; use Mollie\Api\Resources\Customer; -class GetMollieCustomerTest extends BaseMollieInteractionTest +class GetMollieCustomerTest extends BaseMollieInteraction { /** * @test diff --git a/tests/Mollie/GetMollieMandateTest.php b/tests/Mollie/GetMollieMandateTest.php index 60774089..8edeb478 100644 --- a/tests/Mollie/GetMollieMandateTest.php +++ b/tests/Mollie/GetMollieMandateTest.php @@ -7,7 +7,7 @@ use Laravel\Cashier\Mollie\Contracts\GetMollieMandate; use Mollie\Api\Resources\Mandate; -class GetMollieMandateTest extends BaseMollieInteractionTest +class GetMollieMandateTest extends BaseMollieInteraction { /** * @test diff --git a/tests/Mollie/GetMolliePaymentTest.php b/tests/Mollie/GetMolliePaymentTest.php index b4fe4717..7b84665f 100644 --- a/tests/Mollie/GetMolliePaymentTest.php +++ b/tests/Mollie/GetMolliePaymentTest.php @@ -7,7 +7,7 @@ use Laravel\Cashier\Mollie\Contracts\GetMolliePayment; use Mollie\Api\Resources\Payment; -class GetMolliePaymentTest extends BaseMollieInteractionTest +class GetMolliePaymentTest extends BaseMollieInteraction { /** * @test diff --git a/tests/Mollie/GetMollieRefundTest.php b/tests/Mollie/GetMollieRefundTest.php index 0baa8a50..bd619bce 100644 --- a/tests/Mollie/GetMollieRefundTest.php +++ b/tests/Mollie/GetMollieRefundTest.php @@ -7,7 +7,7 @@ use Laravel\Cashier\Mollie\Contracts\GetMollieRefund; use Mollie\Api\Resources\Refund; -class GetMollieRefundTest extends BaseMollieInteractionTest +class GetMollieRefundTest extends BaseMollieInteraction { /** * @test diff --git a/tests/Mollie/UpdateMolliePaymentTest.php b/tests/Mollie/UpdateMolliePaymentTest.php index d059061f..5199adb7 100644 --- a/tests/Mollie/UpdateMolliePaymentTest.php +++ b/tests/Mollie/UpdateMolliePaymentTest.php @@ -7,8 +7,9 @@ use Illuminate\Support\Str; use Laravel\Cashier\Mollie\Contracts\UpdateMolliePayment; use Mollie\Api\Resources\Payment; +use Mollie\Laravel\Facades\Mollie; -class UpdateMolliePaymentTest extends BaseMollieInteractionTest +class UpdateMolliePaymentTest extends BaseMollieInteraction { /** * @test @@ -18,9 +19,9 @@ public function testExecute() { /** @var UpdateMolliePayment $action */ $action = $this->app->make(UpdateMolliePayment::class); - $payment = mollie()->payments->get($this->getUpdatablePaymentId()); + $payment = Mollie::api()->payments->get($this->getUpdatablePaymentId()); $oldWebhookUrl = $payment->webhookUrl; - $newWebhookUrl = 'https://example.com/'.Str::uuid(); + $newWebhookUrl = 'https://example.com/' . Str::uuid(); $payment->webhookUrl = $newWebhookUrl; $result = $action->execute($payment); diff --git a/tests/Order/OrderCollectionTest.php b/tests/Order/OrderCollectionTest.php index 72a8ef4d..cd5a3d4b 100644 --- a/tests/Order/OrderCollectionTest.php +++ b/tests/Order/OrderCollectionTest.php @@ -12,7 +12,6 @@ class OrderCollectionTest extends BaseTestCase /** @test */ public function canGetInvoices() { - $this->withPackageMigrations(); $user = User::factory()->create(); $orders = $user->orders()->saveMany(OrderFactory::new()->times(2)->make()); diff --git a/tests/Order/OrderItemCollectionTest.php b/tests/Order/OrderItemCollectionTest.php index ea218284..35398862 100644 --- a/tests/Order/OrderItemCollectionTest.php +++ b/tests/Order/OrderItemCollectionTest.php @@ -83,8 +83,6 @@ public function cannotGetTotalForMultipleCurrencies() /** @test */ public function testOwners() { - $this->withPackageMigrations(); - User::factory(3)->create()->each(function ($owner) { $owner->orderItems()->saveMany(OrderItemFactory::new()->times(2)->make()); }); @@ -160,8 +158,6 @@ public function testWhereCurrency() /** @test */ public function testChunkByOwner() { - $this->withPackageMigrations(); - User::factory()->create(['id' => 1]); User::factory()->create(['id' => 2]); @@ -215,8 +211,6 @@ public function testChunkByCurrency() /** @test */ public function testChunkByOwnerAndCurrency() { - $this->withPackageMigrations(); - User::factory()->create(['id' => 1]); User::factory()->create(['id' => 2]); diff --git a/tests/Order/OrderItemTest.php b/tests/Order/OrderItemTest.php index 1deaa20c..f34c5824 100644 --- a/tests/Order/OrderItemTest.php +++ b/tests/Order/OrderItemTest.php @@ -66,8 +66,6 @@ public function testGetAttributesAsMoney() public function testScopeProcessed() { - $this->withPackageMigrations(); - OrderItemFactory::new()->times(3)->create([ 'order_id' => null, ]); @@ -82,8 +80,6 @@ public function testScopeProcessed() public function testScopeUnprocessed() { - $this->withPackageMigrations(); - OrderItemFactory::new()->times(3)->create([ 'order_id' => null, ]); @@ -98,8 +94,6 @@ public function testScopeUnprocessed() public function testScopeShouldProcess() { - $this->withPackageMigrations(); - OrderItemFactory::new()->times(2)->create([ 'order_id' => 1, 'process_at' => now()->subHour(), @@ -118,8 +112,6 @@ public function testScopeShouldProcess() public function testScopeDue() { - $this->withPackageMigrations(); - OrderItemFactory::new()->times(2)->create([ 'process_at' => now()->subHour(), ]); diff --git a/tests/Order/OrderNumberGeneratorTest.php b/tests/Order/OrderNumberGeneratorTest.php index caf5a8ac..38412f02 100644 --- a/tests/Order/OrderNumberGeneratorTest.php +++ b/tests/Order/OrderNumberGeneratorTest.php @@ -17,7 +17,6 @@ protected function setUp(): void { parent::setUp(); $this->generator = new OrderNumberGenerator; - $this->withPackageMigrations(); } /** @test */ diff --git a/tests/Order/OrderTest.php b/tests/Order/OrderTest.php index 510154af..b7c95d6e 100644 --- a/tests/Order/OrderTest.php +++ b/tests/Order/OrderTest.php @@ -30,7 +30,6 @@ protected function setUp(): void { parent::setUp(); - $this->withPackageMigrations(); $this->withConfiguredPlans(); } diff --git a/tests/PaymentTest.php b/tests/PaymentTest.php index 5c56d265..6c67cf93 100644 --- a/tests/PaymentTest.php +++ b/tests/PaymentTest.php @@ -11,8 +11,6 @@ class PaymentTest extends BaseTestCase /** @test */ public function canCreateFromBasicMolliePayment() { - $this->withPackageMigrations(); - $molliePayment = new MolliePayment(new MollieApiClient); $molliePayment->id = 'tr_dummy_payment_id'; $molliePayment->status = 'dummy_status'; @@ -40,8 +38,6 @@ public function canCreateFromBasicMolliePayment() /** @test */ public function canCreateFromMolliePaymentWithRefundsAndChargebacks() { - $this->withPackageMigrations(); - $molliePayment = new MolliePayment(new MollieApiClient); $molliePayment->id = 'tr_dummy_payment_id'; $molliePayment->status = 'dummy_status'; diff --git a/tests/Refunds/RefundTest.php b/tests/Refunds/RefundTest.php index 3d813c95..0325fd8c 100644 --- a/tests/Refunds/RefundTest.php +++ b/tests/Refunds/RefundTest.php @@ -21,7 +21,6 @@ class RefundTest extends BaseTestCase public function canHandleProcessedMollieRefund() { Event::fake(); - $this->withPackageMigrations(); $user = $this->getCustomerUser(); $originalOrderItems = OrderItemFactory::new()->times(2)->create(); @@ -60,7 +59,6 @@ public function canHandleProcessedMollieRefund() public function canHandleFailedMollieRefund() { Event::fake(); - $this->withPackageMigrations(); $user = $this->getCustomerUser(); $originalOrderItems = OrderItemFactory::new()->times(2)->create(); diff --git a/tests/Refunds/RefundsBuilderTest.php b/tests/Refunds/RefundsBuilderTest.php index 05be55c0..6875b5d3 100644 --- a/tests/Refunds/RefundsBuilderTest.php +++ b/tests/Refunds/RefundsBuilderTest.php @@ -19,13 +19,6 @@ class RefundsBuilderTest extends BaseTestCase { - protected function setUp(): void - { - parent::setUp(); - - $this->withPackageMigrations(); - } - /** @test */ public function can_create_a_refund_for_a_complete_order(): void { diff --git a/tests/SubscriptionBuilder/FirstPaymentSubscriptionBuilderApplyCorrectTaxTest.php b/tests/SubscriptionBuilder/FirstPaymentSubscriptionBuilderApplyCorrectTaxTest.php index f4140ec1..eec461d6 100644 --- a/tests/SubscriptionBuilder/FirstPaymentSubscriptionBuilderApplyCorrectTaxTest.php +++ b/tests/SubscriptionBuilder/FirstPaymentSubscriptionBuilderApplyCorrectTaxTest.php @@ -16,7 +16,6 @@ protected function setUp(): void parent::setUp(); Cashier::useCurrency('eur'); $this->withTestNow('2019-01-01'); - $this->withPackageMigrations(); $this->withConfiguredPlans(); $this->user = $this->getCustomerUser(true, [ 'tax_percentage' => 21, diff --git a/tests/SubscriptionBuilder/FirstPaymentSubscriptionBuilderTest.php b/tests/SubscriptionBuilder/FirstPaymentSubscriptionBuilderTest.php index c01872b5..9c112029 100644 --- a/tests/SubscriptionBuilder/FirstPaymentSubscriptionBuilderTest.php +++ b/tests/SubscriptionBuilder/FirstPaymentSubscriptionBuilderTest.php @@ -28,7 +28,6 @@ protected function setUp(): void parent::setUp(); Cashier::useCurrency('eur'); $this->withTestNow('2019-01-01'); - $this->withPackageMigrations(); $this->withConfiguredPlans(); $this->user = $this->getCustomerUser(true, [ 'tax_percentage' => 20, diff --git a/tests/SubscriptionBuilder/MandatedSubscriptionBuilderTest.php b/tests/SubscriptionBuilder/MandatedSubscriptionBuilderTest.php index 54f378e5..643679ad 100644 --- a/tests/SubscriptionBuilder/MandatedSubscriptionBuilderTest.php +++ b/tests/SubscriptionBuilder/MandatedSubscriptionBuilderTest.php @@ -15,7 +15,6 @@ class MandatedSubscriptionBuilderTest extends BaseTestCase protected function setUp(): void { parent::setUp(); - $this->withPackageMigrations(); $this->withConfiguredPlans(); $this->user = $this->getCustomerUser(true, [ 'tax_percentage' => 20, diff --git a/tests/SubscriptionTest.php b/tests/SubscriptionTest.php index 9d7338e3..0ac7c18e 100644 --- a/tests/SubscriptionTest.php +++ b/tests/SubscriptionTest.php @@ -18,7 +18,6 @@ class SubscriptionTest extends BaseTestCase protected function setUp(): void { parent::setUp(); - $this->withPackageMigrations(); } /** @test */ diff --git a/tests/SwapSubscriptionPlanTest.php b/tests/SwapSubscriptionPlanTest.php index e70a6d8c..b3ef5af7 100644 --- a/tests/SwapSubscriptionPlanTest.php +++ b/tests/SwapSubscriptionPlanTest.php @@ -17,7 +17,6 @@ protected function setUp(): void { parent::setUp(); - $this->withPackageMigrations(); $this->withTestNow('2019-1-1'); $this->withConfiguredPlans(); diff --git a/tests/Traits/InteractsWithMocks.php b/tests/Traits/InteractsWithMocks.php index 9b312a13..e04b4c3b 100644 --- a/tests/Traits/InteractsWithMocks.php +++ b/tests/Traits/InteractsWithMocks.php @@ -15,13 +15,12 @@ use Laravel\Cashier\Mollie\Contracts\UpdateMolliePayment; use Laravel\Cashier\Mollie\GetMollieMethodMaximumAmount; use Mollie\Api\Exceptions\ApiException; -use Mollie\Api\MollieApiClient; use Mollie\Api\Resources\Customer; use Mollie\Api\Resources\Mandate; use Mollie\Api\Resources\Payment; use Money\Currency; use Money\Money; -use Mollie\Laravel\Wrappers\MollieApiWrapper; +use Mollie\Api\MollieApiClient; /** * @mixin \Laravel\Cashier\Tests\BaseTestCase @@ -32,7 +31,7 @@ public function setUpInteractsWithMocks(): void { if (!$this->interactWithMollieAPI) { // Disable the Mollie API - $this->mock(MollieApiWrapper::class, null); + $this->mock(MollieApiClient::class, null); } } diff --git a/tests/UpdatePaymentMethod/UpdatePaymentMethodTest.php b/tests/UpdatePaymentMethod/UpdatePaymentMethodTest.php index a161c2c5..06a2137d 100644 --- a/tests/UpdatePaymentMethod/UpdatePaymentMethodTest.php +++ b/tests/UpdatePaymentMethod/UpdatePaymentMethodTest.php @@ -17,8 +17,6 @@ class UpdatePaymentMethodTest extends BaseTestCase /** @test */ public function canUpdatePaymentMethod() { - $this->withPackageMigrations(); - $owner = User::factory()->create([ 'mollie_mandate_id' => 'mdt_unique_mandate_id', ]); diff --git a/tests/UpdatePaymentMethod/UpdatePaymentMethodWithoutAddingToBalanceTest.php b/tests/UpdatePaymentMethod/UpdatePaymentMethodWithoutAddingToBalanceTest.php index 265f920a..031fefe6 100644 --- a/tests/UpdatePaymentMethod/UpdatePaymentMethodWithoutAddingToBalanceTest.php +++ b/tests/UpdatePaymentMethod/UpdatePaymentMethodWithoutAddingToBalanceTest.php @@ -2,6 +2,7 @@ namespace Laravel\Cashier\Tests\UpdatePaymentMethod; +use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Support\Facades\Event; use Laravel\Cashier\Cashier; use Laravel\Cashier\Events\MandateUpdated; @@ -17,8 +18,6 @@ class UpdatePaymentMethodWithoutAddingToBalanceTest extends BaseTestCase /** @test */ public function canUpdatePaymentMethodWithoutAddingToBalance() { - $this->withPackageMigrations(); - $owner = User::factory()->create([ 'mollie_mandate_id' => 'mdt_unique_mandate_id', ]);