Laravel components v8 (#2576)

- update actions ci
- include json for 4 spaces tab
- provide output int for process code exit
- adhere to parent type hint of builder
- mailer instance now needs a name, multiple can be instantiated
- getOriginal now uses mutators in the model
- Temporarily loosen MailableInterface requirements. This avoids an immediate BC break for classes in extensions that implement this interface.
- Temporarily provide (and autoload) old symfony translator interface
- make queue exception handler compatible with the contract of L8
- Update phpunit schema for newer version
- Update phpunit assert calls for newer version
This commit is contained in:
Daniël Klabbers 2021-03-05 15:43:35 +01:00 committed by GitHub
parent 725863a6e2
commit 84ded0ce50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
39 changed files with 214 additions and 174 deletions

View File

@ -15,5 +15,5 @@ indent_size = 2
[*.{diff,md}] [*.{diff,md}]
trim_trailing_whitespace = false trim_trailing_whitespace = false
[*.{php,xml}] [*.{php,xml,json}]
indent_size = 4 indent_size = 4

View File

@ -8,7 +8,7 @@ jobs:
strategy: strategy:
matrix: matrix:
php: ['7.2', '7.3', '7.4', '8.0'] php: [7.3, 7.4, '8.0']
service: ['mysql:5.7', mariadb] service: ['mysql:5.7', mariadb]
prefix: ['', flarum_] prefix: ['', flarum_]
@ -21,12 +21,6 @@ jobs:
prefixStr: (prefix) prefixStr: (prefix)
exclude: exclude:
- php: 7.2
service: 'mysql:5.7'
prefix: flarum_
- php: 7.2
service: mariadb
prefix: flarum_
- php: 7.3 - php: 7.3
service: 'mysql:5.7' service: 'mysql:5.7'
prefix: flarum_ prefix: flarum_
@ -80,3 +74,5 @@ jobs:
- name: Run Composer tests - name: Run Composer tests
run: composer test run: composer test
env:
COMPOSER_PROCESS_TIMEOUT: 600

1
.gitignore vendored
View File

@ -4,6 +4,7 @@ composer.phar
node_modules node_modules
.DS_Store .DS_Store
Thumbs.db Thumbs.db
tests/.phpunit.result.cache
/tests/integration/tmp /tests/integration/tmp
.vagrant .vagrant
.idea/* .idea/*

View File

@ -1,7 +1,10 @@
{ {
"name": "flarum/core", "name": "flarum/core",
"description": "Delightfully simple forum software.", "description": "Delightfully simple forum software.",
"keywords": ["forum", "discussion"], "keywords": [
"forum",
"discussion"
],
"homepage": "https://flarum.org/", "homepage": "https://flarum.org/",
"license": "MIT", "license": "MIT",
"authors": [ "authors": [
@ -17,27 +20,27 @@
"docs": "https://flarum.org/docs/" "docs": "https://flarum.org/docs/"
}, },
"require": { "require": {
"php": ">=7.2", "php": ">=7.3",
"axy/sourcemap": "^0.1.4", "axy/sourcemap": "^0.1.4",
"components/font-awesome": "^5.14.0", "components/font-awesome": "^5.14.0",
"dflydev/fig-cookies": "^3.0.0", "dflydev/fig-cookies": "^3.0.0",
"doctrine/dbal": "^2.7", "doctrine/dbal": "^2.7",
"franzl/whoops-middleware": "^2.0.0", "franzl/whoops-middleware": "^2.0.0",
"illuminate/bus": "^6.0", "illuminate/bus": "^8.0",
"illuminate/cache": "^6.0", "illuminate/cache": "^8.0",
"illuminate/config": "^6.0", "illuminate/config": "^8.0",
"illuminate/container": "^6.0", "illuminate/container": "^8.0",
"illuminate/contracts": "^6.0", "illuminate/contracts": "^8.0",
"illuminate/database": "^6.0", "illuminate/database": "^8.0",
"illuminate/events": "^6.0", "illuminate/events": "^8.0",
"illuminate/filesystem": "^6.0", "illuminate/filesystem": "^8.0",
"illuminate/hashing": "^6.0", "illuminate/hashing": "^8.0",
"illuminate/mail": "^6.0", "illuminate/mail": "^8.0",
"illuminate/queue": "^6.0", "illuminate/queue": "^8.0",
"illuminate/session": "^6.0", "illuminate/session": "^8.0",
"illuminate/support": "^6.0", "illuminate/support": "^8.0",
"illuminate/validation": "^6.0", "illuminate/validation": "^8.0",
"illuminate/view": "^6.0", "illuminate/view": "^8.0",
"intervention/image": "^2.5.0", "intervention/image": "^2.5.0",
"laminas/laminas-diactoros": "^2.4.1", "laminas/laminas-diactoros": "^2.4.1",
"laminas/laminas-httphandlerrunner": "^1.2.0", "laminas/laminas-httphandlerrunner": "^1.2.0",
@ -54,25 +57,26 @@
"psr/http-server-handler": "^1.0", "psr/http-server-handler": "^1.0",
"psr/http-server-middleware": "^1.0", "psr/http-server-middleware": "^1.0",
"s9e/text-formatter": "^2.3.6", "s9e/text-formatter": "^2.3.6",
"symfony/config": "^4.3.4", "symfony/config": "^5.2.2",
"symfony/console": "^4.3.4", "symfony/console": "^5.2.2",
"symfony/event-dispatcher": "^4.3.4", "symfony/event-dispatcher": "^5.2.2",
"symfony/mime": "^5.2.0", "symfony/mime": "^5.2.0",
"symfony/translation": "^4.3.4", "symfony/translation": "^5.1.5",
"symfony/yaml": "^4.3.4", "symfony/yaml": "^5.2.2",
"tobscure/json-api": "^0.3.0", "tobscure/json-api": "^0.3.0",
"wikimedia/less.php": "^3.0" "wikimedia/less.php": "^3.0"
}, },
"require-dev": { "require-dev": {
"mockery/mockery": "^1.3.3", "mockery/mockery": "^1.4",
"phpunit/phpunit": "^8.0" "phpunit/phpunit": "^9.0"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Flarum\\": "src/" "Flarum\\": "src/"
}, },
"files": [ "files": [
"src/helpers.php" "src/helpers.php",
"src/TranslatorInterface.php"
] ]
}, },
"autoload-dev": { "autoload-dev": {

View File

@ -20,7 +20,7 @@ use Laminas\Diactoros\Response\EmptyResponse;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface; use Psr\Http\Server\RequestHandlerInterface;
use Symfony\Component\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
class SendConfirmationEmailController implements RequestHandlerInterface class SendConfirmationEmailController implements RequestHandlerInterface
{ {

View File

@ -16,7 +16,7 @@ use Laminas\Diactoros\Response\EmptyResponse;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface; use Psr\Http\Server\RequestHandlerInterface;
use Symfony\Component\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
class SendTestMailController implements RequestHandlerInterface class SendTestMailController implements RequestHandlerInterface
{ {

View File

@ -11,7 +11,7 @@ namespace Flarum\Api\Serializer;
use Flarum\Group\Group; use Flarum\Group\Group;
use InvalidArgumentException; use InvalidArgumentException;
use Symfony\Component\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
class GroupSerializer extends AbstractSerializer class GroupSerializer extends AbstractSerializer
{ {

View File

@ -34,7 +34,7 @@ abstract class AbstractCommand extends Command
$this->input = $input; $this->input = $input;
$this->output = $output; $this->output = $output;
$this->fire(); return $this->fire() ?: 0;
} }
/** /**

View File

@ -91,7 +91,7 @@ class UserState extends AbstractModel
* @param Builder $query * @param Builder $query
* @return Builder * @return Builder
*/ */
protected function setKeysForSaveQuery(Builder $query) protected function setKeysForSaveQuery($query)
{ {
$query->where('discussion_id', $this->discussion_id) $query->where('discussion_id', $this->discussion_id)
->where('user_id', $this->user_id); ->where('user_id', $this->user_id);

View File

@ -18,7 +18,7 @@ use Flarum\User\User;
use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\Factory;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use Psr\Http\Message\ServerRequestInterface as Request; use Psr\Http\Message\ServerRequestInterface as Request;
use Symfony\Component\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
class Index class Index
{ {

View File

@ -32,7 +32,7 @@ use Flarum\Settings\Event\Saved;
use Flarum\Settings\Event\Saving; use Flarum\Settings\Event\Saving;
use Flarum\Settings\SettingsRepositoryInterface; use Flarum\Settings\SettingsRepositoryInterface;
use Laminas\Stratigility\MiddlewarePipe; use Laminas\Stratigility\MiddlewarePipe;
use Symfony\Component\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
class ForumServiceProvider extends AbstractServiceProvider class ForumServiceProvider extends AbstractServiceProvider
{ {

View File

@ -12,7 +12,7 @@ namespace Flarum\Foundation;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use Illuminate\Validation\Factory; use Illuminate\Validation\Factory;
use Illuminate\Validation\ValidationException; use Illuminate\Validation\ValidationException;
use Symfony\Component\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
abstract class AbstractValidator abstract class AbstractValidator
{ {

View File

@ -14,7 +14,7 @@ use Illuminate\Contracts\View\Factory as ViewFactory;
use Laminas\Diactoros\Response\HtmlResponse; use Laminas\Diactoros\Response\HtmlResponse;
use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request; use Psr\Http\Message\ServerRequestInterface as Request;
use Symfony\Component\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
/** /**
* A formatter for turning caught exceptions into "pretty" HTML error pages. * A formatter for turning caught exceptions into "pretty" HTML error pages.

View File

@ -39,7 +39,7 @@ class Permission extends AbstractModel
* @param Builder $query * @param Builder $query
* @return Builder * @return Builder
*/ */
protected function setKeysForSaveQuery(Builder $query) protected function setKeysForSaveQuery($query)
{ {
$query->where('group_id', $this->group_id) $query->where('group_id', $this->group_id)
->where('permission', $this->permission); ->where('permission', $this->permission);

View File

@ -15,7 +15,8 @@ use Flarum\Foundation\Paths;
use Flarum\Settings\SettingsRepositoryInterface; use Flarum\Settings\SettingsRepositoryInterface;
use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Contracts\Translation\Translator as TranslatorContract; use Illuminate\Contracts\Translation\Translator as TranslatorContract;
use Symfony\Component\Translation\TranslatorInterface; use Symfony\Component\Translation\TranslatorInterface as DeprecatedTranslatorInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
class LocaleServiceProvider extends AbstractServiceProvider class LocaleServiceProvider extends AbstractServiceProvider
{ {
@ -62,9 +63,11 @@ class LocaleServiceProvider extends AbstractServiceProvider
return $translator; return $translator;
}); });
$this->container->alias('translator', Translator::class); $this->container->alias('translator', Translator::class);
$this->container->alias('translator', TranslatorContract::class); $this->container->alias('translator', TranslatorContract::class);
$this->container->alias('translator', TranslatorInterface::class); $this->container->alias('translator', TranslatorInterface::class);
$this->container->alias('translator', DeprecatedTranslatorInterface::class);
} }
private function getDefaultLocale(): string private function getDefaultLocale(): string

View File

@ -12,8 +12,9 @@ namespace Flarum\Locale;
use Illuminate\Contracts\Translation\Translator as TranslatorContract; use Illuminate\Contracts\Translation\Translator as TranslatorContract;
use Symfony\Component\Translation\MessageCatalogueInterface; use Symfony\Component\Translation\MessageCatalogueInterface;
use Symfony\Component\Translation\Translator as BaseTranslator; use Symfony\Component\Translation\Translator as BaseTranslator;
use Symfony\Component\Translation\TranslatorInterface; // Defined locally as BC layer
class Translator extends BaseTranslator implements TranslatorContract class Translator extends BaseTranslator implements TranslatorContract, TranslatorInterface
{ {
const REFERENCE_REGEX = '/^=>\s*([a-z0-9_\-\.]+)$/i'; const REFERENCE_REGEX = '/^=>\s*([a-z0-9_\-\.]+)$/i';
@ -84,4 +85,9 @@ class Translator extends BaseTranslator implements TranslatorContract
return $translation; return $translation;
} }
public function setLocale($locale)
{
parent::setLocale($locale);
}
} }

View File

@ -63,6 +63,7 @@ class MailServiceProvider extends AbstractServiceProvider
$this->container->singleton('mailer', function ($container) { $this->container->singleton('mailer', function ($container) {
$mailer = new Mailer( $mailer = new Mailer(
'flarum',
$container['view'], $container['view'],
$container['swift.mailer'], $container['swift.mailer'],
$container['events'] $container['events']

View File

@ -9,7 +9,7 @@
namespace Flarum\Notification; namespace Flarum\Notification;
use Symfony\Component\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
interface MailableInterface interface MailableInterface
{ {
@ -23,7 +23,11 @@ interface MailableInterface
/** /**
* Get the subject line for a notification email. * Get the subject line for a notification email.
* *
* @param TranslatorInterface $translator
*
* @return string * @return string
*/ */
public function getEmailSubject(TranslatorInterface $translator); // Uncomment beta 17. Commented as temporary BC layer since Symfony changed
// the namespace of their translator interface
// public function getEmailSubject(TranslatorInterface $translator);
} }

View File

@ -12,7 +12,7 @@ namespace Flarum\Notification;
use Flarum\User\User; use Flarum\User\User;
use Illuminate\Contracts\Mail\Mailer; use Illuminate\Contracts\Mail\Mailer;
use Illuminate\Mail\Message; use Illuminate\Mail\Message;
use Symfony\Component\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
class NotificationMailer class NotificationMailer
{ {

View File

@ -12,6 +12,7 @@ namespace Flarum\Queue;
use Exception; use Exception;
use Illuminate\Contracts\Debug\ExceptionHandler as ExceptionHandling; use Illuminate\Contracts\Debug\ExceptionHandler as ExceptionHandling;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use Throwable;
class ExceptionHandler implements ExceptionHandling class ExceptionHandler implements ExceptionHandling
{ {
@ -28,10 +29,10 @@ class ExceptionHandler implements ExceptionHandling
/** /**
* Report or log an exception. * Report or log an exception.
* *
* @param \Exception $e * @param Throwable $e
* @return void * @return void
*/ */
public function report(Exception $e) public function report(Throwable $e)
{ {
$this->logger->error((string) $e); $this->logger->error((string) $e);
} }
@ -40,10 +41,10 @@ class ExceptionHandler implements ExceptionHandling
* Render an exception into an HTTP response. * Render an exception into an HTTP response.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param \Exception $e * @param Throwable $e
* @return \Symfony\Component\HttpFoundation\Response * @return \Symfony\Component\HttpFoundation\Response
*/ */
public function render($request, Exception $e) public function render($request, Throwable $e)
{ {
// TODO: Implement render() method. // TODO: Implement render() method.
} }
@ -52,10 +53,10 @@ class ExceptionHandler implements ExceptionHandling
* Render an exception to the console. * Render an exception to the console.
* *
* @param \Symfony\Component\Console\Output\OutputInterface $output * @param \Symfony\Component\Console\Output\OutputInterface $output
* @param \Exception $e * @param Throwable $e
* @return void * @return void
*/ */
public function renderForConsole($output, Exception $e) public function renderForConsole($output, Throwable $e)
{ {
// TODO: Implement renderForConsole() method. // TODO: Implement renderForConsole() method.
} }
@ -63,10 +64,10 @@ class ExceptionHandler implements ExceptionHandling
/** /**
* Determine if the exception should be reported. * Determine if the exception should be reported.
* *
* @param \Exception $e * @param Throwable $e
* @return bool * @return bool
*/ */
public function shouldReport(Exception $e) public function shouldReport(Throwable $e)
{ {
return true; return true;
} }

View File

@ -0,0 +1,20 @@
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Symfony\Component\Translation;
/**
* @deprecated beta 16, remove beta 17.
* This is here to provide a graceful transition for classes typehinting the old interface.
* Temporarily, `Flarum\Locale\Translator` will implement this to avoid breaking that typehint.
* Before beta 17, this should be removed from autoload.
*/
interface TranslatorInterface
{
}

View File

@ -14,7 +14,7 @@ use Flarum\Mail\Job\SendRawEmailJob;
use Flarum\Settings\SettingsRepositoryInterface; use Flarum\Settings\SettingsRepositoryInterface;
use Flarum\User\Event\Registered; use Flarum\User\Event\Registered;
use Illuminate\Contracts\Queue\Queue; use Illuminate\Contracts\Queue\Queue;
use Symfony\Component\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
class AccountActivationMailer class AccountActivationMailer
{ {

View File

@ -49,7 +49,7 @@ class AvatarUploader
*/ */
protected function removeFileAfterSave(User $user) protected function removeFileAfterSave(User $user)
{ {
$avatarPath = $user->getOriginal('avatar_url'); $avatarPath = $user->getRawOriginal('avatar_url');
$user->afterSave(function () use ($avatarPath) { $user->afterSave(function () use ($avatarPath) {
if ($this->uploadDir->has($avatarPath)) { if ($this->uploadDir->has($avatarPath)) {

View File

@ -18,7 +18,7 @@ use Illuminate\Contracts\Queue\Queue;
use Illuminate\Contracts\Validation\Factory; use Illuminate\Contracts\Validation\Factory;
use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Validation\ValidationException; use Illuminate\Validation\ValidationException;
use Symfony\Component\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
class RequestPasswordResetHandler class RequestPasswordResetHandler
{ {

View File

@ -14,7 +14,7 @@ use Flarum\Mail\Job\SendRawEmailJob;
use Flarum\Settings\SettingsRepositoryInterface; use Flarum\Settings\SettingsRepositoryInterface;
use Flarum\User\Event\EmailChangeRequested; use Flarum\User\Event\EmailChangeRequested;
use Illuminate\Contracts\Queue\Queue; use Illuminate\Contracts\Queue\Queue;
use Symfony\Component\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
class EmailConfirmationMailer class EmailConfirmationMailer
{ {

View File

@ -45,7 +45,7 @@ class WithApiKeyTest extends TestCase
$this->request('GET', '/api') $this->request('GET', '/api')
); );
$data = json_decode($response->getBody(), true); $data = json_decode($response->getBody()->getContents(), true);
$this->assertFalse($data['data']['attributes']['canViewUserList']); $this->assertFalse($data['data']['attributes']['canViewUserList']);
} }
@ -59,7 +59,7 @@ class WithApiKeyTest extends TestCase
->withAddedHeader('Authorization', 'Token mastertoken; userId=1') ->withAddedHeader('Authorization', 'Token mastertoken; userId=1')
); );
$data = json_decode($response->getBody(), true); $data = json_decode($response->getBody()->getContents(), true);
$this->assertTrue($data['data']['attributes']['canViewUserList']); $this->assertTrue($data['data']['attributes']['canViewUserList']);
$this->assertArrayHasKey('adminUrl', $data['data']['attributes']); $this->assertArrayHasKey('adminUrl', $data['data']['attributes']);
@ -78,7 +78,7 @@ class WithApiKeyTest extends TestCase
->withAddedHeader('Authorization', 'Token personaltoken; userId=1') ->withAddedHeader('Authorization', 'Token personaltoken; userId=1')
); );
$data = json_decode($response->getBody(), true); $data = json_decode($response->getBody()->getContents(), true);
$this->assertTrue($data['data']['attributes']['canViewUserList']); $this->assertTrue($data['data']['attributes']['canViewUserList']);
$this->assertArrayNotHasKey('adminUrl', $data['data']['attributes']); $this->assertArrayNotHasKey('adminUrl', $data['data']['attributes']);
@ -97,7 +97,7 @@ class WithApiKeyTest extends TestCase
->withAddedHeader('Authorization', 'Token personaltoken') ->withAddedHeader('Authorization', 'Token personaltoken')
); );
$data = json_decode($response->getBody(), true); $data = json_decode($response->getBody()->getContents(), true);
$this->assertTrue($data['data']['attributes']['canViewUserList']); $this->assertTrue($data['data']['attributes']['canViewUserList']);
$this->assertArrayNotHasKey('adminUrl', $data['data']['attributes']); $this->assertArrayNotHasKey('adminUrl', $data['data']['attributes']);

View File

@ -86,7 +86,7 @@ class ListTest extends TestCase
$data = json_decode($response->getBody()->getContents(), true)['data']; $data = json_decode($response->getBody()->getContents(), true)['data'];
// Order-independent comparison // Order-independent comparison
$this->assertEquals(['2', '3'], Arr::pluck($data, 'id'), 'IDs do not match', 0.0, 10, true); $this->assertEqualsCanonicalizing(['2', '3'], Arr::pluck($data, 'id'), 'IDs do not match');
} }
/** /**
@ -105,7 +105,7 @@ class ListTest extends TestCase
$data = json_decode($response->getBody()->getContents(), true)['data']; $data = json_decode($response->getBody()->getContents(), true)['data'];
// Order-independent comparison // Order-independent comparison
$this->assertEquals(['1'], Arr::pluck($data, 'id'), 'IDs do not match', 0.0, 10, true); $this->assertEquals(['1'], Arr::pluck($data, 'id'), 'IDs do not match');
} }
/** /**
@ -124,7 +124,7 @@ class ListTest extends TestCase
$data = json_decode($response->getBody()->getContents(), true)['data']; $data = json_decode($response->getBody()->getContents(), true)['data'];
// Order-independent comparison // Order-independent comparison
$this->assertEquals(['3'], Arr::pluck($data, 'id'), 'IDs do not match', 0.0, 10, true); $this->assertEquals(['3'], Arr::pluck($data, 'id'), 'IDs do not match');
} }
/** /**
@ -143,7 +143,7 @@ class ListTest extends TestCase
$data = json_decode($response->getBody()->getContents(), true)['data']; $data = json_decode($response->getBody()->getContents(), true)['data'];
// Order-independent comparison // Order-independent comparison
$this->assertEquals(['1', '2'], Arr::pluck($data, 'id'), 'IDs do not match', 0.0, 10, true); $this->assertEqualsCanonicalizing(['1', '2'], Arr::pluck($data, 'id'), 'IDs do not match');
} }
/** /**
@ -162,7 +162,7 @@ class ListTest extends TestCase
$data = json_decode($response->getBody()->getContents(), true)['data']; $data = json_decode($response->getBody()->getContents(), true)['data'];
// Order-independent comparison // Order-independent comparison
$this->assertEquals(['2', '3'], Arr::pluck($data, 'id'), 'IDs do not match', 0.0, 10, true); $this->assertEqualsCanonicalizing(['2', '3'], Arr::pluck($data, 'id'), 'IDs do not match');
} }
/** /**
@ -181,7 +181,7 @@ class ListTest extends TestCase
$data = json_decode($response->getBody()->getContents(), true)['data']; $data = json_decode($response->getBody()->getContents(), true)['data'];
// Order-independent comparison // Order-independent comparison
$this->assertEquals(['1'], Arr::pluck($data, 'id'), 'IDs do not match', 0.0, 10, true); $this->assertEquals(['1'], Arr::pluck($data, 'id'), 'IDs do not match');
} }
/** /**
@ -200,7 +200,7 @@ class ListTest extends TestCase
$data = json_decode($response->getBody()->getContents(), true)['data']; $data = json_decode($response->getBody()->getContents(), true)['data'];
// Order-independent comparison // Order-independent comparison
$this->assertEquals(['4'], Arr::pluck($data, 'id'), 'IDs do not match', 0.0, 10, true); $this->assertEquals(['4'], Arr::pluck($data, 'id'), 'IDs do not match');
} }
/** /**
@ -219,7 +219,7 @@ class ListTest extends TestCase
$data = json_decode($response->getBody()->getContents(), true)['data']; $data = json_decode($response->getBody()->getContents(), true)['data'];
// Order-independent comparison // Order-independent comparison
$this->assertEquals(['1', '2', '3'], Arr::pluck($data, 'id'), 'IDs do not match', 0.0, 10, true); $this->assertEqualsCanonicalizing(['1', '2', '3'], Arr::pluck($data, 'id'), 'IDs do not match');
} }
/** /**
@ -241,7 +241,7 @@ class ListTest extends TestCase
$data = json_decode($response->getBody()->getContents(), true)['data']; $data = json_decode($response->getBody()->getContents(), true)['data'];
// Order-independent comparison // Order-independent comparison
$this->assertEquals(['3'], Arr::pluck($data, 'id'), 'IDs do not match', 0.0, 10, true); $this->assertEquals(['3'], Arr::pluck($data, 'id'), 'IDs do not match');
} }
/** /**
@ -263,7 +263,7 @@ class ListTest extends TestCase
$data = json_decode($response->getBody()->getContents(), true)['data']; $data = json_decode($response->getBody()->getContents(), true)['data'];
// Order-independent comparison // Order-independent comparison
$this->assertEquals(['1', '2'], Arr::pluck($data, 'id'), 'IDs do not match', 0.0, 10, true); $this->assertEqualsCanonicalizing(['1', '2'], Arr::pluck($data, 'id'), 'IDs do not match');
} }
/** /**
@ -282,7 +282,7 @@ class ListTest extends TestCase
$data = json_decode($response->getBody()->getContents(), true)['data']; $data = json_decode($response->getBody()->getContents(), true)['data'];
// Order-independent comparison // Order-independent comparison
$this->assertEquals(['2', '3'], Arr::pluck($data, 'id'), 'IDs do not match', 0.0, 10, true); $this->assertEqualsCanonicalizing(['2', '3'], Arr::pluck($data, 'id'), 'IDs do not match');
} }
/** /**
@ -301,7 +301,7 @@ class ListTest extends TestCase
$data = json_decode($response->getBody()->getContents(), true)['data']; $data = json_decode($response->getBody()->getContents(), true)['data'];
// Order-independent comparison // Order-independent comparison
$this->assertEquals(['1'], Arr::pluck($data, 'id'), 'IDs do not match', 0.0, 10, true); $this->assertEquals(['1'], Arr::pluck($data, 'id'), 'IDs do not match');
} }
/** /**
@ -320,7 +320,7 @@ class ListTest extends TestCase
$data = json_decode($response->getBody()->getContents(), true)['data']; $data = json_decode($response->getBody()->getContents(), true)['data'];
// Order-independent comparison // Order-independent comparison
$this->assertEquals(['3'], Arr::pluck($data, 'id'), 'IDs do not match', 0.0, 10, true); $this->assertEquals(['3'], Arr::pluck($data, 'id'), 'IDs do not match');
} }
/** /**
@ -339,7 +339,7 @@ class ListTest extends TestCase
$data = json_decode($response->getBody()->getContents(), true)['data']; $data = json_decode($response->getBody()->getContents(), true)['data'];
// Order-independent comparison // Order-independent comparison
$this->assertEquals(['1', '2'], Arr::pluck($data, 'id'), 'IDs do not match', 0.0, 10, true); $this->assertEqualsCanonicalizing(['1', '2'], Arr::pluck($data, 'id'), 'IDs do not match');
} }
/** /**
@ -358,7 +358,7 @@ class ListTest extends TestCase
$data = json_decode($response->getBody()->getContents(), true)['data']; $data = json_decode($response->getBody()->getContents(), true)['data'];
// Order-independent comparison // Order-independent comparison
$this->assertEquals(['2', '3'], Arr::pluck($data, 'id'), 'IDs do not match', 0.0, 10, true); $this->assertEqualsCanonicalizing(['2', '3'], Arr::pluck($data, 'id'), 'IDs do not match');
} }
/** /**
@ -377,7 +377,7 @@ class ListTest extends TestCase
$data = json_decode($response->getBody()->getContents(), true)['data']; $data = json_decode($response->getBody()->getContents(), true)['data'];
// Order-independent comparison // Order-independent comparison
$this->assertEquals(['1'], Arr::pluck($data, 'id'), 'IDs do not match', 0.0, 10, true); $this->assertEquals(['1'], Arr::pluck($data, 'id'), 'IDs do not match');
} }
/** /**
@ -396,7 +396,7 @@ class ListTest extends TestCase
$data = json_decode($response->getBody()->getContents(), true)['data']; $data = json_decode($response->getBody()->getContents(), true)['data'];
// Order-independent comparison // Order-independent comparison
$this->assertEquals(['4'], Arr::pluck($data, 'id'), 'IDs do not match', 0.0, 10, true); $this->assertEquals(['4'], Arr::pluck($data, 'id'), 'IDs do not match');
} }
/** /**
@ -415,7 +415,7 @@ class ListTest extends TestCase
$data = json_decode($response->getBody()->getContents(), true)['data']; $data = json_decode($response->getBody()->getContents(), true)['data'];
// Order-independent comparison // Order-independent comparison
$this->assertEquals(['1', '2', '3'], Arr::pluck($data, 'id'), 'IDs do not match', 0.0, 10, true); $this->assertEqualsCanonicalizing(['1', '2', '3'], Arr::pluck($data, 'id'), 'IDs do not match');
} }
/** /**
@ -437,7 +437,7 @@ class ListTest extends TestCase
$data = json_decode($response->getBody()->getContents(), true)['data']; $data = json_decode($response->getBody()->getContents(), true)['data'];
// Order-independent comparison // Order-independent comparison
$this->assertEquals(['3'], Arr::pluck($data, 'id'), 'IDs do not match', 0.0, 10, true); $this->assertEquals(['3'], Arr::pluck($data, 'id'), 'IDs do not match');
} }
/** /**
@ -459,6 +459,6 @@ class ListTest extends TestCase
$data = json_decode($response->getBody()->getContents(), true)['data']; $data = json_decode($response->getBody()->getContents(), true)['data'];
// Order-independent comparison // Order-independent comparison
$this->assertEquals(['1', '2'], Arr::pluck($data, 'id'), 'IDs do not match', 0.0, 10, true); $this->assertEqualsCanonicalizing(['1', '2'], Arr::pluck($data, 'id'), 'IDs do not match');
} }
} }

View File

@ -75,7 +75,7 @@ class ListTest extends TestCase
}, $data['data']); }, $data['data']);
// Order-independent comparison // Order-independent comparison
$this->assertEquals(['3'], $ids, 'IDs do not match', 0.0, 10, true); $this->assertEquals(['3'], $ids, 'IDs do not match');
} }
/** /**
@ -97,7 +97,7 @@ class ListTest extends TestCase
}, $data['data']); }, $data['data']);
// Order-independent comparison // Order-independent comparison
$this->assertEquals(['3'], $ids, 'IDs do not match', 0.0, 10, true); $this->assertEquals(['3'], $ids, 'IDs do not match');
} }
/** /**

View File

@ -68,7 +68,7 @@ class ApiControllerTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertEquals('dataSerializationPrepCustomTitle', $payload['data']['attributes']['title']); $this->assertEquals('dataSerializationPrepCustomTitle', $payload['data']['attributes']['title']);
} }
@ -89,7 +89,7 @@ class ApiControllerTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertEquals(CustomPrepareDataSerializationInvokableClass::class, $payload['data']['attributes']['title']); $this->assertEquals(CustomPrepareDataSerializationInvokableClass::class, $payload['data']['attributes']['title']);
} }
@ -115,7 +115,7 @@ class ApiControllerTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertArrayHasKey('referenceTest', $payload['data']['relationships']); $this->assertArrayHasKey('referenceTest', $payload['data']['relationships']);
} }
@ -139,7 +139,7 @@ class ApiControllerTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertArrayHasKey('referenceTest2', $payload['data']['relationships']); $this->assertArrayHasKey('referenceTest2', $payload['data']['relationships']);
} }
@ -164,7 +164,7 @@ class ApiControllerTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertEquals('dataSerializationPrepCustomTitle2', $payload['data']['attributes']['title']); $this->assertEquals('dataSerializationPrepCustomTitle2', $payload['data']['attributes']['title']);
} }
@ -193,7 +193,7 @@ class ApiControllerTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertEquals('dataSerializationPrepCustomTitle4', $payload['data']['attributes']['title']); $this->assertEquals('dataSerializationPrepCustomTitle4', $payload['data']['attributes']['title']);
} }
@ -218,7 +218,7 @@ class ApiControllerTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertArrayHasKey('customSerializer2', $payload['data']['attributes']); $this->assertArrayHasKey('customSerializer2', $payload['data']['attributes']);
} }
@ -247,7 +247,7 @@ class ApiControllerTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertArrayHasKey('customSerializer', $payload['data']['attributes']); $this->assertArrayHasKey('customSerializer', $payload['data']['attributes']);
} }
@ -263,7 +263,7 @@ class ApiControllerTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertArrayNotHasKey('customSerializer', $payload['data']['attributes']); $this->assertArrayNotHasKey('customSerializer', $payload['data']['attributes']);
} }
@ -284,7 +284,7 @@ class ApiControllerTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertArrayHasKey('customSerializer', $payload['data']['attributes']); $this->assertArrayHasKey('customSerializer', $payload['data']['attributes']);
} }
@ -310,7 +310,7 @@ class ApiControllerTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertArrayHasKey('customSerializer', $payload['data']['attributes']); $this->assertArrayHasKey('customSerializer', $payload['data']['attributes']);
} }
@ -333,7 +333,7 @@ class ApiControllerTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertArrayNotHasKey('customSerializer', $payload['data']['attributes']); $this->assertArrayNotHasKey('customSerializer', $payload['data']['attributes']);
} }
@ -349,7 +349,7 @@ class ApiControllerTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertArrayNotHasKey('customApiControllerRelation', $payload['data']['relationships']); $this->assertArrayNotHasKey('customApiControllerRelation', $payload['data']['relationships']);
$this->assertArrayNotHasKey('customApiControllerRelation2', $payload['data']['relationships']); $this->assertArrayNotHasKey('customApiControllerRelation2', $payload['data']['relationships']);
@ -375,7 +375,7 @@ class ApiControllerTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertArrayHasKey('customApiControllerRelation', $payload['data']['relationships']); $this->assertArrayHasKey('customApiControllerRelation', $payload['data']['relationships']);
} }
@ -402,7 +402,7 @@ class ApiControllerTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertArrayHasKey('customApiControllerRelation2', $payload['data']['relationships']); $this->assertArrayHasKey('customApiControllerRelation2', $payload['data']['relationships']);
} }
@ -418,7 +418,7 @@ class ApiControllerTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertArrayHasKey('groups', $payload['data']['relationships']); $this->assertArrayHasKey('groups', $payload['data']['relationships']);
} }
@ -439,7 +439,7 @@ class ApiControllerTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertArrayNotHasKey('groups', Arr::get($payload, 'data.relationships', [])); $this->assertArrayNotHasKey('groups', Arr::get($payload, 'data.relationships', []));
} }
@ -481,7 +481,7 @@ class ApiControllerTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertCount(3, $payload['data']); $this->assertCount(3, $payload['data']);
} }
@ -502,7 +502,7 @@ class ApiControllerTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertCount(1, $payload['data']); $this->assertCount(1, $payload['data']);
} }
@ -525,7 +525,7 @@ class ApiControllerTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertCount(1, $payload['data']); $this->assertCount(1, $payload['data']);
} }
@ -587,7 +587,7 @@ class ApiControllerTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertEquals(200, $response->getStatusCode()); $this->assertEquals(200, $response->getStatusCode());
$this->assertEquals([3, 1, 2], Arr::pluck($payload['data'], 'id')); $this->assertEquals([3, 1, 2], Arr::pluck($payload['data'], 'id'));
@ -647,7 +647,7 @@ class ApiControllerTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertEquals(200, $response->getStatusCode()); $this->assertEquals(200, $response->getStatusCode());
$this->assertEquals([2, 1, 3], Arr::pluck($payload['data'], 'id')); $this->assertEquals([2, 1, 3], Arr::pluck($payload['data'], 'id'));

View File

@ -62,7 +62,7 @@ class ApiSerializerTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertArrayNotHasKey('customAttribute', $payload['data']['attributes']); $this->assertArrayNotHasKey('customAttribute', $payload['data']['attributes']);
} }
@ -89,7 +89,7 @@ class ApiSerializerTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertArrayHasKey('customAttribute', $payload['data']['attributes']); $this->assertArrayHasKey('customAttribute', $payload['data']['attributes']);
} }
@ -112,7 +112,7 @@ class ApiSerializerTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertArrayHasKey('customAttributeFromInvokable', $payload['data']['attributes']); $this->assertArrayHasKey('customAttributeFromInvokable', $payload['data']['attributes']);
} }
@ -139,7 +139,7 @@ class ApiSerializerTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertArrayHasKey('customAttribute', $payload['data']['attributes']); $this->assertArrayHasKey('customAttribute', $payload['data']['attributes']);
} }
@ -172,7 +172,7 @@ class ApiSerializerTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertArrayHasKey('customAttribute', $payload['data']['attributes']); $this->assertArrayHasKey('customAttribute', $payload['data']['attributes']);
$this->assertEquals('newValue', $payload['data']['attributes']['customAttribute']); $this->assertEquals('newValue', $payload['data']['attributes']['customAttribute']);
@ -200,7 +200,7 @@ class ApiSerializerTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertArrayHasKey('customSingleAttribute', $payload['data']['attributes']); $this->assertArrayHasKey('customSingleAttribute', $payload['data']['attributes']);
$this->assertArrayHasKey('customSingleAttribute_0', $payload['data']['attributes']); $this->assertArrayHasKey('customSingleAttribute_0', $payload['data']['attributes']);
@ -225,7 +225,7 @@ class ApiSerializerTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertArrayHasKey('customSingleAttribute_1', $payload['data']['attributes']); $this->assertArrayHasKey('customSingleAttribute_1', $payload['data']['attributes']);
} }
@ -250,7 +250,7 @@ class ApiSerializerTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertArrayHasKey('customSingleAttribute_2', $payload['data']['attributes']); $this->assertArrayHasKey('customSingleAttribute_2', $payload['data']['attributes']);
} }
@ -279,7 +279,7 @@ class ApiSerializerTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertArrayHasKey('customSingleAttribute_3', $payload['data']['attributes']); $this->assertArrayHasKey('customSingleAttribute_3', $payload['data']['attributes']);
$this->assertEquals('newValue', $payload['data']['attributes']['customSingleAttribute_3']); $this->assertEquals('newValue', $payload['data']['attributes']['customSingleAttribute_3']);
@ -312,7 +312,7 @@ class ApiSerializerTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertArrayHasKey('someCustomAttribute', $payload['data']['attributes']); $this->assertArrayHasKey('someCustomAttribute', $payload['data']['attributes']);
$this->assertEquals('newValue', $payload['data']['attributes']['someCustomAttribute']); $this->assertEquals('newValue', $payload['data']['attributes']['someCustomAttribute']);

View File

@ -18,7 +18,7 @@ use Flarum\Tests\integration\TestCase;
use Flarum\User\User; use Flarum\User\User;
use Illuminate\Contracts\Bus\Dispatcher as BusDispatcher; use Illuminate\Contracts\Bus\Dispatcher as BusDispatcher;
use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Events\Dispatcher;
use Symfony\Component\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
class EventTest extends TestCase class EventTest extends TestCase
{ {

View File

@ -60,8 +60,8 @@ class FilterTest extends TestCase
$this->prepDb(); $this->prepDb();
$searchForAll = json_encode($this->filterDiscussions([], 5)); $searchForAll = json_encode($this->filterDiscussions([], 5));
$this->assertContains('DISCUSSION 1', $searchForAll); $this->assertStringContainsString('DISCUSSION 1', $searchForAll);
$this->assertContains('DISCUSSION 2', $searchForAll); $this->assertStringContainsString('DISCUSSION 2', $searchForAll);
} }
/** /**
@ -74,8 +74,8 @@ class FilterTest extends TestCase
$this->prepDb(); $this->prepDb();
$withResultSearch = json_encode($this->filterDiscussions(['noResult' => 0], 5)); $withResultSearch = json_encode($this->filterDiscussions(['noResult' => 0], 5));
$this->assertContains('DISCUSSION 1', $withResultSearch); $this->assertStringContainsString('DISCUSSION 1', $withResultSearch);
$this->assertContains('DISCUSSION 2', $withResultSearch); $this->assertStringContainsString('DISCUSSION 2', $withResultSearch);
$this->assertEquals([], $this->filterDiscussions(['noResult' => 1], 5)); $this->assertEquals([], $this->filterDiscussions(['noResult' => 1], 5));
} }

View File

@ -34,7 +34,7 @@ class MailTest extends TestCase
]) ])
); );
$fields = json_decode($response->getBody(), true)['data']['attributes']['fields']; $fields = json_decode($response->getBody()->getContents(), true)['data']['attributes']['fields'];
// The custom driver does not exist // The custom driver does not exist
$this->assertArrayNotHasKey('custom', $fields); $this->assertArrayNotHasKey('custom', $fields);
@ -65,7 +65,7 @@ class MailTest extends TestCase
]) ])
); );
$fields = json_decode($response->getBody(), true)['data']['attributes']['fields']; $fields = json_decode($response->getBody()->getContents(), true)['data']['attributes']['fields'];
$this->assertArrayHasKey('custom', $fields); $this->assertArrayHasKey('custom', $fields);
$this->assertEquals(['customSetting1' => ''], $fields['custom']); $this->assertEquals(['customSetting1' => ''], $fields['custom']);
@ -87,7 +87,7 @@ class MailTest extends TestCase
]) ])
); );
$requiredFields = json_decode($response->getBody(), true)['data']['attributes']['fields']['smtp']; $requiredFields = json_decode($response->getBody()->getContents(), true)['data']['attributes']['fields']['smtp'];
$this->assertEquals(['customSetting1' => ''], $requiredFields); $this->assertEquals(['customSetting1' => ''], $requiredFields);
} }

View File

@ -50,7 +50,7 @@ class SettingsTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertArrayNotHasKey('customPrefix.customSetting', $payload['data']['attributes']); $this->assertArrayNotHasKey('customPrefix.customSetting', $payload['data']['attributes']);
} }
@ -73,7 +73,7 @@ class SettingsTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertArrayHasKey('customPrefix.customSetting', $payload['data']['attributes']); $this->assertArrayHasKey('customPrefix.customSetting', $payload['data']['attributes']);
$this->assertEquals('customValue', $payload['data']['attributes']['customPrefix.customSetting']); $this->assertEquals('customValue', $payload['data']['attributes']['customPrefix.customSetting']);
@ -99,7 +99,7 @@ class SettingsTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertArrayHasKey('customPrefix.customSetting', $payload['data']['attributes']); $this->assertArrayHasKey('customPrefix.customSetting', $payload['data']['attributes']);
$this->assertEquals('customValueModified', $payload['data']['attributes']['customPrefix.customSetting']); $this->assertEquals('customValueModified', $payload['data']['attributes']['customPrefix.customSetting']);
@ -123,7 +123,7 @@ class SettingsTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertArrayHasKey('customPrefix.customSetting2', $payload['data']['attributes']); $this->assertArrayHasKey('customPrefix.customSetting2', $payload['data']['attributes']);
$this->assertEquals('customValueModifiedByInvokable', $payload['data']['attributes']['customPrefix.customSetting2']); $this->assertEquals('customValueModifiedByInvokable', $payload['data']['attributes']['customPrefix.customSetting2']);
@ -147,7 +147,7 @@ class SettingsTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertArrayHasKey('customPrefix.noCustomSetting', $payload['data']['attributes']); $this->assertArrayHasKey('customPrefix.noCustomSetting', $payload['data']['attributes']);
$this->assertEquals('customDefault', $payload['data']['attributes']['customPrefix.noCustomSetting']); $this->assertEquals('customDefault', $payload['data']['attributes']['customPrefix.noCustomSetting']);
@ -173,7 +173,7 @@ class SettingsTest extends TestCase
]) ])
); );
$payload = json_decode($response->getBody(), true); $payload = json_decode($response->getBody()->getContents(), true);
$this->assertArrayHasKey('customPrefix.noCustomSetting', $payload['data']['attributes']); $this->assertArrayHasKey('customPrefix.noCustomSetting', $payload['data']['attributes']);
$this->assertEquals('customDefaultModified2', $payload['data']['attributes']['customPrefix.noCustomSetting']); $this->assertEquals('customDefaultModified2', $payload['data']['attributes']['customPrefix.noCustomSetting']);

View File

@ -77,12 +77,12 @@ class SimpleFlarumSearchTest extends TestCase
$this->prepDb(); $this->prepDb();
$searchForAll = json_encode($this->searchDiscussions('in text', 5)); $searchForAll = json_encode($this->searchDiscussions('in text', 5));
$this->assertContains('DISCUSSION 1', $searchForAll); $this->assertStringContainsString('DISCUSSION 1', $searchForAll);
$this->assertContains('DISCUSSION 2', $searchForAll); $this->assertStringContainsString('DISCUSSION 2', $searchForAll);
$searchForSecond = json_encode($this->searchDiscussions('lightsail', 5)); $searchForSecond = json_encode($this->searchDiscussions('lightsail', 5));
$this->assertNotContains('DISCUSSION 1', $searchForSecond); $this->assertStringNotContainsString('DISCUSSION 1', $searchForSecond);
$this->assertContains('DISCUSSION 2', $searchForSecond); $this->assertStringContainsString('DISCUSSION 2', $searchForSecond);
} }
/** /**
@ -105,8 +105,8 @@ class SimpleFlarumSearchTest extends TestCase
$this->prepDb(); $this->prepDb();
$withResultSearch = json_encode($this->searchDiscussions('noResult:0', 5)); $withResultSearch = json_encode($this->searchDiscussions('noResult:0', 5));
$this->assertContains('DISCUSSION 1', $withResultSearch); $this->assertStringContainsString('DISCUSSION 1', $withResultSearch);
$this->assertContains('DISCUSSION 2', $withResultSearch); $this->assertStringContainsString('DISCUSSION 2', $withResultSearch);
$this->assertEquals('[]', json_encode($this->searchDiscussions('noResult:1', 5))); $this->assertEquals('[]', json_encode($this->searchDiscussions('noResult:1', 5)));
} }

View File

@ -1,22 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit
<phpunit backupGlobals="false" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupStaticAttributes="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
colors="true" backupGlobals="false"
convertErrorsToExceptions="true" backupStaticAttributes="false"
convertNoticesToExceptions="true" colors="true"
convertWarningsToExceptions="true" convertErrorsToExceptions="true"
processIsolation="true" convertNoticesToExceptions="true"
stopOnFailure="false"> convertWarningsToExceptions="true"
processIsolation="true"
stopOnFailure="false"
>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">../src/</directory>
</include>
</coverage>
<testsuites> <testsuites>
<testsuite name="Flarum Integration Tests"> <testsuite name="Flarum Integration Tests">
<directory suffix="Test.php">./integration</directory> <directory suffix="Test.php">./integration</directory>
</testsuite> </testsuite>
</testsuites> </testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src/</directory>
</whitelist>
</filter>
</phpunit> </phpunit>

View File

@ -1,25 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit
<phpunit backupGlobals="false" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupStaticAttributes="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
colors="true" backupGlobals="false"
convertErrorsToExceptions="true" backupStaticAttributes="false"
convertNoticesToExceptions="true" colors="true"
convertWarningsToExceptions="true" convertErrorsToExceptions="true"
processIsolation="false" convertNoticesToExceptions="true"
stopOnFailure="false"> convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">../src/</directory>
</include>
</coverage>
<testsuites> <testsuites>
<testsuite name="Flarum Unit Tests"> <testsuite name="Flarum Unit Tests">
<directory suffix="Test.php">./unit</directory> <directory suffix="Test.php">./unit</directory>
</testsuite> </testsuite>
</testsuites> </testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src/</directory>
</whitelist>
</filter>
<listeners> <listeners>
<listener class="\Mockery\Adapter\Phpunit\TestListener"></listener> <listener class="\Mockery\Adapter\Phpunit\TestListener" />
</listeners> </listeners>
</phpunit> </phpunit>

View File

@ -41,7 +41,7 @@ class WritablePathsTest extends TestCase
$problems = $writable->problems(); $problems = $writable->problems();
$this->assertCount(1, $problems); $this->assertCount(1, $problems);
$this->assertRegExp( $this->assertMatchesRegularExpression(
"%^The .+/tests/fixtures/writable_paths/missing directory doesn't exist$%", "%^The .+/tests/fixtures/writable_paths/missing directory doesn't exist$%",
$problems[0]['message'] $problems[0]['message']
); );
@ -59,7 +59,7 @@ class WritablePathsTest extends TestCase
$problems = $writable->problems(); $problems = $writable->problems();
$this->assertCount(1, $problems); $this->assertCount(1, $problems);
$this->assertRegExp( $this->assertMatchesRegularExpression(
"%^The .+/tests/fixtures/writable_paths/missing directory doesn't exist$%", "%^The .+/tests/fixtures/writable_paths/missing directory doesn't exist$%",
$problems[0]['message'] $problems[0]['message']
); );

View File

@ -56,7 +56,7 @@ class AvatarUploaderTest extends TestCase
} }
$user->syncOriginal(); $user->syncOriginal();
$this->assertEquals(null, $user->getOriginal('avatar_url')); $this->assertEquals(null, $user->getRawOriginal('avatar_url'));
} }
public function test_removing_url_avatar_removes_no_file() public function test_removing_url_avatar_removes_no_file()
@ -76,7 +76,7 @@ class AvatarUploaderTest extends TestCase
} }
$user->syncOriginal(); $user->syncOriginal();
$this->assertEquals(null, $user->getOriginal('avatar_url')); $this->assertEquals(null, $user->getRawOriginal('avatar_url'));
} }
public function test_changing_avatar_removes_file() public function test_changing_avatar_removes_file()
@ -97,6 +97,6 @@ class AvatarUploaderTest extends TestCase
} }
$user->syncOriginal(); $user->syncOriginal();
$this->assertNotEquals('ABCDEFGHabcdefgh.png', $user->getOriginal('avatar_url')); $this->assertNotEquals('ABCDEFGHabcdefgh.png', $user->getRawOriginal('avatar_url'));
} }
} }