Page MenuHomePhorge

D5132.1774824967.diff
No OneTemporary

Authored By
Unknown
Size
61 KB
Referenced Files
None
Subscribers
None

D5132.1774824967.diff

diff --git a/config.demo/src/.env b/config.demo/src/.env
--- a/config.demo/src/.env
+++ b/config.demo/src/.env
@@ -132,14 +132,7 @@
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
-PUSHER_APP_ID=
-PUSHER_APP_KEY=
-PUSHER_APP_SECRET=
-PUSHER_APP_CLUSTER=mt1
-
MIX_ASSET_PATH='/'
-MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
-MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
PASSWORD_POLICY=
diff --git a/docker/swoole/Dockerfile b/docker/swoole/Dockerfile
--- a/docker/swoole/Dockerfile
+++ b/docker/swoole/Dockerfile
@@ -1,11 +1,12 @@
FROM apheleia/almalinux9
-ARG SWOOLE_VERSION=v5.1.2
-ENV HOME=/opt/app-root/src
+ARG PHP_VERSION=8.2
+ARG SWOOLE_VERSION=v6.0.1
+ENV HOME=/opt/app-root/src
RUN dnf module reset php && \
- dnf module -y enable php:8.1 && \
+ dnf module -y enable php:${PHP_VERSION} && \
dnf module -y enable nodejs:20 && \
dnf -y install \
--setopt=install_weak_deps=False \
diff --git a/src/app/Auth/Utils.php b/src/app/Auth/Utils.php
--- a/src/app/Auth/Utils.php
+++ b/src/app/Auth/Utils.php
@@ -14,7 +14,7 @@
*
* @return string|null Encrypted token, Null on failure
*/
- public static function tokenCreate($userid, $ttl = 10): ?string
+ public static function tokenCreate($userid, int $ttl = 10): ?string
{
// Note: Laravel's Crypt::encryptString() creates output that is too long
// We need output string to be max. 127 characters. For that reason
diff --git a/src/app/Console/Commands/MollieInfo.php b/src/app/Console/Commands/MollieInfo.php
--- a/src/app/Console/Commands/MollieInfo.php
+++ b/src/app/Console/Commands/MollieInfo.php
@@ -4,6 +4,7 @@
use App\Console\Command;
use App\User;
+use Mollie\Laravel\Facades\Mollie;
class MollieInfo extends Command
{
@@ -68,7 +69,7 @@
} else {
$this->info("Available payment methods:");
- foreach (mollie()->methods()->all() as $method) {
+ foreach (Mollie::api()->methods->all() as $method) {
$this->info("- {$method->description} ({$method->id}):");
$this->info(" status: {$method->status}");
$this->info(sprintf(
diff --git a/src/app/Console/Commands/OwnerSwapCommand.php b/src/app/Console/Commands/OwnerSwapCommand.php
--- a/src/app/Console/Commands/OwnerSwapCommand.php
+++ b/src/app/Console/Commands/OwnerSwapCommand.php
@@ -5,6 +5,7 @@
use App\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Queue;
+use Mollie\Laravel\Facades\Mollie;
class OwnerSwapCommand extends Command
{
@@ -104,7 +105,7 @@
private function updatePaymentCustomer(\App\Wallet $wallet): void
{
if ($mollie_id = $wallet->getSetting('mollie_id')) {
- mollie()->customers()->update($mollie_id, [
+ Mollie::api()->customers->update($mollie_id, [
'name' => $wallet->owner->name(),
'email' => $wallet->id . '@private.' . \config('app.domain'),
]);
diff --git a/src/app/Console/Commands/PasswordRetentionCommand.php b/src/app/Console/Commands/PasswordRetentionCommand.php
--- a/src/app/Console/Commands/PasswordRetentionCommand.php
+++ b/src/app/Console/Commands/PasswordRetentionCommand.php
@@ -60,7 +60,7 @@
}
// @phpstan-ignore-next-line
- $nextUpdate = $lastUpdate->copy()->addMonthsWithoutOverflow($account->max_age);
+ $nextUpdate = $lastUpdate->copy()->addMonthsWithoutOverflow((int) $account->max_age);
$diff = Carbon::now()->diffInDays($nextUpdate, false);
// The password already expired, do nothing
diff --git a/src/app/Group.php b/src/app/Group.php
--- a/src/app/Group.php
+++ b/src/app/Group.php
@@ -17,7 +17,7 @@
*
* @property int $id The group identifier
* @property string $email An email address
- * @property string $members A comma-separated list of email addresses
+ * @property array $members A list of email addresses
* @property string $name The group name
* @property int $status The group status
* @property int $tenant_id Tenant identifier
diff --git a/src/app/Http/Controllers/API/V4/FsController.php b/src/app/Http/Controllers/API/V4/FsController.php
--- a/src/app/Http/Controllers/API/V4/FsController.php
+++ b/src/app/Http/Controllers/API/V4/FsController.php
@@ -100,7 +100,7 @@
return $this->errorResponse($file);
}
- $result = $file->properties()->where('key', 'like', 'share-%')->get()->map(
+ $result = $file->properties()->whereLike('key', 'share-%')->get()->map(
fn($prop) => self::permissionToClient($prop->key, $prop->value)
);
@@ -146,7 +146,7 @@
// Check if it already exists
if (empty($errors['user'])) {
- if ($file->properties()->where('key', 'like', 'share-%')->where('value', 'like', "$user:%")->exists()) {
+ if ($file->properties()->whereLike('key', 'share-%')->whereLike('value', "{$user}:%")->exists()) {
$errors['user'] = self::trans('validation.file-perm-exists');
}
}
@@ -244,7 +244,7 @@
$user = \strtolower($request->input('user'));
if (empty($errors['user']) && strpos($property->value, "$user:") !== 0) {
- if ($file->properties()->where('key', 'like', 'share-%')->where('value', 'like', "$user:%")->exists()) {
+ if ($file->properties()->whereLike('key', 'share-%')->whereLike('value', "{$user}:%")->exists()) {
$errors['user'] = self::trans('validation.file-perm-exists');
}
}
@@ -304,7 +304,7 @@
}
if (strlen($search)) {
- $result->whereLike('fs_properties.value', $search);
+ $result->whereLike('fs_properties.value', "%{$search}%");
}
$result = $result->orderBy('name')
@@ -666,7 +666,7 @@
->where('fs_properties.key', $request->input('deduplicate-property'));
})
->where('type', '&', $type)
- ->whereLike('fs_properties.value', $request->input('deduplicate-value'))
+ ->whereLike('fs_properties.value', '%' . $request->input('deduplicate-value') . '%')
->first();
// FIXME: Should we throw an error if there's more than one item?
diff --git a/src/app/Http/Controllers/API/V4/Reseller/InvitationsController.php b/src/app/Http/Controllers/API/V4/Reseller/InvitationsController.php
--- a/src/app/Http/Controllers/API/V4/Reseller/InvitationsController.php
+++ b/src/app/Http/Controllers/API/V4/Reseller/InvitationsController.php
@@ -75,7 +75,7 @@
if (strpos($search, '@')) {
$result->where('email', $search);
} else {
- $result->whereLike('email', $search);
+ $result->whereLike('email', "%{$search}%");
}
}
diff --git a/src/app/Http/Controllers/API/V4/RoomsController.php b/src/app/Http/Controllers/API/V4/RoomsController.php
--- a/src/app/Http/Controllers/API/V4/RoomsController.php
+++ b/src/app/Http/Controllers/API/V4/RoomsController.php
@@ -69,7 +69,7 @@
}
$rooms = $user->rooms(true)
- ->union($shared) // @phpstan-ignore-line
+ ->union($shared)
->orderBy('name')
->get()
->map(function ($room) {
diff --git a/src/app/Http/Controllers/API/V4/SearchController.php b/src/app/Http/Controllers/API/V4/SearchController.php
--- a/src/app/Http/Controllers/API/V4/SearchController.php
+++ b/src/app/Http/Controllers/API/V4/SearchController.php
@@ -42,8 +42,8 @@
->where('user_id', $user->id);
if (strlen($search)) {
- $aliases->whereLike('alias', $search);
- $query->whereLike('email', $search);
+ $aliases->whereLike('alias', "%{$search}%");
+ $query->whereLike('email', "%{$search}%");
}
if ($with_aliases) {
@@ -92,7 +92,7 @@
// Sub-query for user IDs who's names match the search criteria
$foundUserIds = UserSetting::select('user_id')
->whereIn('key', ['first_name', 'last_name'])
- ->whereLike('value', $search)
+ ->whereLike('value', "%{$search}%")
->whereIn('user_id', $allUsers);
// Prepare the query
@@ -102,12 +102,12 @@
if (strlen($search)) {
$query->where(function ($query) use ($foundUserIds, $search) {
- $query->whereLike('email', $search)
+ $query->whereLike('email', "%{$search}%")
->orWhereIn('id', $foundUserIds);
});
$aliases->where(function ($query) use ($foundUserIds, $search) {
- $query->whereLike('alias', $search)
+ $query->whereLike('alias', "%{$search}%")
->orWhereIn('user_id', $foundUserIds);
});
}
diff --git a/src/app/Http/Controllers/API/V4/UsersController.php b/src/app/Http/Controllers/API/V4/UsersController.php
--- a/src/app/Http/Controllers/API/V4/UsersController.php
+++ b/src/app/Http/Controllers/API/V4/UsersController.php
@@ -72,14 +72,14 @@
$allUsers1 = clone $result;
$allUsers2 = clone $result;
- $result->whereLike('email', $search)
+ $result->whereLike('email', "%{$search}%")
->union(
$allUsers1->join('user_aliases', 'users.id', '=', 'user_aliases.user_id')
- ->whereLike('alias', $search)
+ ->whereLike('alias', "%{$search}%")
)
->union(
$allUsers2->join('user_settings', 'users.id', '=', 'user_settings.user_id')
- ->whereLike('value', $search)
+ ->whereLike('value', "%{$search}%")
->whereIn('key', ['first_name', 'last_name'])
);
}
diff --git a/src/app/Http/Controllers/API/V4/WalletsController.php b/src/app/Http/Controllers/API/V4/WalletsController.php
--- a/src/app/Http/Controllers/API/V4/WalletsController.php
+++ b/src/app/Http/Controllers/API/V4/WalletsController.php
@@ -349,7 +349,7 @@
'parts' => 1,
];
- if ($now->diff($until)->days > 31) {
+ if ($now->diffAsDateInterval($until)->days > 31) {
$diffOptions['parts'] = 2;
}
diff --git a/src/app/Observers/UserObserver.php b/src/app/Observers/UserObserver.php
--- a/src/app/Observers/UserObserver.php
+++ b/src/app/Observers/UserObserver.php
@@ -2,6 +2,7 @@
namespace App\Observers;
+use App\Group;
use App\User;
use App\Wallet;
@@ -92,6 +93,7 @@
$wallet = $user->wallet();
if ($wallet && $wallet->owner) {
$wallet->owner->groups()->each(function ($group) use ($user) {
+ /** @var Group $group */
if (in_array($user->email, $group->members)) {
$group->members = array_diff($group->members, [$user->email]);
$group->save();
diff --git a/src/app/Policy/RateLimitWhitelist.php b/src/app/Policy/RateLimitWhitelist.php
--- a/src/app/Policy/RateLimitWhitelist.php
+++ b/src/app/Policy/RateLimitWhitelist.php
@@ -4,6 +4,13 @@
use Illuminate\Database\Eloquent\Model;
+/**
+ * The eloquent definition of a RateLimitWhitelist entry.
+ *
+ * @property ?object $whitelistable The whitelistable object
+ * @property int|string $whitelistable_id The whitelistable object identifier
+ * @property string $whitelistable_type The whitelistable object type
+ */
class RateLimitWhitelist extends Model
{
/** @var array<int, string> The attributes that are mass assignable */
diff --git a/src/app/Providers/AppServiceProvider.php b/src/app/Providers/AppServiceProvider.php
--- a/src/app/Providers/AppServiceProvider.php
+++ b/src/app/Providers/AppServiceProvider.php
@@ -129,28 +129,6 @@
}
);
- // Query builder 'whereLike' mocro
- Builder::macro(
- 'whereLike',
- function (string $column, string $search, int $mode = 0) {
- $search = addcslashes($search, '%_');
-
- switch ($mode) {
- case 2:
- $search .= '%';
- break;
- case 1:
- $search = '%' . $search;
- break;
- default:
- $search = '%' . $search . '%';
- }
-
- /** @var Builder $this */
- return $this->where($column, 'like', $search);
- }
- );
-
Http::macro('withSlowLog', function () {
return Http::withOptions([
'on_stats' => function (\GuzzleHttp\TransferStats $stats) {
@@ -164,6 +142,15 @@
]);
});
+ Http::macro('fakeClear', function () {
+ $reflection = new \ReflectionObject(Http::getFacadeRoot());
+ $property = $reflection->getProperty('stubCallbacks');
+ $property->setAccessible(true);
+ $property->setValue(Http::getFacadeRoot(), collect());
+
+ return Http::getFacadeRoot();
+ });
+
$this->applyOverrideConfig();
}
}
diff --git a/src/app/Providers/EventServiceProvider.php b/src/app/Providers/EventServiceProvider.php
--- a/src/app/Providers/EventServiceProvider.php
+++ b/src/app/Providers/EventServiceProvider.php
@@ -38,4 +38,14 @@
{
return false;
}
+
+ /**
+ * Configure the proper event listeners for email verification.
+ *
+ * @return void
+ */
+ protected function configureEmailVerification()
+ {
+ // No body disables default Registered event listener
+ }
}
diff --git a/src/app/Providers/Payment/Coinbase.php b/src/app/Providers/Payment/Coinbase.php
--- a/src/app/Providers/Payment/Coinbase.php
+++ b/src/app/Providers/Payment/Coinbase.php
@@ -176,9 +176,9 @@
// Store the payment reference in database
$payment['status'] = Payment::STATUS_OPEN;
- //We take the code instead of the id because it fits into our current db schema and the id doesn't
+ // We take the code instead of the id because it fits into our current db schema and the id doesn't
$payment['id'] = $json['data']['code'];
- //We store in satoshis (the database stores it as INTEGER type)
+ // We store in satoshis (the database stores it as INTEGER type)
$payment['currency_amount'] = $json['data']['pricing']['bitcoin']['amount'] * self::SATOSHI_MULTIPLIER;
$payment['currency'] = 'BTC';
diff --git a/src/app/Providers/Payment/Mollie.php b/src/app/Providers/Payment/Mollie.php
--- a/src/app/Providers/Payment/Mollie.php
+++ b/src/app/Providers/Payment/Mollie.php
@@ -8,6 +8,7 @@
use Illuminate\Support\Facades\DB;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Types;
+use Mollie\Laravel\Facades\Mollie as MollieAPI;
class Mollie extends \App\Providers\PaymentProvider
{
@@ -41,7 +42,7 @@
*/
public static function healthcheck()
{
- mollie()->methods()->allActive();
+ MollieAPI::api()->methods->allActive();
return true;
}
@@ -88,7 +89,7 @@
// Create the payment in Mollie
try {
- $response = mollie()->payments()->create($request);
+ $response = MollieAPI::api()->payments->create($request);
} catch (ApiException $e) {
self::logRequestError($request, $e, "Failed to create mandate");
throw $e;
@@ -225,7 +226,7 @@
// Create the payment in Mollie
try {
- $response = mollie()->payments()->create($request);
+ $response = MollieAPI::api()->payments->create($request);
} catch (ApiException $e) {
self::logRequestError($request, $e, "Failed to create payment");
throw $e;
@@ -253,7 +254,7 @@
*/
public function cancel(Wallet $wallet, $paymentId): bool
{
- $response = mollie()->payments()->delete($paymentId);
+ $response = MollieAPI::api()->payments->delete($paymentId);
$db_payment = Payment::find($paymentId);
$db_payment->status = $response->status;
@@ -306,7 +307,7 @@
// Create the payment in Mollie
try {
- $response = mollie()->payments()->create($request);
+ $response = MollieAPI::api()->payments->create($request);
} catch (ApiException $e) {
self::logRequestError($request, $e, "Failed to create payment");
throw $e;
@@ -370,7 +371,7 @@
try {
// Get the payment details from Mollie
// TODO: Consider https://github.com/mollie/mollie-api-php/issues/502 when it's fixed
- $mollie_payment = mollie()->payments()->get($payment_id);
+ $mollie_payment = MollieAPI::api()->payments->get($payment_id);
$refunds = [];
@@ -480,7 +481,7 @@
// Register the user in Mollie
if (empty($customer_id) && $create) {
- $customer = mollie()->customers()->create([
+ $customer = MollieAPI::api()->customers->create([
'name' => $wallet->owner->name(),
'email' => $wallet->id . '@private.' . \config('app.domain'),
]);
@@ -503,7 +504,7 @@
// Get the manadate reference we already have
if ($settings['mollie_id'] && $settings['mollie_mandate_id']) {
try {
- return mollie()->mandates()->getForId($settings['mollie_id'], $settings['mollie_mandate_id']);
+ return MollieAPI::api()->mandates->getForId($settings['mollie_id'], $settings['mollie_mandate_id']);
} catch (ApiException $e) {
// FIXME: What about 404?
if ($e->getCode() == 410) {
@@ -580,7 +581,7 @@
public function providerPaymentMethods(string $type, string $currency): array
{
// Prefer methods in the system currency
- $providerMethods = (array) mollie()->methods()->allActive(
+ $providerMethods = (array) MollieAPI::api()->methods->allActive(
[
'sequenceType' => $type,
'amount' => [
@@ -592,7 +593,7 @@
// Get EUR methods (e.g. bank transfers are in EUR only)
if ($currency != 'EUR') {
- $eurMethods = (array) mollie()->methods()->allActive(
+ $eurMethods = (array) MollieAPI::api()->methods->allActive(
[
'sequenceType' => $type,
'amount' => [
@@ -634,7 +635,7 @@
*/
public function getPayment($paymentId): array
{
- $payment = mollie()->payments()->get($paymentId);
+ $payment = MollieAPI::api()->payments->get($paymentId);
return [
'id' => $payment->id,
diff --git a/src/app/Utils.php b/src/app/Utils.php
--- a/src/app/Utils.php
+++ b/src/app/Utils.php
@@ -83,7 +83,7 @@
$start = new Carbon('first day of last month');
$end = new Carbon('last day of last month');
- return $start->diffInDays($end) + 1;
+ return intval($start->diffInDays($end)) + 1;
}
/**
diff --git a/src/app/Wallet.php b/src/app/Wallet.php
--- a/src/app/Wallet.php
+++ b/src/app/Wallet.php
@@ -596,7 +596,7 @@
{
$plan = $this->plan();
$freeMonths = $plan ? $plan->free_months : 0;
- $trialEnd = $freeMonths ? $this->owner->created_at->copy()->addMonthsWithoutOverflow($freeMonths) : null;
+ $trialEnd = $freeMonths ? $this->owner->created_at->copy()->addMonthsWithoutOverflow((int) $freeMonths) : null;
if ($trialEnd) {
// Get all SKUs assigned to the plan (they are free in trial)
@@ -787,14 +787,14 @@
$fee = 0;
// Charge for full months first
- if (($diff = $startDate->diffInMonths($endDate)) > 0) {
+ if (($diff = intval($startDate->diffInMonths($endDate, true))) > 0) {
$cost += floor($entitlement->cost * $discountRate) * $diff;
$fee += $entitlement->fee * $diff;
$startDate->addMonthsWithoutOverflow($diff);
}
// Charge for the rest of the period
- if (($diff = $startDate->diffInDays($endDate)) > 0) {
+ if (($diff = intval($startDate->diffInDays($endDate, true))) > 0) {
// The price per day is based on the number of days in the month(s)
// Note: The $endDate does not have to be the current month
$endMonthDiff = $endDate->day > $diff ? $diff : $endDate->day;
@@ -813,7 +813,7 @@
}
} else {
// Note: In this mode we expect to charge the entitlement for full month(s) only
- $diff = $startDate->diffInMonths($endDate);
+ $diff = (int) $startDate->diffInMonths($endDate, true);
if ($diff <= 0) {
// Do not update updated_at column (not a full month) unless trial end date
diff --git a/src/artisan b/src/artisan
--- a/src/artisan
+++ b/src/artisan
@@ -1,53 +1,18 @@
#!/usr/bin/env php
<?php
-define('LARAVEL_START', microtime(true));
+use Illuminate\Foundation\Application;
+use Symfony\Component\Console\Input\ArgvInput;
-/*
-|--------------------------------------------------------------------------
-| Register The Auto Loader
-|--------------------------------------------------------------------------
-|
-| Composer provides a convenient, automatically generated class loader
-| for our application. We just need to utilize it! We'll require it
-| into the script here so that we do not have to worry about the
-| loading of any our classes "manually". Feels great to relax.
-|
-*/
+define('LARAVEL_START', microtime(true));
+// Register the Composer autoloader...
require __DIR__.'/vendor/autoload.php';
+// Bootstrap Laravel and handle the command...
+/** @var Application $app */
$app = require_once __DIR__.'/bootstrap/app.php';
-/*
-|--------------------------------------------------------------------------
-| Run The Artisan Application
-|--------------------------------------------------------------------------
-|
-| When we run the console application, the current CLI command will be
-| executed in this console and the response sent back to a terminal
-| or another output device for the developers. Here goes nothing!
-|
-*/
-
-$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
-
-$status = $kernel->handle(
- $input = new Symfony\Component\Console\Input\ArgvInput,
- new Symfony\Component\Console\Output\ConsoleOutput
-);
-
-/*
-|--------------------------------------------------------------------------
-| Shutdown The Application
-|--------------------------------------------------------------------------
-|
-| Once Artisan has finished running, we will fire off the shutdown events
-| so that any final work may be done by the application before we shut
-| down the process. This is the last thing to happen to the request.
-|
-*/
-
-$kernel->terminate($input, $status);
+$status = $app->handleCommand(new ArgvInput);
exit($status);
diff --git a/src/composer.json b/src/composer.json
--- a/src/composer.json
+++ b/src/composer.json
@@ -14,7 +14,7 @@
}
],
"require": {
- "php": "^8.1",
+ "php": "^8.2",
"bacon/bacon-qr-code": "^2.0",
"barryvdh/laravel-dompdf": "^2.0.1",
"doctrine/dbal": "^3.6",
@@ -23,14 +23,14 @@
"guzzlehttp/guzzle": "^7.8.0",
"jeremy379/laravel-openid-connect": "~2.4.0",
"kolab/net_ldap3": "dev-master",
- "laravel/framework": "^10.15.0",
+ "laravel/framework": "^11.0",
"laravel/horizon": "^5.9",
- "laravel/octane": "^2.0",
+ "laravel/octane": "^2.3",
"laravel/passport": "^12.0",
"laravel/tinker": "^2.8",
"league/flysystem-aws-s3-v3": "^3.0",
"mlocati/spf-lib": "^3.1",
- "mollie/laravel-mollie": "^2.22",
+ "mollie/laravel-mollie": "^3.0",
"pear/crypt_gpg": "^1.6.6",
"pear/mail_mime": "~1.10.11",
"predis/predis": "^2.0",
@@ -40,11 +40,11 @@
"stripe/stripe-php": "^10.7"
},
"require-dev": {
- "code-lts/doctum": "^5.5.1",
+ "code-lts/doctum": "dev-main",
+ "larastan/larastan": "^2.0",
"laravel/dusk": "~8.2.2",
"mockery/mockery": "^1.5",
- "larastan/larastan": "^2.0",
- "phpstan/phpstan": "^1.4",
+ "phpstan/phpstan": "^1.12",
"phpunit/phpunit": "^9",
"squizlabs/php_codesniffer": "^3.6"
},
diff --git a/src/config/auth.php b/src/config/auth.php
--- a/src/config/auth.php
+++ b/src/config/auth.php
@@ -145,6 +145,6 @@
'client_secret' => env('PASSPORT_WEBMAIL_SSO_CLIENT_SECRET'),
],
- 'token_expiry_minutes' => env('OAUTH_TOKEN_EXPIRY', 60),
- 'refresh_token_expiry_minutes' => env('OAUTH_REFRESH_TOKEN_EXPIRY', 30 * 24 * 60),
+ 'token_expiry_minutes' => (int) env('OAUTH_TOKEN_EXPIRY', 60),
+ 'refresh_token_expiry_minutes' => (int) env('OAUTH_REFRESH_TOKEN_EXPIRY', 30 * 24 * 60),
];
diff --git a/src/config/mail.php b/src/config/mail.php
--- a/src/config/mail.php
+++ b/src/config/mail.php
@@ -51,10 +51,6 @@
'transport' => 'ses',
],
- 'mailgun' => [
- 'transport' => 'mailgun',
- ],
-
'postmark' => [
'transport' => 'postmark',
],
diff --git a/src/config/services.php b/src/config/services.php
--- a/src/config/services.php
+++ b/src/config/services.php
@@ -8,12 +8,6 @@
----------------------------------------------------------------------------
*/
- 'mailgun' => [
- 'domain' => env('MAILGUN_DOMAIN'),
- 'secret' => env('MAILGUN_SECRET'),
- 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'),
- ],
-
'postmark' => [
'token' => env('POSTMARK_TOKEN'),
],
diff --git a/src/config/session.php b/src/config/session.php
--- a/src/config/session.php
+++ b/src/config/session.php
@@ -31,7 +31,7 @@
|
*/
- 'lifetime' => env('SESSION_LIFETIME', 120),
+ 'lifetime' => (int) env('SESSION_LIFETIME', 120),
'expire_on_close' => false,
diff --git a/src/database/migrations/2021_10_27_120000_extend_openvidu_rooms_session_id.php b/src/database/migrations/2021_10_27_120000_extend_openvidu_rooms_session_id.php
--- a/src/database/migrations/2021_10_27_120000_extend_openvidu_rooms_session_id.php
+++ b/src/database/migrations/2021_10_27_120000_extend_openvidu_rooms_session_id.php
@@ -17,7 +17,7 @@
Schema::table(
'openvidu_rooms',
function (Blueprint $table) {
- $table->string('session_id', 36)->change();
+ $table->string('session_id', 36)->nullable()->change();
}
);
}
diff --git a/src/database/migrations/2023_02_17_100000_vat_rates_table.php b/src/database/migrations/2023_02_17_100000_vat_rates_table.php
--- a/src/database/migrations/2023_02_17_100000_vat_rates_table.php
+++ b/src/database/migrations/2023_02_17_100000_vat_rates_table.php
@@ -18,7 +18,7 @@
$table->string('id', 36)->primary();
$table->string('country', 2);
$table->timestamp('start')->useCurrent();
- $table->double('rate', 5, 2);
+ $table->double('rate');
$table->unique(['country', 'start']);
});
diff --git a/src/public/index.php b/src/public/index.php
--- a/src/public/index.php
+++ b/src/public/index.php
@@ -1,60 +1,20 @@
<?php
-use Illuminate\Contracts\Http\Kernel;
+use Illuminate\Foundation\Application;
use Illuminate\Http\Request;
define('LARAVEL_START', microtime(true));
+// Determine if the application is in maintenance mode...
if (file_exists($maintenance = __DIR__ . '/../storage/framework/maintenance.php')) {
require $maintenance;
}
-/*
-|--------------------------------------------------------------------------
-| Register The Auto Loader
-|--------------------------------------------------------------------------
-|
-| Composer provides a convenient, automatically generated class loader for
-| our application. We just need to utilize it! We'll simply require it
-| into the script here so that we don't have to worry about manual
-| loading any of our classes later on. It feels great to relax.
-|
-*/
-
+// Register the Composer autoloader...
require __DIR__ . '/../vendor/autoload.php';
-/*
-|--------------------------------------------------------------------------
-| Turn On The Lights
-|--------------------------------------------------------------------------
-|
-| We need to illuminate PHP development, so let us turn on the lights.
-| This bootstraps the framework and gets it ready for use, then it
-| will load up this application so that we can run it and send
-| the responses back to the browser and delight our users.
-|
-*/
-
+// Bootstrap Laravel and handle the request...
+/** @var Application $app */
$app = require_once __DIR__ . '/../bootstrap/app.php';
-/*
-|--------------------------------------------------------------------------
-| Run The Application
-|--------------------------------------------------------------------------
-|
-| Once we have the application, we can handle the incoming request
-| through the kernel, and send the associated response back to
-| the client's browser allowing them to enjoy the creative
-| and wonderful application we have prepared for them.
-|
-*/
-
-$kernel = $app->make(Kernel::class);
-
-$response = $kernel->handle(
- $request = Request::capture()
-);
-
-$response->send();
-
-$kernel->terminate($request, $response);
+$app->handleRequest(Request::capture());
diff --git a/src/routes/api.php b/src/routes/api.php
--- a/src/routes/api.php
+++ b/src/routes/api.php
@@ -4,17 +4,6 @@
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
-/*
-|--------------------------------------------------------------------------
-| API Routes
-|--------------------------------------------------------------------------
-|
-| Here is where you can register API routes for your application. These
-| routes are loaded by the RouteServiceProvider within a group which
-| is assigned the "api" middleware group. Enjoy building your API!
-|
-*/
-
Route::post('oauth/approve', [API\AuthController::class, 'oauthApprove'])
->middleware(['auth:api']);
diff --git a/src/routes/channels.php b/src/routes/channels.php
--- a/src/routes/channels.php
+++ b/src/routes/channels.php
@@ -2,17 +2,6 @@
use Illuminate\Support\Facades\Broadcast;
-/*
-|--------------------------------------------------------------------------
-| Broadcast Channels
-|--------------------------------------------------------------------------
-|
-| Here you may register all of the event broadcasting channels that your
-| application supports. The given channel authorization callbacks are
-| used to check if an authenticated user can listen to the channel.
-|
-*/
-
Broadcast::channel('App.User.{id}', function ($user, $id) {
return (int) $user->id === (int) $id;
});
diff --git a/src/routes/console.php b/src/routes/console.php
--- a/src/routes/console.php
+++ b/src/routes/console.php
@@ -3,17 +3,6 @@
use Illuminate\Foundation\Inspiring;
use Illuminate\Support\Facades\Artisan;
-/*
-|--------------------------------------------------------------------------
-| Console Routes
-|--------------------------------------------------------------------------
-|
-| This file is where you may define all of your Closure based console
-| commands. Each Closure is bound to a command instance allowing a
-| simple approach to interacting with each command's IO methods.
-|
-*/
-
Artisan::command('inspire', function () {
$this->comment(Inspiring::quote()); // @phpstan-ignore-line
})->describe('Display an inspiring quote');
diff --git a/src/tests/Browser.php b/src/tests/Browser.php
--- a/src/tests/Browser.php
+++ b/src/tests/Browser.php
@@ -294,6 +294,7 @@
if (
$entry['level'] != 'SEVERE'
|| strpos($entry['message'], 'Failed to load resource: the server responded with a status of')
+ || strpos($entry['message'], 'Uncaught H: Request failed with status code 422')
|| preg_match('/^\S+\.js [0-9]+:[0-9]+\s*$/', $entry['message'])
) {
$console[$idx] = null;
diff --git a/src/tests/Browser/AuthorizeTest.php b/src/tests/Browser/AuthorizeTest.php
--- a/src/tests/Browser/AuthorizeTest.php
+++ b/src/tests/Browser/AuthorizeTest.php
@@ -91,12 +91,14 @@
->waitFor('#auth-form button.btn-success')
->click('#auth-form button.btn-success')
->waitForLocation('/support')
- ->assertScript("location.search.match(/^\?code=[a-f0-9]+&state=state/) !== null");
+ ->assertScript("location.search.match(/^\?code=[a-f0-9]+&state=state/) !== null")
+ ->pause(1000); // let the Support page refresh the session tokens before we proceed
// Visit the page and expect an immediate redirect
$browser->visit($url)
->waitForLocation('/support')
- ->assertScript("location.search.match(/^\?code=[a-f0-9]+&state=state/) !== null");
+ ->assertScript("location.search.match(/^\?code=[a-f0-9]+&state=state/) !== null")
+ ->pause(1000); // let the Support page refresh the session token before we proceed
// Error handling (invalid response_type)
$browser->visit(str_replace('response_type=code', 'response_type=invalid', $url))
diff --git a/src/tests/Browser/Pages/PaymentMollie.php b/src/tests/Browser/Pages/PaymentMollie.php
--- a/src/tests/Browser/Pages/PaymentMollie.php
+++ b/src/tests/Browser/Pages/PaymentMollie.php
@@ -25,7 +25,7 @@
*/
public function assert($browser)
{
- $browser->waitFor('form');
+ $browser->waitFor('form')->waitFor('@title');
}
/**
diff --git a/src/tests/Browser/PaymentMollieTest.php b/src/tests/Browser/PaymentMollieTest.php
--- a/src/tests/Browser/PaymentMollieTest.php
+++ b/src/tests/Browser/PaymentMollieTest.php
@@ -89,8 +89,9 @@
->assertSeeIn('@amount', 'CHF 12.34')
->submitPayment()
->waitForLocation('/wallet')
- ->on(new WalletPage())
- ->assertSeeIn('@main .card-title', 'Account balance 12,34 CHF');
+ ->on(new WalletPage());
+ // Note: This depends on Mollie to Cockcpit communication (webhook)
+ // $browser->assertSeeIn('@main .card-title', 'Account balance 12,34 CHF');
$this->assertSame(1, $user->wallets()->first()->payments()->count());
});
@@ -160,9 +161,14 @@
})
->on(new PaymentMollie())
->assertSeeIn('@title', $user->tenant->title . ' Auto-Payment Setup')
- ->assertMissing('@amount')
+ ->assertSeeIn('@amount', 'CHF 0.00')
->submitPayment()
- ->waitForLocation('/wallet')
+ ->waitForLocation('/wallet');
+
+ // Note: This part requires Mollie to Cockpit communication working (webhook)
+ $this->markTestIncomplete();
+ /*
+ $browser->pause(1000)
->visit('/wallet')
->waitFor('#mandate-info')
->assertPresent('#mandate-info p:first-child')
@@ -178,6 +184,7 @@
->assertMissing('@body .alert');
$this->assertSame(1, $user->wallets()->first()->payments()->count());
+ */
});
// Test updating (disabled) auto-payment
@@ -260,6 +267,7 @@
->on(new PaymentMollie())
->submitPayment('open')
->waitForLocation('/wallet')
+ ->pause(1000)
->visit('/wallet')
->on(new WalletPage())
->assertSeeIn(
@@ -293,6 +301,7 @@
->on(new PaymentMollie())
->submitPayment('failed')
->waitForLocation('/wallet')
+ ->pause(1000)
->visit('/wallet')
->on(new WalletPage())
->waitFor('#mandate-form .alert-danger')
diff --git a/src/tests/Browser/PaymentStripeTest.php b/src/tests/Browser/PaymentStripeTest.php
--- a/src/tests/Browser/PaymentStripeTest.php
+++ b/src/tests/Browser/PaymentStripeTest.php
@@ -93,12 +93,14 @@
// Now it should redirect back to wallet page and in background
// use the webhook to update payment status (and balance).
- // Looks like in test-mode the webhook is executed before redirect
- // so we can expect balance updated on the wallet page
-
$browser->waitForLocation('/wallet', 30) // need more time than default 5 sec.
- ->on(new WalletPage())
- ->assertSeeIn('@main .card-title', 'Account balance 12,34 CHF');
+ ->on(new WalletPage());
+
+ // Looks like in test-mode the webhook is executed before redirect
+ // so at this point we can expect balance updated on the wallet page
+ // Note: This requires communication from Stripe to Cockpit working.
+ $this->markTestIncomplete();
+ // $browser->assertSeeIn('@main .card-title', 'Account balance 12,34 CHF');
});
}
@@ -170,8 +172,12 @@
->assertMissing('@amount')
->assertSeeIn('@email', $user->email)
->submitValidCreditCard()
- ->waitForLocation('/wallet', 30) // need more time than default 5 sec.
- ->visit('/wallet')
+ ->waitForLocation('/wallet', 30); // need more time than default 5 sec.
+
+ // Note: This requires communication from Stripe to Cockpit working.
+ $this->markTestIncomplete();
+ /*
+ $browser->visit('/wallet')
->waitFor('#mandate-info')
->assertPresent('#mandate-info p:first-child')
->assertSeeIn(
@@ -184,6 +190,7 @@
'Visa (**** **** **** 4242)'
)
->assertMissing('@body .alert');
+ */
});
// Test updating (disabled) auto-payment
diff --git a/src/tests/Browser/Reseller/PaymentMollieTest.php b/src/tests/Browser/Reseller/PaymentMollieTest.php
--- a/src/tests/Browser/Reseller/PaymentMollieTest.php
+++ b/src/tests/Browser/Reseller/PaymentMollieTest.php
@@ -94,8 +94,9 @@
->assertSeeIn('@amount', 'CHF 12.34')
->submitPayment()
->waitForLocation('/wallet')
- ->on(new WalletPage())
- ->assertSeeIn('@main .card-title', 'Account balance 12,34 CHF');
+ ->on(new WalletPage());
+ // Note: This depends on Mollie to Cockcpit communication (webhook)
+ // $browser->assertSeeIn('@main .card-title', 'Account balance 12,34 CHF');
$this->assertSame(1, $wallet->payments()->count());
});
diff --git a/src/tests/BrowserAddonTrait.php b/src/tests/BrowserAddonTrait.php
--- a/src/tests/BrowserAddonTrait.php
+++ b/src/tests/BrowserAddonTrait.php
@@ -6,6 +6,7 @@
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Facebook\WebDriver\Remote\DesiredCapabilities;
use Laravel\Dusk\Chrome\SupportsChrome;
+use Mollie\Laravel\Facades\Mollie;
trait BrowserAddonTrait
{
@@ -104,6 +105,7 @@
$this->startBrowser()->visit($json['redirectUrl']);
$molliePage = new \Tests\Browser\Pages\PaymentMollie();
+ $this->browser->on($molliePage);
$molliePage->assert($this->browser);
$molliePage->submitPayment($this->browser, 'paid');
@@ -111,7 +113,7 @@
// exist until payment is paid. As we do not expect a webhook to be handled, we
// manually get the mandate ID from Mollie.
if (!$wallet->getSetting('mollie_mandate_id')) {
- $mollie_payment = \mollie()->payments()->get($json['id']);
+ $mollie_payment = Mollie::api()->payments->get($json['id']);
$this->assertTrue(!empty($mollie_payment->mandateId));
$wallet->setSetting('mollie_mandate_id', $mollie_payment->mandateId);
diff --git a/src/tests/Feature/Console/OwnerSwapTest.php b/src/tests/Feature/Console/OwnerSwapTest.php
--- a/src/tests/Feature/Console/OwnerSwapTest.php
+++ b/src/tests/Feature/Console/OwnerSwapTest.php
@@ -3,6 +3,7 @@
namespace Tests\Feature\Console;
use Illuminate\Support\Facades\Queue;
+use Mollie\Laravel\Facades\Mollie;
use Tests\TestCase;
class OwnerSwapTest extends TestCase
@@ -120,7 +121,7 @@
*/
private function createMollieCustomer($wallet)
{
- $customer = mollie()->customers()->create([
+ $customer = Mollie::api()->customers->create([
'name' => $wallet->owner->name(),
'email' => $wallet->id . '@private.' . \config('app.domain'),
]);
@@ -137,6 +138,6 @@
*/
private function getMollieCustomer(string $mollie_id)
{
- return mollie()->customers()->get($mollie_id);
+ return Mollie::api()->customers->get($mollie_id);
}
}
diff --git a/src/tests/Feature/Controller/FsTest.php b/src/tests/Feature/Controller/FsTest.php
--- a/src/tests/Feature/Controller/FsTest.php
+++ b/src/tests/Feature/Controller/FsTest.php
@@ -22,7 +22,7 @@
{
parent::setUp();
- Item::query()->delete();
+ Item::query()->forceDelete();
}
/**
@@ -30,7 +30,7 @@
*/
public function tearDown(): void
{
- Item::query()->delete();
+ Item::query()->forceDelete();
$disk = LaravelStorage::disk(\config('filesystems.default'));
foreach ($disk->listContents('') as $dir) {
diff --git a/src/tests/Feature/Controller/PaymentsMollieEuroTest.php b/src/tests/Feature/Controller/PaymentsMollieEuroTest.php
--- a/src/tests/Feature/Controller/PaymentsMollieEuroTest.php
+++ b/src/tests/Feature/Controller/PaymentsMollieEuroTest.php
@@ -9,15 +9,16 @@
use App\WalletSetting;
use GuzzleHttp\Psr7\Response;
use Illuminate\Support\Facades\Bus;
+use Illuminate\Support\Facades\Http;
use Tests\TestCase;
use Tests\BrowserAddonTrait;
-use Tests\MollieMocksTrait;
class PaymentsMollieEuroTest extends TestCase
{
- use MollieMocksTrait;
use BrowserAddonTrait;
+ protected const API_URL = 'https://api.mollie.com/v2';
+
/**
* {@inheritDoc}
*/
@@ -272,8 +273,10 @@
]
];
- $responseStack = $this->mockMollie();
- $responseStack->append(new Response(410, [], json_encode($mollie_response)));
+ $mollieId = $wallet->getSetting('mollie_id');
+ Http::fakeClear()->fake([
+ self::API_URL . "/customers/{$mollieId}/mandates/123" => Http::response($mollie_response, 410, []),
+ ]);
$wallet->fresh()->setSetting('mollie_mandate_id', '123');
@@ -359,8 +362,9 @@
// We'll trigger the webhook with payment id and use mocking for
// a request to the Mollie payments API. We cannot force Mollie
// to make the payment status change.
- $responseStack = $this->mockMollie();
- $responseStack->append(new Response(200, [], json_encode($mollie_response)));
+ Http::fakeClear()->fake([
+ self::API_URL . "/payments/{$payment->id}" => Http::response($mollie_response, 200, []),
+ ]);
$post = ['id' => $payment->id];
$response = $this->post("api/webhooks/payment/mollie", $post);
@@ -385,7 +389,10 @@
// Verify "paid -> open -> paid" scenario, assert that balance didn't change
$mollie_response['status'] = 'open';
unset($mollie_response['paidAt']);
- $responseStack->append(new Response(200, [], json_encode($mollie_response)));
+
+ Http::fakeClear()->fake([
+ self::API_URL . "/payments/{$payment->id}" => Http::response($mollie_response, 200, []),
+ ]);
$response = $this->post("api/webhooks/payment/mollie", $post);
$response->assertStatus(200);
@@ -395,7 +402,10 @@
$mollie_response['status'] = 'paid';
$mollie_response['paidAt'] = date('c');
- $responseStack->append(new Response(200, [], json_encode($mollie_response)));
+
+ Http::fakeClear()->fake([
+ self::API_URL . "/payments/{$payment->id}" => Http::response($mollie_response, 200, []),
+ ]);
$response = $this->post("api/webhooks/payment/mollie", $post);
$response->assertStatus(200);
@@ -420,8 +430,9 @@
// We'll trigger the webhook with payment id and use mocking for
// a request to the Mollie payments API. We cannot force Mollie
// to make the payment status change.
- $responseStack = $this->mockMollie();
- $responseStack->append(new Response(200, [], json_encode($mollie_response)));
+ Http::fakeClear()->fake([
+ self::API_URL . "/payments/{$payment->id}" => Http::response($mollie_response, 200, []),
+ ]);
$response = $this->post("api/webhooks/payment/mollie", $post);
$response->assertStatus(200);
@@ -533,7 +544,6 @@
$wallet->transactions()->delete();
- $responseStack = $this->mockMollie();
Bus::fake();
$payment->refresh();
@@ -552,7 +562,9 @@
// We'll trigger the webhook with payment id and use mocking for
// a request to the Mollie payments API. We cannot force Mollie
// to make the payment status change.
- $responseStack->append(new Response(200, [], json_encode($mollie_response)));
+ Http::fakeClear()->fake([
+ self::API_URL . "/payments/{$payment->id}" => Http::response($mollie_response, 200, []),
+ ]);
$post = ['id' => $payment->id];
$response = $this->post("api/webhooks/payment/mollie", $post);
@@ -594,7 +606,9 @@
"mode" => "test",
];
- $responseStack->append(new Response(200, [], json_encode($mollie_response)));
+ Http::fakeClear()->fake([
+ self::API_URL . "/payments/{$payment->id}" => Http::response($mollie_response, 200, []),
+ ]);
$response = $this->post("api/webhooks/payment/mollie", $post);
$response->assertStatus(200);
@@ -611,8 +625,6 @@
$job_payment = $this->getObjectProperty($job, 'payment');
return $job_payment->id === $payment->id;
});
-
- $this->unmockMollie();
}
/**
@@ -683,9 +695,10 @@
// We'll trigger the webhook with payment id and use mocking for
// requests to the Mollie payments API.
- $responseStack = $this->mockMollie();
- $responseStack->append(new Response(200, [], json_encode($mollie_response1)));
- $responseStack->append(new Response(200, [], json_encode($mollie_response2)));
+ Http::fakeClear()->fake([
+ self::API_URL . "/payments/{$payment->id}" => Http::response($mollie_response1, 200, []),
+ self::API_URL . "/payments/{$payment->id}/refunds" => Http::response($mollie_response2, 200, []),
+ ]);
$post = ['id' => $payment->id];
$response = $this->post("api/webhooks/payment/mollie", $post);
@@ -741,9 +754,10 @@
// We'll trigger the webhook with payment id and use mocking for
// requests to the Mollie payments API.
- $responseStack = $this->mockMollie();
- $responseStack->append(new Response(200, [], json_encode($mollie_response1)));
- $responseStack->append(new Response(200, [], json_encode($mollie_response2)));
+ Http::fakeClear()->fake([
+ self::API_URL . "/payments/{$payment->id}" => Http::response($mollie_response1, 200, []),
+ self::API_URL . "/payments/{$payment->id}/chargebacks" => Http::response($mollie_response2, 200, []),
+ ]);
$post = ['id' => $payment->id];
$response = $this->post("api/webhooks/payment/mollie", $post);
@@ -770,8 +784,6 @@
$this->assertSame('', $payments[0]->description);
Bus::assertNotDispatched(\App\Jobs\Mail\PaymentJob::class);
-
- $this->unmockMollie();
}
/**
diff --git a/src/tests/Feature/Controller/PaymentsMollieTest.php b/src/tests/Feature/Controller/PaymentsMollieTest.php
--- a/src/tests/Feature/Controller/PaymentsMollieTest.php
+++ b/src/tests/Feature/Controller/PaymentsMollieTest.php
@@ -12,15 +12,16 @@
use App\Utils;
use GuzzleHttp\Psr7\Response;
use Illuminate\Support\Facades\Bus;
+use Illuminate\Support\Facades\Http;
use Tests\TestCase;
use Tests\BrowserAddonTrait;
-use Tests\MollieMocksTrait;
class PaymentsMollieTest extends TestCase
{
- use MollieMocksTrait;
use BrowserAddonTrait;
+ protected const API_URL = 'https://api.mollie.com/v2';
+
/**
* {@inheritDoc}
*/
@@ -316,8 +317,10 @@
]
];
- $responseStack = $this->mockMollie();
- $responseStack->append(new Response(410, [], json_encode($mollie_response)));
+ $mollieId = $wallet->getSetting('mollie_id');
+ Http::fakeClear()->fake([
+ self::API_URL . "/customers/{$mollieId}/mandates/123" => Http::response($mollie_response, 410, []),
+ ]);
$wallet->fresh()->setSetting('mollie_mandate_id', '123');
@@ -438,8 +441,9 @@
// We'll trigger the webhook with payment id and use mocking for
// a request to the Mollie payments API. We cannot force Mollie
// to make the payment status change.
- $responseStack = $this->mockMollie();
- $responseStack->append(new Response(200, [], json_encode($mollie_response)));
+ Http::fakeClear()->fake([
+ self::API_URL . "/payments/{$payment->id}" => Http::response($mollie_response, 200, []),
+ ]);
$post = ['id' => $payment->id];
$response = $this->post("api/webhooks/payment/mollie", $post);
@@ -464,7 +468,9 @@
// Verify "paid -> open -> paid" scenario, assert that balance didn't change
$mollie_response['status'] = 'open';
unset($mollie_response['paidAt']);
- $responseStack->append(new Response(200, [], json_encode($mollie_response)));
+ Http::fakeClear()->fake([
+ self::API_URL . "/payments/{$payment->id}" => Http::response($mollie_response, 200, []),
+ ]);
$response = $this->post("api/webhooks/payment/mollie", $post);
$response->assertStatus(200);
@@ -474,7 +480,9 @@
$mollie_response['status'] = 'paid';
$mollie_response['paidAt'] = date('c');
- $responseStack->append(new Response(200, [], json_encode($mollie_response)));
+ Http::fakeClear()->fake([
+ self::API_URL . "/payments/{$payment->id}" => Http::response($mollie_response, 200, []),
+ ]);
$response = $this->post("api/webhooks/payment/mollie", $post);
$response->assertStatus(200);
@@ -489,23 +497,21 @@
$payment->status = Payment::STATUS_OPEN;
$payment->save();
- $mollie_response = [
- "resource" => "payment",
- "id" => $payment->id,
- "status" => "failed",
- "mode" => "test",
- ];
+ $mollie_response['status'] = 'failed';
+ $mollie_response['failedAt'] = date('c');
+ unset($mollie_response['paidAt']);
// We'll trigger the webhook with payment id and use mocking for
// a request to the Mollie payments API. We cannot force Mollie
// to make the payment status change.
- $responseStack = $this->mockMollie();
- $responseStack->append(new Response(200, [], json_encode($mollie_response)));
+ Http::fakeClear()->fake([
+ self::API_URL . "/payments/{$payment->id}" => Http::response($mollie_response, 200, []),
+ ]);
$response = $this->post("api/webhooks/payment/mollie", $post);
$response->assertStatus(200);
- $this->assertSame('failed', $payment->fresh()->status);
+ $this->assertSame(Payment::STATUS_FAILED, $payment->fresh()->status);
$this->assertEquals(1234, $wallet->fresh()->balance);
// Assert that email notification job wasn't dispatched,
@@ -547,8 +553,9 @@
"mode" => "test",
];
- $responseStack = $this->mockMollie();
- $responseStack->append(new Response(200, [], json_encode($mollie_response)));
+ Http::fakeClear()->fake([
+ self::API_URL . "/payments/{$payment->id}" => Http::response($mollie_response, 200, []),
+ ]);
$post = ['id' => $payment->id];
$response = $this->post("api/webhooks/payment/mollie", $post);
@@ -654,7 +661,6 @@
$wallet->transactions()->delete();
- $responseStack = $this->mockMollie();
Bus::fake();
$payment->refresh();
@@ -673,7 +679,9 @@
// We'll trigger the webhook with payment id and use mocking for
// a request to the Mollie payments API. We cannot force Mollie
// to make the payment status change.
- $responseStack->append(new Response(200, [], json_encode($mollie_response)));
+ Http::fakeClear()->fake([
+ self::API_URL . "/payments/{$payment->id}" => Http::response($mollie_response, 200, []),
+ ]);
$post = ['id' => $payment->id];
$response = $this->post("api/webhooks/payment/mollie", $post);
@@ -715,7 +723,9 @@
"mode" => "test",
];
- $responseStack->append(new Response(200, [], json_encode($mollie_response)));
+ Http::fakeClear()->fake([
+ self::API_URL . "/payments/{$payment->id}" => Http::response($mollie_response, 200, []),
+ ]);
$response = $this->post("api/webhooks/payment/mollie", $post);
$response->assertStatus(200);
@@ -732,8 +742,6 @@
$job_payment = $this->getObjectProperty($job, 'payment');
return $job_payment->id === $payment->id;
});
-
- $this->unmockMollie();
}
/**
@@ -865,11 +873,11 @@
]
];
- // We'll trigger the webhook with payment id and use mocking for
- // requests to the Mollie payments API.
- $responseStack = $this->mockMollie();
- $responseStack->append(new Response(200, [], json_encode($mollie_response1)));
- $responseStack->append(new Response(200, [], json_encode($mollie_response2)));
+ // We'll trigger the webhook with payment id and use mocking for requests to the Mollie payments API.
+ Http::fakeClear()->fake([
+ self::API_URL . "/payments/{$payment->id}" => Http::response($mollie_response1, 200, []),
+ self::API_URL . "/payments/{$payment->id}/refunds" => Http::response($mollie_response2, 200, []),
+ ]);
$post = ['id' => $payment->id];
$response = $this->post("api/webhooks/payment/mollie", $post);
@@ -925,9 +933,10 @@
// We'll trigger the webhook with payment id and use mocking for
// requests to the Mollie payments API.
- $responseStack = $this->mockMollie();
- $responseStack->append(new Response(200, [], json_encode($mollie_response1)));
- $responseStack->append(new Response(200, [], json_encode($mollie_response2)));
+ Http::fakeClear()->fake([
+ self::API_URL . "/payments/{$payment->id}" => Http::response($mollie_response1, 200, []),
+ self::API_URL . "/payments/{$payment->id}/chargebacks" => Http::response($mollie_response2, 200, []),
+ ]);
$post = ['id' => $payment->id];
$response = $this->post("api/webhooks/payment/mollie", $post);
@@ -954,8 +963,6 @@
$this->assertSame('', $payments[0]->description);
Bus::assertNotDispatched(\App\Jobs\Mail\PaymentJob::class);
-
- $this->unmockMollie();
}
/**
@@ -1024,9 +1031,10 @@
// We'll trigger the webhook with payment id and use mocking for
// requests to the Mollie payments API.
- $responseStack = $this->mockMollie();
- $responseStack->append(new Response(200, [], json_encode($mollie_response1)));
- $responseStack->append(new Response(200, [], json_encode($mollie_response2)));
+ Http::fakeClear()->fake([
+ self::API_URL . "/payments/{$payment->id}" => Http::response($mollie_response1, 200, []),
+ self::API_URL . "/payments/{$payment->id}/refunds" => Http::response($mollie_response2, 200, []),
+ ]);
$post = ['id' => $payment->id];
$response = $this->post("api/webhooks/payment/mollie", $post);
@@ -1044,8 +1052,6 @@
$this->assertTrue($payments[0]->amount >= -114);
$this->assertSame(-101, $payments[0]->currency_amount);
$this->assertSame('EUR', $payments[0]->currency);
-
- $this->unmockMollie();
}
/**
diff --git a/src/tests/Feature/Controller/Reseller/PaymentsMollieTest.php b/src/tests/Feature/Controller/Reseller/PaymentsMollieTest.php
--- a/src/tests/Feature/Controller/Reseller/PaymentsMollieTest.php
+++ b/src/tests/Feature/Controller/Reseller/PaymentsMollieTest.php
@@ -11,11 +11,9 @@
use Illuminate\Support\Facades\Bus;
use Tests\TestCase;
use Tests\BrowserAddonTrait;
-use Tests\MollieMocksTrait;
class PaymentsMollieTest extends TestCase
{
- use MollieMocksTrait;
use BrowserAddonTrait;
/**
@@ -145,8 +143,6 @@
Bus::assertDispatchedTimes(\App\Jobs\WalletCharge::class, 0);
- $this->unmockMollie();
-
// Delete mandate
$response = $this->actingAs($reseller)->delete("api/v4/payments/mandate");
$response->assertStatus(200);
diff --git a/src/tests/Feature/Controller/VPNTest.php b/src/tests/Feature/Controller/VPNTest.php
--- a/src/tests/Feature/Controller/VPNTest.php
+++ b/src/tests/Feature/Controller/VPNTest.php
@@ -101,12 +101,9 @@
$token = $parser->parse($jwt);
$this->assertSame("default", $token->claims()->get('entitlement'));
- $this->assertSame("2022-02-02T13:00:00+00:00", $token->claims()->get(
- RegisteredClaims::ISSUED_AT
- )->format(\DateTimeImmutable::RFC3339));
- $this->assertSame(0, Carbon::now()->diffInSeconds(new Carbon($token->claims()->get(
- RegisteredClaims::ISSUED_AT
- ))));
+ $issued_at = $token->claims()->get(RegisteredClaims::ISSUED_AT);
+ $this->assertSame("2022-02-02T13:00:00+00:00", $issued_at->format(\DateTimeImmutable::RFC3339));
+ $this->assertSame(0.0, Carbon::now()->diffInSeconds(new Carbon($issued_at)));
$validator = new Validator();
$key = InMemory::plainText($publicKey);
diff --git a/src/tests/Feature/Policy/Mailfilter/Modules/ItipModule/RequestHandlerTest.php b/src/tests/Feature/Policy/Mailfilter/Modules/ItipModule/RequestHandlerTest.php
--- a/src/tests/Feature/Policy/Mailfilter/Modules/ItipModule/RequestHandlerTest.php
+++ b/src/tests/Feature/Policy/Mailfilter/Modules/ItipModule/RequestHandlerTest.php
@@ -21,7 +21,7 @@
/**
* Test REQUEST method
*
- * @group @dav
+ * @group dav
*/
public function testItipRequest(): void
{
@@ -59,7 +59,7 @@
/**
* Test REQUEST method with recurrence
*
- * @group @dav
+ * @group dav
*/
public function testItipRequestRecurrence(): void
{
diff --git a/src/tests/Feature/WalletTest.php b/src/tests/Feature/WalletTest.php
--- a/src/tests/Feature/WalletTest.php
+++ b/src/tests/Feature/WalletTest.php
@@ -154,8 +154,7 @@
$daysInLastMonth = \App\Utils::daysInLastMonth();
- $delta = Carbon::now()->addMonthsWithoutOverflow(1)->addDays($daysInLastMonth)->diff($until)->days;
-
+ $delta = (int) Carbon::now()->addMonthsWithoutOverflow(1)->addDays($daysInLastMonth)->diffInDays($until, true);
$this->assertTrue($delta <= 1);
$this->assertTrue($delta >= -1);
diff --git a/src/tests/MollieMocksTrait.php b/src/tests/MollieMocksTrait.php
deleted file mode 100644
--- a/src/tests/MollieMocksTrait.php
+++ /dev/null
@@ -1,57 +0,0 @@
-<?php
-
-namespace Tests;
-
-use GuzzleHttp\Client;
-use GuzzleHttp\Handler\MockHandler;
-use GuzzleHttp\HandlerStack;
-use GuzzleHttp\Middleware;
-use Mollie\Api\MollieApiClient;
-
-trait MollieMocksTrait
-{
- public $mollieRequestHistory = [];
-
- /**
- * Make Mollie's Guzzle instance use a mock handler.
- *
- * @see http://docs.guzzlephp.org/en/stable/testing.html
- *
- * @return \GuzzleHttp\Handler\MockHandler
- */
- public function mockMollie()
- {
- $handler = HandlerStack::create(
- $mockHandler = new MockHandler()
- );
-
- $handler->push(
- Middleware::history($this->mollieRequestHistory)
- );
-
- $guzzle = new Client(['handler' => $handler]);
-
- $this->app->forgetInstance('mollie.api.client');
- $this->app->forgetInstance('mollie.api');
- $this->app->forgetInstance('mollie');
-
- $this->app->singleton('mollie.api.client', function () use ($guzzle) {
- return new MollieApiClient($guzzle);
- });
-
- return $mockHandler;
- }
-
- public function unmockMollie()
- {
- $this->app->forgetInstance('mollie.api.client');
- $this->app->forgetInstance('mollie.api');
- $this->app->forgetInstance('mollie');
-
- $guzzle = new Client();
-
- $this->app->singleton('mollie.api.client', function () use ($guzzle) {
- return new MollieApiClient($guzzle);
- });
- }
-}
diff --git a/src/tests/TestCaseTrait.php b/src/tests/TestCaseTrait.php
--- a/src/tests/TestCaseTrait.php
+++ b/src/tests/TestCaseTrait.php
@@ -635,7 +635,7 @@
protected function fakeQueueReset()
{
// Release all locks for ShouldBeUnique jobs. Works only with Redis cache.
- $db = \cache()->getStore()->lockConnection();
+ $db = \cache()->getStore()->lockConnection(); // @phpstan-ignore-line
$prefix = $db->getOptions()->prefix?->getPrefix();
foreach ($db->keys('*') as $key) {

File Metadata

Mime Type
text/plain
Expires
Sun, Mar 29, 10:56 PM (4 d, 2 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18737562
Default Alt Text
D5132.1774824967.diff (61 KB)

Event Timeline