chore: update dependencies (#4012)

* chore: phpunit 10

* chore: config

* Apply fixes from StyleCI

* chore: phpunit 11 (php 8.2 minimum requirement)

* feat: laravel 11

* Apply fixes from StyleCI

* feat: carbon v3

* fixes
This commit is contained in:
Sami Mazouz 2024-08-06 16:50:09 +01:00 committed by GitHub
parent 2f92a6c739
commit 6b336c5ea8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
205 changed files with 1176 additions and 2361 deletions

View File

@ -32,7 +32,7 @@ on:
type: string type: string
required: false required: false
# Keep PHP versions synced with build-install-packages.yml # Keep PHP versions synced with build-install-packages.yml
default: '["8.1", "8.2", "8.3"]' default: '["8.2", "8.3"]'
php_extensions: php_extensions:
description: PHP extensions to install. description: PHP extensions to install.

View File

@ -6,7 +6,7 @@ on:
env: env:
VERSION: ${{ github.event.release.tag_name }} VERSION: ${{ github.event.release.tag_name }}
PHP_VERSIONS: '8.1 8.2 8.3' PHP_VERSIONS: '8.2 8.3'
INSTALL_PACKAGES_INPUTS: '{ "flarum_version": "{0}", "php_versions": "{1}" }' INSTALL_PACKAGES_INPUTS: '{ "flarum_version": "{0}", "php_versions": "{1}" }'
jobs: jobs:

View File

@ -105,7 +105,7 @@
"flarum/testing": "self.version" "flarum/testing": "self.version"
}, },
"require": { "require": {
"php": "^8.1", "php": "^8.2",
"ext-json": "*", "ext-json": "*",
"components/font-awesome": "^5.15.0", "components/font-awesome": "^5.15.0",
"composer/composer": "^2.7", "composer/composer": "^2.7",
@ -115,22 +115,22 @@
"fakerphp/faker": "^1.9.1", "fakerphp/faker": "^1.9.1",
"franzl/whoops-middleware": "2.0", "franzl/whoops-middleware": "2.0",
"guzzlehttp/guzzle": "*", "guzzlehttp/guzzle": "*",
"illuminate/bus": "^10.0", "illuminate/bus": "^11.0",
"illuminate/cache": "^10.0", "illuminate/cache": "^11.0",
"illuminate/config": "^10.0", "illuminate/config": "^11.0",
"illuminate/console": "^10.0", "illuminate/console": "^11.0",
"illuminate/container": "^10.0", "illuminate/container": "^11.0",
"illuminate/contracts": "^10.0", "illuminate/contracts": "^11.0",
"illuminate/database": "^10.0", "illuminate/database": "^11.0",
"illuminate/events": "^10.0", "illuminate/events": "^11.0",
"illuminate/filesystem": "^10.0", "illuminate/filesystem": "^11.0",
"illuminate/hashing": "^10.0", "illuminate/hashing": "^11.0",
"illuminate/mail": "^10.0", "illuminate/mail": "^11.0",
"illuminate/queue": "^10.0", "illuminate/queue": "^11.0",
"illuminate/session": "^10.0", "illuminate/session": "^11.0",
"illuminate/support": "^10.0", "illuminate/support": "^11.0",
"illuminate/validation": "^10.0", "illuminate/validation": "^11.0",
"illuminate/view": "^10.0", "illuminate/view": "^11.0",
"intervention/image": "^3.2", "intervention/image": "^3.2",
"jenssegers/agent": "^2.6", "jenssegers/agent": "^2.6",
"laminas/laminas-diactoros": "^3.0", "laminas/laminas-diactoros": "^3.0",
@ -143,34 +143,33 @@
"middlewares/base-path-router": "^2.0.1", "middlewares/base-path-router": "^2.0.1",
"middlewares/request-handler": "^2.0.2", "middlewares/request-handler": "^2.0.2",
"monolog/monolog": "^3.3", "monolog/monolog": "^3.3",
"nesbot/carbon": "^2.66", "nesbot/carbon": "^3.0",
"nikic/fast-route": "^1.3", "nikic/fast-route": "^1.3",
"psr/http-message": "^1.1", "psr/http-message": "^1.1",
"psr/http-server-handler": "^1.0.2", "psr/http-server-handler": "^1.0.2",
"psr/http-server-middleware": "^1.0.2", "psr/http-server-middleware": "^1.0.2",
"pusher/pusher-php-server": "^7.2", "pusher/pusher-php-server": "^7.2",
"s9e/text-formatter": "^2.13", "s9e/text-formatter": "^2.13",
"staudenmeir/eloquent-eager-limit": "^1.8.2",
"sycho/sourcemap": "^2.0.0", "sycho/sourcemap": "^2.0.0",
"symfony/config": "^6.3", "symfony/config": "^7.0",
"symfony/console": "^6.3", "symfony/console": "^7.0",
"symfony/event-dispatcher": "^6.3", "symfony/event-dispatcher": "^7.0",
"symfony/http-client": "^6.3", "symfony/http-client": "^7.0",
"symfony/mailgun-mailer": "^6.3", "symfony/mailgun-mailer": "^7.0",
"symfony/mime": "^6.3", "symfony/mime": "^7.0",
"symfony/polyfill-intl-messageformatter": "^1.27", "symfony/polyfill-intl-messageformatter": "^1.27",
"symfony/postmark-mailer": "^6.3", "symfony/postmark-mailer": "^7.0",
"symfony/translation": "^6.3", "symfony/translation": "^7.0",
"symfony/yaml": "^6.3", "symfony/yaml": "^7.0",
"flarum/json-api-server": "^0.1.0", "flarum/json-api-server": "^0.1.0",
"wikimedia/less.php": "^4.1" "wikimedia/less.php": "^4.1"
}, },
"require-dev": { "require-dev": {
"mockery/mockery": "^1.5", "mockery/mockery": "^1.5",
"phpunit/phpunit": "^9.0", "phpunit/phpunit": "^11.0",
"phpstan/phpstan": "^1.10.0", "phpstan/phpstan": "^1.10.0",
"larastan/larastan": "^2.7", "larastan/larastan": "^2.7",
"symfony/var-dumper": "^6.3" "symfony/var-dumper": "^7.0"
}, },
"config": { "config": {
"sort-packages": true "sort-packages": true

View File

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

View File

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

View File

@ -1,28 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit <phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
backupGlobals="false" backupGlobals="false"
backupStaticAttributes="false" cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true" colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false" processIsolation="false"
stopOnFailure="false" stopOnFailure="false"
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php" bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
> >
<coverage processUncoveredFiles="true"> <source>
<include> <include>
<directory suffix=".php">../src/</directory> <directory suffix=".php">../src/</directory>
</include> </include>
</coverage> </source>
<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>
<listeners>
<listener class="\Mockery\Adapter\Phpunit\TestListener" />
</listeners>
</phpunit> </phpunit>

View File

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

View File

@ -64,7 +64,7 @@ trait InteractsWithUnapprovedContent
/** /**
* null: Guest, 2: Normal User. * null: Guest, 2: Normal User.
*/ */
public function unallowedUsers(): array public static function unallowedUsers(): array
{ {
return [[null], [2]]; return [[null], [2]];
} }
@ -72,7 +72,7 @@ trait InteractsWithUnapprovedContent
/** /**
* 1: Admin, 3: Permission Given, 4: Discussions Author. * 1: Admin, 3: Permission Given, 4: Discussions Author.
*/ */
public function allowedUsers(): array public static function allowedUsers(): array
{ {
return [[1], [3], [4]]; return [[1], [3], [4]];
} }

View File

@ -17,6 +17,7 @@ use Flarum\Post\Post;
use Flarum\Testing\integration\RetrievesAuthorizedUsers; use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase; use Flarum\Testing\integration\TestCase;
use Flarum\User\User; use Flarum\User\User;
use PHPUnit\Framework\Attributes\Test;
class ApprovePostsTest extends TestCase class ApprovePostsTest extends TestCase
{ {
@ -59,9 +60,7 @@ class ApprovePostsTest extends TestCase
]); ]);
} }
/** #[Test]
* @test
*/
public function can_approve_unapproved_post() public function can_approve_unapproved_post()
{ {
$response = $this->send( $response = $this->send(
@ -81,9 +80,7 @@ class ApprovePostsTest extends TestCase
$this->assertEquals(1, $this->database()->table('posts')->where('id', 3)->where('is_approved', 1)->count()); $this->assertEquals(1, $this->database()->table('posts')->where('id', 3)->where('is_approved', 1)->count());
} }
/** #[Test]
* @test
*/
public function cannot_approve_post_without_permission() public function cannot_approve_post_without_permission()
{ {
$response = $this->send( $response = $this->send(
@ -103,9 +100,7 @@ class ApprovePostsTest extends TestCase
$this->assertEquals(0, $this->database()->table('posts')->where('id', 3)->where('is_approved', 1)->count()); $this->assertEquals(0, $this->database()->table('posts')->where('id', 3)->where('is_approved', 1)->count());
} }
/** #[Test]
* @test
*/
public function hiding_post_silently_approves_it() public function hiding_post_silently_approves_it()
{ {
$response = $this->send( $response = $this->send(

View File

@ -17,6 +17,8 @@ use Flarum\Post\Post;
use Flarum\Testing\integration\RetrievesAuthorizedUsers; use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase; use Flarum\Testing\integration\TestCase;
use Flarum\User\User; use Flarum\User\User;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
class CreatePostsTest extends TestCase class CreatePostsTest extends TestCase
{ {
@ -68,10 +70,8 @@ class CreatePostsTest extends TestCase
]); ]);
} }
/** #[Test]
* @dataProvider startDiscussionDataProvider #[DataProvider('startDiscussionDataProvider')]
* @test
*/
public function can_start_discussion_without_approval_when_allowed(int $authenticatedAs, bool $allowed) public function can_start_discussion_without_approval_when_allowed(int $authenticatedAs, bool $allowed)
{ {
$this->database()->table('group_permission')->where('group_id', Group::MEMBER_ID)->where('permission', 'discussion.startWithoutApproval')->delete(); $this->database()->table('group_permission')->where('group_id', Group::MEMBER_ID)->where('permission', 'discussion.startWithoutApproval')->delete();
@ -98,10 +98,8 @@ class CreatePostsTest extends TestCase
$this->assertEquals($allowed ? 1 : 0, $this->database()->table('discussions')->where('id', $json['data']['id'])->value('is_approved')); $this->assertEquals($allowed ? 1 : 0, $this->database()->table('discussions')->where('id', $json['data']['id'])->value('is_approved'));
} }
/** #[Test]
* @dataProvider replyToDiscussionDataProvider #[DataProvider('replyToDiscussionDataProvider')]
* @test
*/
public function can_reply_without_approval_when_allowed(?int $authenticatedAs, bool $allowed) public function can_reply_without_approval_when_allowed(?int $authenticatedAs, bool $allowed)
{ {
$this->database()->table('group_permission')->where('group_id', Group::MEMBER_ID)->where('permission', 'discussion.replyWithoutApproval')->delete(); $this->database()->table('group_permission')->where('group_id', Group::MEMBER_ID)->where('permission', 'discussion.replyWithoutApproval')->delete();

View File

@ -13,6 +13,8 @@ use Flarum\Approval\Tests\integration\InteractsWithUnapprovedContent;
use Flarum\Testing\integration\RetrievesAuthorizedUsers; use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase; use Flarum\Testing\integration\TestCase;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
class ListDiscussionsTest extends TestCase class ListDiscussionsTest extends TestCase
{ {
@ -28,10 +30,8 @@ class ListDiscussionsTest extends TestCase
$this->prepareUnapprovedDatabaseContent(); $this->prepareUnapprovedDatabaseContent();
} }
/** #[Test]
* @dataProvider unallowedUsers #[DataProvider('unallowedUsers')]
* @test
*/
public function can_only_see_approved_if_not_allowed_to_approve(?int $authenticatedAs) public function can_only_see_approved_if_not_allowed_to_approve(?int $authenticatedAs)
{ {
$response = $this->send( $response = $this->send(
@ -44,10 +44,8 @@ class ListDiscussionsTest extends TestCase
$this->assertEqualsCanonicalizing([1, 4, 5, 7], Arr::pluck($body['data'], 'id')); $this->assertEqualsCanonicalizing([1, 4, 5, 7], Arr::pluck($body['data'], 'id'));
} }
/** #[Test]
* @dataProvider allowedUsers #[DataProvider('allowedUsers')]
* @test
*/
public function can_see_unapproved_if_allowed_to_approve(int $authenticatedAs) public function can_see_unapproved_if_allowed_to_approve(int $authenticatedAs)
{ {
$response = $this->send( $response = $this->send(

View File

@ -13,6 +13,8 @@ use Flarum\Approval\Tests\integration\InteractsWithUnapprovedContent;
use Flarum\Testing\integration\RetrievesAuthorizedUsers; use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase; use Flarum\Testing\integration\TestCase;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
class ListPostsTest extends TestCase class ListPostsTest extends TestCase
{ {
@ -28,10 +30,8 @@ class ListPostsTest extends TestCase
$this->prepareUnapprovedDatabaseContent(); $this->prepareUnapprovedDatabaseContent();
} }
/** #[Test]
* @dataProvider unallowedUsers #[DataProvider('unallowedUsers')]
* @test
*/
public function can_only_see_approved_if_not_allowed_to_approve(?int $authenticatedAs) public function can_only_see_approved_if_not_allowed_to_approve(?int $authenticatedAs)
{ {
$response = $this->send( $response = $this->send(
@ -50,10 +50,8 @@ class ListPostsTest extends TestCase
$this->assertEqualsCanonicalizing([7, 8, 10], Arr::pluck($body['data'], 'id')); $this->assertEqualsCanonicalizing([7, 8, 10], Arr::pluck($body['data'], 'id'));
} }
/** #[Test]
* @dataProvider allowedUsers #[DataProvider('allowedUsers')]
* @test
*/
public function can_see_unapproved_if_allowed_to_approve(int $authenticatedAs) public function can_see_unapproved_if_allowed_to_approve(int $authenticatedAs)
{ {
$response = $this->send( $response = $this->send(

View File

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

View File

@ -1,28 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit <phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
backupGlobals="false" backupGlobals="false"
backupStaticAttributes="false" cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true" colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false" processIsolation="false"
stopOnFailure="false" stopOnFailure="false"
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php" bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
> >
<coverage processUncoveredFiles="true"> <source>
<include> <include>
<directory suffix=".php">../src/</directory> <directory suffix=".php">../src/</directory>
</include> </include>
</coverage> </source>
<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>
<listeners>
<listener class="\Mockery\Adapter\Phpunit\TestListener" />
</listeners>
</phpunit> </phpunit>

View File

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

View File

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

View File

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

View File

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

View File

@ -13,13 +13,13 @@ use Illuminate\Database\Schema\Builder;
return [ return [
'up' => function (Builder $schema) { 'up' => function (Builder $schema) {
$schema->table('flags', function (Blueprint $table) { $schema->table('flags', function (Blueprint $table) {
$table->text('reason_detail')->change(); $table->text('reason_detail')->nullable()->change();
}); });
}, },
'down' => function (Builder $schema) { 'down' => function (Builder $schema) {
$schema->table('flags', function (Blueprint $table) { $schema->table('flags', function (Blueprint $table) {
$table->string('reason_detail')->change(); $table->string('reason_detail')->nullable()->change();
}); });
} }
]; ];

View File

@ -19,6 +19,7 @@ use Flarum\Testing\integration\TestCase;
use Flarum\User\User; use Flarum\User\User;
use Illuminate\Database\PostgresConnection; use Illuminate\Database\PostgresConnection;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use PHPUnit\Framework\Attributes\Test;
class ListTest extends TestCase class ListTest extends TestCase
{ {
@ -70,9 +71,7 @@ class ListTest extends TestCase
]); ]);
} }
/** #[Test]
* @test
*/
public function admin_can_see_one_flag_per_visible_post() public function admin_can_see_one_flag_per_visible_post()
{ {
$response = $this->send( $response = $this->send(
@ -96,9 +95,7 @@ class ListTest extends TestCase
} }
} }
/** #[Test]
* @test
*/
public function regular_user_sees_own_flags_of_visible_posts() public function regular_user_sees_own_flags_of_visible_posts()
{ {
$response = $this->send( $response = $this->send(
@ -115,9 +112,7 @@ class ListTest extends TestCase
$this->assertEqualsCanonicalizing(['2', '4'], $ids); $this->assertEqualsCanonicalizing(['2', '4'], $ids);
} }
/** #[Test]
* @test
*/
public function mod_can_see_one_flag_per_visible_post() public function mod_can_see_one_flag_per_visible_post()
{ {
$response = $this->send( $response = $this->send(
@ -134,9 +129,7 @@ class ListTest extends TestCase
$this->assertCount(3, $data); $this->assertCount(3, $data);
} }
/** #[Test]
* @test
*/
public function guest_cant_see_flags() public function guest_cant_see_flags()
{ {
$response = $this->send( $response = $this->send(

View File

@ -19,6 +19,7 @@ use Flarum\Testing\integration\TestCase;
use Flarum\User\User; use Flarum\User\User;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use Illuminate\Support\Carbon; use Illuminate\Support\Carbon;
use PHPUnit\Framework\Attributes\Test;
class ListWithTagsTest extends TestCase class ListWithTagsTest extends TestCase
{ {
@ -101,9 +102,7 @@ class ListWithTagsTest extends TestCase
]); ]);
} }
/** #[Test]
* @test
*/
public function admin_can_see_one_flag_per_post() public function admin_can_see_one_flag_per_post()
{ {
$response = $this->send( $response = $this->send(
@ -122,9 +121,7 @@ class ListWithTagsTest extends TestCase
$this->assertCount(7, $data); $this->assertCount(7, $data);
} }
/** #[Test]
* @test
*/
public function regular_user_sees_own_flags() public function regular_user_sees_own_flags()
{ {
$response = $this->send( $response = $this->send(
@ -141,9 +138,7 @@ class ListWithTagsTest extends TestCase
$this->assertEqualsCanonicalizing(['2', '4'], $ids); $this->assertEqualsCanonicalizing(['2', '4'], $ids);
} }
/** #[Test]
* @test
*/
public function mod_can_see_one_flag_per_post() public function mod_can_see_one_flag_per_post()
{ {
$response = $this->send( $response = $this->send(
@ -162,9 +157,7 @@ class ListWithTagsTest extends TestCase
$this->assertCount(5, $data); $this->assertCount(5, $data);
} }
/** #[Test]
* @test
*/
public function guest_cant_see_flags() public function guest_cant_see_flags()
{ {
$response = $this->send( $response = $this->send(

View File

@ -18,6 +18,8 @@ use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase; use Flarum\Testing\integration\TestCase;
use Flarum\User\User; use Flarum\User\User;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
class IncludeFlagsVisibilityTest extends TestCase class IncludeFlagsVisibilityTest extends TestCase
{ {
@ -106,10 +108,8 @@ class IncludeFlagsVisibilityTest extends TestCase
]); ]);
} }
/** #[Test]
* @dataProvider listFlagsIncludesDataProvider #[DataProvider('listFlagsIncludesDataProvider')]
* @test
*/
public function user_sees_where_allowed_with_included_tags(int $actorId, array $expectedIncludes) public function user_sees_where_allowed_with_included_tags(int $actorId, array $expectedIncludes)
{ {
$response = $this->send( $response = $this->send(
@ -137,7 +137,7 @@ class IncludeFlagsVisibilityTest extends TestCase
); );
} }
public function listFlagsIncludesDataProvider(): array public static function listFlagsIncludesDataProvider(): array
{ {
return [ return [
'admin_sees_all' => [1, [1, 2, 3, 4, 5, 6, 7, 8]], 'admin_sees_all' => [1, [1, 2, 3, 4, 5, 6, 7, 8]],

View File

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

View File

@ -1,28 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit <phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
backupGlobals="false" backupGlobals="false"
backupStaticAttributes="false" cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true" colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false" processIsolation="false"
stopOnFailure="false" stopOnFailure="false"
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php" bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
> >
<coverage processUncoveredFiles="true"> <source>
<include> <include>
<directory suffix=".php">../src/</directory> <directory suffix=".php">../src/</directory>
</include> </include>
</coverage> </source>
<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>
<listeners>
<listener class="\Mockery\Adapter\Phpunit\TestListener" />
</listeners>
</phpunit> </phpunit>

View File

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

View File

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

View File

@ -17,6 +17,8 @@ use Flarum\Post\Post;
use Flarum\Testing\integration\RetrievesAuthorizedUsers; use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase; use Flarum\Testing\integration\TestCase;
use Flarum\User\User; use Flarum\User\User;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
class LikePostTest extends TestCase class LikePostTest extends TestCase
@ -60,10 +62,8 @@ class LikePostTest extends TestCase
$this->database()->table('group_permission')->insert(['permission' => 'discussion.likePosts', 'group_id' => 5]); $this->database()->table('group_permission')->insert(['permission' => 'discussion.likePosts', 'group_id' => 5]);
} }
/** #[Test]
* @dataProvider allowedUsersToLike #[DataProvider('allowedUsersToLike')]
* @test
*/
public function can_like_a_post_if_allowed(int $postId, ?int $authenticatedAs, string $message, bool $canLikeOwnPost = null) public function can_like_a_post_if_allowed(int $postId, ?int $authenticatedAs, string $message, bool $canLikeOwnPost = null)
{ {
if (! is_null($canLikeOwnPost)) { if (! is_null($canLikeOwnPost)) {
@ -80,10 +80,8 @@ class LikePostTest extends TestCase
$this->assertNotNull($post->likes->where('id', $authenticatedAs)->first(), $message); $this->assertNotNull($post->likes->where('id', $authenticatedAs)->first(), $message);
} }
/** #[Test]
* @dataProvider unallowedUsersToLike #[DataProvider('unallowedUsersToLike')]
* @test
*/
public function cannot_like_a_post_if_not_allowed(int $postId, ?int $authenticatedAs, string $message, bool $canLikeOwnPost = null) public function cannot_like_a_post_if_not_allowed(int $postId, ?int $authenticatedAs, string $message, bool $canLikeOwnPost = null)
{ {
if (! is_null($canLikeOwnPost)) { if (! is_null($canLikeOwnPost)) {
@ -100,10 +98,8 @@ class LikePostTest extends TestCase
$this->assertNull($post->likes->where('id', $authenticatedAs)->first()); $this->assertNull($post->likes->where('id', $authenticatedAs)->first());
} }
/** #[Test]
* @dataProvider allowedUsersToLike #[DataProvider('allowedUsersToLike')]
* @test
*/
public function can_dislike_a_post_if_liked_and_allowed(int $postId, ?int $authenticatedAs, string $message, bool $canLikeOwnPost = null) public function can_dislike_a_post_if_liked_and_allowed(int $postId, ?int $authenticatedAs, string $message, bool $canLikeOwnPost = null)
{ {
if (! is_null($canLikeOwnPost)) { if (! is_null($canLikeOwnPost)) {
@ -121,7 +117,7 @@ class LikePostTest extends TestCase
$this->assertNull($post->likes->where('id', $authenticatedAs)->first(), $message); $this->assertNull($post->likes->where('id', $authenticatedAs)->first(), $message);
} }
public function allowedUsersToLike(): array public static function allowedUsersToLike(): array
{ {
return [ return [
[1, 1, 'Admin can like any post'], [1, 1, 'Admin can like any post'],
@ -130,7 +126,7 @@ class LikePostTest extends TestCase
]; ];
} }
public function unallowedUsersToLike(): array public static function unallowedUsersToLike(): array
{ {
return [ return [
[1, null, 'Guest cannot like any post'], [1, null, 'Guest cannot like any post'],

View File

@ -18,6 +18,8 @@ use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase; use Flarum\Testing\integration\TestCase;
use Flarum\User\User; use Flarum\User\User;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
class ListPostsTest extends TestCase class ListPostsTest extends TestCase
{ {
@ -72,9 +74,7 @@ class ListPostsTest extends TestCase
]); ]);
} }
/** #[Test]
* @test
*/
public function liked_filter_works() public function liked_filter_works()
{ {
$response = $this->send( $response = $this->send(
@ -95,9 +95,7 @@ class ListPostsTest extends TestCase
], $ids, 'IDs do not match'); ], $ids, 'IDs do not match');
} }
/** #[Test]
* @test
*/
public function liked_filter_works_negated() public function liked_filter_works_negated()
{ {
$response = $this->send( $response = $this->send(
@ -116,7 +114,7 @@ class ListPostsTest extends TestCase
$this->assertEqualsCanonicalizing([1, 103], $ids, 'IDs do not match'); $this->assertEqualsCanonicalizing([1, 103], $ids, 'IDs do not match');
} }
/** @test */ #[Test]
public function likes_relation_returns_limited_results_and_shows_only_visible_posts_in_show_post_endpoint() public function likes_relation_returns_limited_results_and_shows_only_visible_posts_in_show_post_endpoint()
{ {
// List posts endpoint // List posts endpoint
@ -142,7 +140,7 @@ class ListPostsTest extends TestCase
$this->assertEquals([2, 102, 104, 105], Arr::pluck($likes, 'id')); $this->assertEquals([2, 102, 104, 105], Arr::pluck($likes, 'id'));
} }
/** @test */ #[Test]
public function likes_relation_returns_limited_results_and_shows_only_visible_posts_in_list_posts_endpoint() public function likes_relation_returns_limited_results_and_shows_only_visible_posts_in_list_posts_endpoint()
{ {
// List posts endpoint // List posts endpoint
@ -169,10 +167,8 @@ class ListPostsTest extends TestCase
$this->assertEquals([2, 102, 104, 105], Arr::pluck($likes, 'id')); $this->assertEquals([2, 102, 104, 105], Arr::pluck($likes, 'id'));
} }
/** #[Test]
* @dataProvider likesIncludeProvider #[DataProvider('likesIncludeProvider')]
* @test
*/
public function likes_relation_returns_limited_results_and_shows_only_visible_posts_in_show_discussion_endpoint(?string $include) public function likes_relation_returns_limited_results_and_shows_only_visible_posts_in_show_discussion_endpoint(?string $include)
{ {
// Show discussion endpoint // Show discussion endpoint
@ -207,7 +203,7 @@ class ListPostsTest extends TestCase
$this->assertEquals([2, 102, 104, 105], Arr::pluck($likes, 'id'), $body); $this->assertEquals([2, 102, 104, 105], Arr::pluck($likes, 'id'), $body);
} }
public function likesIncludeProvider(): array public static function likesIncludeProvider(): array
{ {
return [ return [
['posts,posts.likes'], ['posts,posts.likes'],

View File

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

View File

@ -1,28 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit <phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
backupGlobals="false" backupGlobals="false"
backupStaticAttributes="false" cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true" colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false" processIsolation="false"
stopOnFailure="false" stopOnFailure="false"
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php" bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
> >
<coverage processUncoveredFiles="true"> <source>
<include> <include>
<directory suffix=".php">../src/</directory> <directory suffix=".php">../src/</directory>
</include> </include>
</coverage> </source>
<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>
<listeners>
<listener class="\Mockery\Adapter\Phpunit\TestListener" />
</listeners>
</phpunit> </phpunit>

View File

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

View File

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

View File

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

View File

@ -17,6 +17,7 @@ use Flarum\Post\Post;
use Flarum\Testing\integration\RetrievesAuthorizedUsers; use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase; use Flarum\Testing\integration\TestCase;
use Flarum\User\User; use Flarum\User\User;
use PHPUnit\Framework\Attributes\Test;
class GroupMentionsTest extends TestCase class GroupMentionsTest extends TestCase
{ {
@ -63,9 +64,7 @@ class GroupMentionsTest extends TestCase
]); ]);
} }
/** #[Test]
* @test
*/
public function rendering_a_valid_group_mention_works() public function rendering_a_valid_group_mention_works()
{ {
$response = $this->send( $response = $this->send(
@ -83,9 +82,7 @@ class GroupMentionsTest extends TestCase
$this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsGroups->find(4)); $this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsGroups->find(4));
} }
/** #[Test]
* @test
*/
public function mentioning_an_invalid_group_doesnt_work() public function mentioning_an_invalid_group_doesnt_work()
{ {
$response = $this->send( $response = $this->send(
@ -114,9 +111,7 @@ class GroupMentionsTest extends TestCase
$this->assertCount(0, CommentPost::find($response['data']['id'])->mentionsGroups); $this->assertCount(0, CommentPost::find($response['data']['id'])->mentionsGroups);
} }
/** #[Test]
* @test
*/
public function deleted_group_mentions_render_with_deleted_label() public function deleted_group_mentions_render_with_deleted_label()
{ {
$deleted_text = $this->app()->getContainer()->make('translator')->trans('flarum-mentions.forum.group_mention.deleted_text'); $deleted_text = $this->app()->getContainer()->make('translator')->trans('flarum-mentions.forum.group_mention.deleted_text');
@ -138,9 +133,7 @@ class GroupMentionsTest extends TestCase
$this->assertCount(0, CommentPost::find($response['data']['id'])->mentionsGroups); $this->assertCount(0, CommentPost::find($response['data']['id'])->mentionsGroups);
} }
/** #[Test]
* @test
*/
public function group_mentions_render_with_fresh_data() public function group_mentions_render_with_fresh_data()
{ {
$response = $this->send( $response = $this->send(
@ -159,9 +152,7 @@ class GroupMentionsTest extends TestCase
$this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsGroups->find(11)); $this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsGroups->find(11));
} }
/** #[Test]
* @test
*/
public function mentioning_a_group_as_an_admin_user_works() public function mentioning_a_group_as_an_admin_user_works()
{ {
$response = $this->send( $response = $this->send(
@ -192,9 +183,7 @@ class GroupMentionsTest extends TestCase
$this->assertCount(1, CommentPost::find($response['data']['id'])->mentionsGroups); $this->assertCount(1, CommentPost::find($response['data']['id'])->mentionsGroups);
} }
/** #[Test]
* @test
*/
public function mentioning_multiple_groups_as_an_admin_user_works() public function mentioning_multiple_groups_as_an_admin_user_works()
{ {
$response = $this->send( $response = $this->send(
@ -227,9 +216,7 @@ class GroupMentionsTest extends TestCase
$this->assertCount(2, CommentPost::find($response['data']['id'])->mentionsGroups); $this->assertCount(2, CommentPost::find($response['data']['id'])->mentionsGroups);
} }
/** #[Test]
* @test
*/
public function mentioning_a_virtual_group_as_an_admin_user_does_not_work() public function mentioning_a_virtual_group_as_an_admin_user_does_not_work()
{ {
$response = $this->send( $response = $this->send(
@ -262,18 +249,14 @@ class GroupMentionsTest extends TestCase
$this->assertCount(0, CommentPost::find($response['data']['id'])->mentionsGroups); $this->assertCount(0, CommentPost::find($response['data']['id'])->mentionsGroups);
} }
/** #[Test]
* @test
*/
public function regular_user_does_not_have_group_mention_permission_by_default() public function regular_user_does_not_have_group_mention_permission_by_default()
{ {
$this->database(); $this->database();
$this->assertFalse(User::find(3)->can('mentionGroups')); $this->assertFalse(User::find(3)->can('mentionGroups'));
} }
/** #[Test]
* @test
*/
public function regular_user_does_have_group_mention_permission_when_added() public function regular_user_does_have_group_mention_permission_when_added()
{ {
$this->prepareDatabase([ $this->prepareDatabase([
@ -286,9 +269,7 @@ class GroupMentionsTest extends TestCase
$this->assertTrue(User::find(3)->can('mentionGroups')); $this->assertTrue(User::find(3)->can('mentionGroups'));
} }
/** #[Test]
* @test
*/
public function user_without_permission_cannot_mention_groups() public function user_without_permission_cannot_mention_groups()
{ {
$response = $this->send( $response = $this->send(
@ -318,9 +299,7 @@ class GroupMentionsTest extends TestCase
$this->assertCount(0, CommentPost::find($response['data']['id'])->mentionsGroups); $this->assertCount(0, CommentPost::find($response['data']['id'])->mentionsGroups);
} }
/** #[Test]
* @test
*/
public function user_with_permission_can_mention_groups() public function user_with_permission_can_mention_groups()
{ {
$response = $this->send( $response = $this->send(
@ -350,9 +329,7 @@ class GroupMentionsTest extends TestCase
$this->assertCount(1, CommentPost::find($response['data']['id'])->mentionsGroups); $this->assertCount(1, CommentPost::find($response['data']['id'])->mentionsGroups);
} }
/** #[Test]
* @test
*/
public function user_with_permission_cannot_mention_hidden_groups() public function user_with_permission_cannot_mention_hidden_groups()
{ {
$response = $this->send( $response = $this->send(
@ -382,9 +359,7 @@ class GroupMentionsTest extends TestCase
$this->assertCount(0, CommentPost::find($response['data']['id'])->mentionsGroups); $this->assertCount(0, CommentPost::find($response['data']['id'])->mentionsGroups);
} }
/** #[Test]
* @test
*/
public function editing_a_post_that_has_a_mention_works() public function editing_a_post_that_has_a_mention_works()
{ {
$response = $this->send( $response = $this->send(

View File

@ -17,6 +17,8 @@ use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase; use Flarum\Testing\integration\TestCase;
use Flarum\User\User; use Flarum\User\User;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
class ListPostsTest extends TestCase class ListPostsTest extends TestCase
{ {
@ -52,9 +54,7 @@ class ListPostsTest extends TestCase
]); ]);
} }
/** #[Test]
* @test
*/
public function mentioned_filter_works() public function mentioned_filter_works()
{ {
$response = $this->send( $response = $this->send(
@ -71,9 +71,7 @@ class ListPostsTest extends TestCase
$this->assertEqualsCanonicalizing(['2', '3'], $ids, 'IDs do not match'); $this->assertEqualsCanonicalizing(['2', '3'], $ids, 'IDs do not match');
} }
/** #[Test]
* @test
*/
public function mentioned_filter_works_negated() public function mentioned_filter_works_negated()
{ {
$response = $this->send( $response = $this->send(
@ -90,9 +88,7 @@ class ListPostsTest extends TestCase
$this->assertEqualsCanonicalizing(['4'], $ids, 'IDs do not match'); $this->assertEqualsCanonicalizing(['4'], $ids, 'IDs do not match');
} }
/** #[Test]
* @test
*/
public function mentioned_filter_works_with_sort() public function mentioned_filter_works_with_sort()
{ {
$response = $this->send( $response = $this->send(
@ -149,7 +145,7 @@ class ListPostsTest extends TestCase
]); ]);
} }
/** @test */ #[Test]
public function mentioned_by_relation_returns_limited_results_and_shows_only_visible_posts_in_show_post_endpoint() public function mentioned_by_relation_returns_limited_results_and_shows_only_visible_posts_in_show_post_endpoint()
{ {
$this->prepareMentionedByData(); $this->prepareMentionedByData();
@ -175,7 +171,7 @@ class ListPostsTest extends TestCase
$this->assertEquals([102, 104, 105, 106], Arr::pluck($mentionedBy, 'id')); $this->assertEquals([102, 104, 105, 106], Arr::pluck($mentionedBy, 'id'));
} }
/** @test */ #[Test]
public function mentioned_by_relation_returns_limited_results_and_shows_only_visible_posts_in_list_posts_endpoint() public function mentioned_by_relation_returns_limited_results_and_shows_only_visible_posts_in_list_posts_endpoint()
{ {
$this->prepareMentionedByData(); $this->prepareMentionedByData();
@ -203,10 +199,8 @@ class ListPostsTest extends TestCase
$this->assertEquals([102, 104, 105, 106], Arr::pluck($mentionedBy, 'id')); $this->assertEquals([102, 104, 105, 106], Arr::pluck($mentionedBy, 'id'));
} }
/** #[Test]
* @dataProvider mentionedByIncludeProvider #[DataProvider('mentionedByIncludeProvider')]
* @test
*/
public function mentioned_by_relation_returns_limited_results_and_shows_only_visible_posts_in_show_discussion_endpoint(?string $include) public function mentioned_by_relation_returns_limited_results_and_shows_only_visible_posts_in_show_discussion_endpoint(?string $include)
{ {
$this->prepareMentionedByData(); $this->prepareMentionedByData();
@ -236,7 +230,7 @@ class ListPostsTest extends TestCase
$this->assertEquals([102, 104, 105, 106], Arr::pluck($mentionedBy, 'id')); $this->assertEquals([102, 104, 105, 106], Arr::pluck($mentionedBy, 'id'));
} }
public function mentionedByIncludeProvider(): array public static function mentionedByIncludeProvider(): array
{ {
return [ return [
['posts,posts.mentionedBy'], ['posts,posts.mentionedBy'],
@ -245,7 +239,7 @@ class ListPostsTest extends TestCase
]; ];
} }
/** @test */ #[Test]
public function mentioned_by_count_only_includes_visible_posts_to_actor() public function mentioned_by_count_only_includes_visible_posts_to_actor()
{ {
$this->prepareMentionedByData(); $this->prepareMentionedByData();
@ -264,7 +258,7 @@ class ListPostsTest extends TestCase
$this->assertEquals(0, $data['attributes']['mentionedByCount']); $this->assertEquals(0, $data['attributes']['mentionedByCount']);
} }
/** @test */ #[Test]
public function mentioned_by_count_works_on_show_endpoint() public function mentioned_by_count_works_on_show_endpoint()
{ {
$this->prepareMentionedByData(); $this->prepareMentionedByData();
@ -283,7 +277,7 @@ class ListPostsTest extends TestCase
$this->assertEquals(10, $data['attributes']['mentionedByCount']); $this->assertEquals(10, $data['attributes']['mentionedByCount']);
} }
/** @test */ #[Test]
public function mentioned_by_count_works_on_list_endpoint() public function mentioned_by_count_works_on_list_endpoint()
{ {
$this->prepareMentionedByData(); $this->prepareMentionedByData();

View File

@ -19,6 +19,7 @@ use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase; use Flarum\Testing\integration\TestCase;
use Flarum\User\DisplayName\DriverInterface; use Flarum\User\DisplayName\DriverInterface;
use Flarum\User\User; use Flarum\User\User;
use PHPUnit\Framework\Attributes\Test;
class PostMentionsTest extends TestCase class PostMentionsTest extends TestCase
{ {
@ -73,9 +74,7 @@ class PostMentionsTest extends TestCase
); );
} }
/** #[Test]
* @test
*/
public function mentioning_a_valid_post_with_old_format_doesnt_work() public function mentioning_a_valid_post_with_old_format_doesnt_work()
{ {
$response = $this->send( $response = $this->send(
@ -107,9 +106,7 @@ class PostMentionsTest extends TestCase
$this->assertNull(CommentPost::find($response['data']['id'])->mentionsPosts->find(4)); $this->assertNull(CommentPost::find($response['data']['id'])->mentionsPosts->find(4));
} }
/** #[Test]
* @test
*/
public function mentioning_a_valid_post_with_new_format_works() public function mentioning_a_valid_post_with_new_format_works()
{ {
$response = $this->send( $response = $this->send(
@ -139,9 +136,7 @@ class PostMentionsTest extends TestCase
$this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsPosts->find(4)); $this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsPosts->find(4));
} }
/** #[Test]
* @test
*/
public function cannot_mention_a_post_without_access() public function cannot_mention_a_post_without_access()
{ {
$response = $this->send( $response = $this->send(
@ -171,9 +166,7 @@ class PostMentionsTest extends TestCase
$this->assertNull(CommentPost::find($response['data']['id'])->mentionsPosts->find(50)); $this->assertNull(CommentPost::find($response['data']['id'])->mentionsPosts->find(50));
} }
/** #[Test]
* @test
*/
public function mentioning_a_valid_post_with_new_format_with_smart_quotes_works_and_falls_back_to_normal_quotes() public function mentioning_a_valid_post_with_new_format_with_smart_quotes_works_and_falls_back_to_normal_quotes()
{ {
$response = $this->send( $response = $this->send(
@ -205,9 +198,7 @@ class PostMentionsTest extends TestCase
$this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsPosts->find(4)); $this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsPosts->find(4));
} }
/** #[Test]
* @test
*/
public function mentioning_an_invalid_post_doesnt_work() public function mentioning_an_invalid_post_doesnt_work()
{ {
$response = $this->send( $response = $this->send(
@ -237,9 +228,7 @@ class PostMentionsTest extends TestCase
$this->assertCount(0, CommentPost::find($response['data']['id'])->mentionsPosts); $this->assertCount(0, CommentPost::find($response['data']['id'])->mentionsPosts);
} }
/** #[Test]
* @test
*/
public function mentioning_multiple_posts_works() public function mentioning_multiple_posts_works()
{ {
$response = $this->send( $response = $this->send(
@ -271,9 +260,7 @@ class PostMentionsTest extends TestCase
$this->assertCount(2, CommentPost::find($response['data']['id'])->mentionsPosts); $this->assertCount(2, CommentPost::find($response['data']['id'])->mentionsPosts);
} }
/** #[Test]
* @test
*/
public function post_mentions_render_with_fresh_data() public function post_mentions_render_with_fresh_data()
{ {
$response = $this->send( $response = $this->send(
@ -291,9 +278,7 @@ class PostMentionsTest extends TestCase
$this->assertCount(1, CommentPost::find($response['data']['id'])->mentionsPosts); $this->assertCount(1, CommentPost::find($response['data']['id'])->mentionsPosts);
} }
/** #[Test]
* @test
*/
public function post_mentions_unparse_with_fresh_data() public function post_mentions_unparse_with_fresh_data()
{ {
$response = $this->send( $response = $this->send(
@ -310,9 +295,7 @@ class PostMentionsTest extends TestCase
$this->assertCount(1, CommentPost::find($response['data']['id'])->mentionsPosts); $this->assertCount(1, CommentPost::find($response['data']['id'])->mentionsPosts);
} }
/** #[Test]
* @test
*/
public function deleted_post_mentions_s_user_unparse_and_render_without_user_data() public function deleted_post_mentions_s_user_unparse_and_render_without_user_data()
{ {
$deleted_text = $this->app()->getContainer()->make('translator')->trans('core.lib.username.deleted_text'); $deleted_text = $this->app()->getContainer()->make('translator')->trans('core.lib.username.deleted_text');
@ -335,9 +318,7 @@ class PostMentionsTest extends TestCase
$this->assertCount(1, CommentPost::find($response['data']['id'])->mentionsPosts); $this->assertCount(1, CommentPost::find($response['data']['id'])->mentionsPosts);
} }
/** #[Test]
* @test
*/
public function deleted_post_mentions_unparse_and_render_without_user_data() public function deleted_post_mentions_unparse_and_render_without_user_data()
{ {
$deleted_text = $this->app()->getContainer()->make('translator')->trans('flarum-mentions.forum.post_mention.deleted_text'); $deleted_text = $this->app()->getContainer()->make('translator')->trans('flarum-mentions.forum.post_mention.deleted_text');
@ -360,9 +341,7 @@ class PostMentionsTest extends TestCase
$this->assertCount(0, CommentPost::find($response['data']['id'])->mentionsPosts); $this->assertCount(0, CommentPost::find($response['data']['id'])->mentionsPosts);
} }
/** #[Test]
* @test
*/
public function deleted_post_mentions_and_deleted_user_unparse_and_render_without_user_data() public function deleted_post_mentions_and_deleted_user_unparse_and_render_without_user_data()
{ {
$deleted_text = $this->app()->getContainer()->make('translator')->trans('flarum-mentions.forum.post_mention.deleted_text'); $deleted_text = $this->app()->getContainer()->make('translator')->trans('flarum-mentions.forum.post_mention.deleted_text');
@ -385,9 +364,7 @@ class PostMentionsTest extends TestCase
$this->assertCount(0, CommentPost::find($response['data']['id'])->mentionsPosts); $this->assertCount(0, CommentPost::find($response['data']['id'])->mentionsPosts);
} }
/** #[Test]
* @test
*/
public function post_mentions_with_unremoved_bad_string_from_display_names_doesnt_work() public function post_mentions_with_unremoved_bad_string_from_display_names_doesnt_work()
{ {
$response = $this->send( $response = $this->send(
@ -417,9 +394,7 @@ class PostMentionsTest extends TestCase
$this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsPosts->find(6)); $this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsPosts->find(6));
} }
/** #[Test]
* @test
*/
public function post_mentions_unparsing_removes_bad_display_name_string() public function post_mentions_unparsing_removes_bad_display_name_string()
{ {
$response = $this->send( $response = $this->send(
@ -438,9 +413,7 @@ class PostMentionsTest extends TestCase
$this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsPosts->find(9)); $this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsPosts->find(9));
} }
/** #[Test]
* @test
*/
public function post_mentions_with_removed_bad_string_from_display_names_works() public function post_mentions_with_removed_bad_string_from_display_names_works()
{ {
$response = $this->send( $response = $this->send(
@ -470,9 +443,7 @@ class PostMentionsTest extends TestCase
$this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsPosts->find(9)); $this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsPosts->find(9));
} }
/** #[Test]
* @test
*/
public function editing_a_post_that_has_a_mention_works() public function editing_a_post_that_has_a_mention_works()
{ {
$response = $this->send( $response = $this->send(
@ -499,9 +470,7 @@ class PostMentionsTest extends TestCase
$this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsPosts->find(9)); $this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsPosts->find(9));
} }
/** #[Test]
* @test
*/
public function editing_a_post_with_deleted_author_that_has_a_mention_works() public function editing_a_post_with_deleted_author_that_has_a_mention_works()
{ {
$response = $this->send( $response = $this->send(
@ -530,9 +499,7 @@ class PostMentionsTest extends TestCase
$this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsPosts->find(9)); $this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsPosts->find(9));
} }
/** #[Test]
* @test
*/
public function editing_a_post_with_a_mention_of_a_post_with_deleted_author_works() public function editing_a_post_with_a_mention_of_a_post_with_deleted_author_works()
{ {
$response = $this->send( $response = $this->send(
@ -559,9 +526,7 @@ class PostMentionsTest extends TestCase
$this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsPosts->find(11)); $this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsPosts->find(11));
} }
/** #[Test]
* @test
*/
public function rendering_post_mention_with_a_post_context_works() public function rendering_post_mention_with_a_post_context_works()
{ {
/** @var Formatter $formatter */ /** @var Formatter $formatter */
@ -576,9 +541,7 @@ class PostMentionsTest extends TestCase
$this->assertStringContainsString('TOBY$', $renderedHtml); $this->assertStringContainsString('TOBY$', $renderedHtml);
} }
/** #[Test]
* @test
*/
public function rendering_post_mention_without_a_context_works() public function rendering_post_mention_without_a_context_works()
{ {
/** @var Formatter $formatter */ /** @var Formatter $formatter */

View File

@ -18,6 +18,7 @@ use Flarum\Tags\Tag;
use Flarum\Testing\integration\RetrievesAuthorizedUsers; use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase; use Flarum\Testing\integration\TestCase;
use Flarum\User\User; use Flarum\User\User;
use PHPUnit\Framework\Attributes\Test;
class TagMentionsTest extends TestCase class TagMentionsTest extends TestCase
{ {
@ -64,7 +65,7 @@ class TagMentionsTest extends TestCase
]); ]);
} }
/** @test */ #[Test]
public function mentioning_a_valid_tag_with_valid_format_works() public function mentioning_a_valid_tag_with_valid_format_works()
{ {
$response = $this->send( $response = $this->send(
@ -93,7 +94,7 @@ class TagMentionsTest extends TestCase
$this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsTags->find(2)); $this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsTags->find(2));
} }
/** @test */ #[Test]
public function mentioning_a_valid_tag_using_cjk_slug_with_valid_format_works() public function mentioning_a_valid_tag_using_cjk_slug_with_valid_format_works()
{ {
$response = $this->send( $response = $this->send(
@ -123,7 +124,7 @@ class TagMentionsTest extends TestCase
$this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsTags->find(6)); $this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsTags->find(6));
} }
/** @test */ #[Test]
public function mentioning_an_invalid_tag_doesnt_work() public function mentioning_an_invalid_tag_doesnt_work()
{ {
$response = $this->send( $response = $this->send(
@ -152,7 +153,7 @@ class TagMentionsTest extends TestCase
$this->assertCount(0, CommentPost::find($response['data']['id'])->mentionsTags); $this->assertCount(0, CommentPost::find($response['data']['id'])->mentionsTags);
} }
/** @test */ #[Test]
public function mentioning_a_tag_when_tags_disabled_does_not_cause_errors() public function mentioning_a_tag_when_tags_disabled_does_not_cause_errors()
{ {
$this->extensions = ['flarum-mentions']; $this->extensions = ['flarum-mentions'];
@ -183,7 +184,7 @@ class TagMentionsTest extends TestCase
$this->assertNull(CommentPost::find($response['data']['id'])->mentionsTags); $this->assertNull(CommentPost::find($response['data']['id'])->mentionsTags);
} }
/** @test */ #[Test]
public function mentioning_a_restricted_tag_doesnt_work_without_privileges() public function mentioning_a_restricted_tag_doesnt_work_without_privileges()
{ {
$response = $this->send( $response = $this->send(
@ -212,7 +213,7 @@ class TagMentionsTest extends TestCase
$this->assertCount(0, CommentPost::find($response['data']['id'])->mentionsTags); $this->assertCount(0, CommentPost::find($response['data']['id'])->mentionsTags);
} }
/** @test */ #[Test]
public function mentioning_a_restricted_tag_works_with_privileges() public function mentioning_a_restricted_tag_works_with_privileges()
{ {
$response = $this->send( $response = $this->send(
@ -241,7 +242,7 @@ class TagMentionsTest extends TestCase
$this->assertCount(1, CommentPost::find($response['data']['id'])->mentionsTags); $this->assertCount(1, CommentPost::find($response['data']['id'])->mentionsTags);
} }
/** @test */ #[Test]
public function mentioning_multiple_tags_works() public function mentioning_multiple_tags_works()
{ {
$response = $this->send( $response = $this->send(
@ -273,7 +274,7 @@ class TagMentionsTest extends TestCase
$this->assertCount(4, CommentPost::find($response['data']['id'])->mentionsTags); $this->assertCount(4, CommentPost::find($response['data']['id'])->mentionsTags);
} }
/** @test */ #[Test]
public function tag_mentions_render_with_fresh_data() public function tag_mentions_render_with_fresh_data()
{ {
$response = $this->send( $response = $this->send(
@ -291,7 +292,7 @@ class TagMentionsTest extends TestCase
$this->assertCount(1, CommentPost::find($response['data']['id'])->mentionsTags); $this->assertCount(1, CommentPost::find($response['data']['id'])->mentionsTags);
} }
/** @test */ #[Test]
public function tag_mentions_dont_cause_errors_when_tags_disabled() public function tag_mentions_dont_cause_errors_when_tags_disabled()
{ {
$this->extensions = ['flarum-mentions']; $this->extensions = ['flarum-mentions'];
@ -305,7 +306,7 @@ class TagMentionsTest extends TestCase
$this->assertEquals(200, $response->getStatusCode()); $this->assertEquals(200, $response->getStatusCode());
} }
/** @test */ #[Test]
public function tag_mentions_unparse_with_fresh_data() public function tag_mentions_unparse_with_fresh_data()
{ {
$response = $this->send( $response = $this->send(
@ -322,7 +323,7 @@ class TagMentionsTest extends TestCase
$this->assertCount(1, CommentPost::find($response['data']['id'])->mentionsTags); $this->assertCount(1, CommentPost::find($response['data']['id'])->mentionsTags);
} }
/** @test */ #[Test]
public function deleted_tag_mentions_unparse_and_render_as_expected() public function deleted_tag_mentions_unparse_and_render_as_expected()
{ {
// No reason to hide a deleted tag's name. // No reason to hide a deleted tag's name.
@ -345,7 +346,7 @@ class TagMentionsTest extends TestCase
$this->assertCount(0, CommentPost::find($response['data']['id'])->mentionsTags); $this->assertCount(0, CommentPost::find($response['data']['id'])->mentionsTags);
} }
/** @test */ #[Test]
public function deleted_tag_mentions_relation_unparse_and_render_as_expected() public function deleted_tag_mentions_relation_unparse_and_render_as_expected()
{ {
// No reason to hide a deleted tag's name. // No reason to hide a deleted tag's name.
@ -368,7 +369,7 @@ class TagMentionsTest extends TestCase
$this->assertCount(0, CommentPost::find($response['data']['id'])->mentionsTags); $this->assertCount(0, CommentPost::find($response['data']['id'])->mentionsTags);
} }
/** @test */ #[Test]
public function editing_a_post_that_has_a_tag_mention_works() public function editing_a_post_that_has_a_tag_mention_works()
{ {
$response = $this->send( $response = $this->send(

View File

@ -18,6 +18,7 @@ use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase; use Flarum\Testing\integration\TestCase;
use Flarum\User\DisplayName\DriverInterface; use Flarum\User\DisplayName\DriverInterface;
use Flarum\User\User; use Flarum\User\User;
use PHPUnit\Framework\Attributes\Test;
class UserMentionsTest extends TestCase class UserMentionsTest extends TestCase
{ {
@ -63,9 +64,7 @@ class UserMentionsTest extends TestCase
); );
} }
/** #[Test]
* @test
*/
public function mentioning_a_valid_user_with_old_format_doesnt_work_if_off() public function mentioning_a_valid_user_with_old_format_doesnt_work_if_off()
{ {
$this->setting('flarum-mentions.allow_username_format', '0'); $this->setting('flarum-mentions.allow_username_format', '0');
@ -97,9 +96,7 @@ class UserMentionsTest extends TestCase
$this->assertCount(0, CommentPost::find($response['data']['id'])->mentionsUsers); $this->assertCount(0, CommentPost::find($response['data']['id'])->mentionsUsers);
} }
/** #[Test]
* @test
*/
public function mentioning_a_valid_user_with_old_format_works_if_on() public function mentioning_a_valid_user_with_old_format_works_if_on()
{ {
$this->setting('flarum-mentions.allow_username_format', '1'); $this->setting('flarum-mentions.allow_username_format', '1');
@ -131,9 +128,7 @@ class UserMentionsTest extends TestCase
$this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsUsers->find(3)); $this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsUsers->find(3));
} }
/** #[Test]
* @test
*/
public function mentioning_a_valid_user_with_new_format_works() public function mentioning_a_valid_user_with_new_format_works()
{ {
$response = $this->send( $response = $this->send(
@ -163,9 +158,7 @@ class UserMentionsTest extends TestCase
$this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsUsers->find(3)); $this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsUsers->find(3));
} }
/** #[Test]
* @test
*/
public function mentioning_a_valid_user_with_new_format_with_smart_quotes_works_and_falls_back_to_normal_quotes() public function mentioning_a_valid_user_with_new_format_with_smart_quotes_works_and_falls_back_to_normal_quotes()
{ {
$response = $this->send( $response = $this->send(
@ -195,9 +188,7 @@ class UserMentionsTest extends TestCase
$this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsUsers->find(3)); $this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsUsers->find(3));
} }
/** #[Test]
* @test
*/
public function mentioning_an_invalid_user_doesnt_work() public function mentioning_an_invalid_user_doesnt_work()
{ {
$response = $this->send( $response = $this->send(
@ -227,9 +218,7 @@ class UserMentionsTest extends TestCase
$this->assertCount(0, CommentPost::find($response['data']['id'])->mentionsUsers); $this->assertCount(0, CommentPost::find($response['data']['id'])->mentionsUsers);
} }
/** #[Test]
* @test
*/
public function mentioning_multiple_users_works() public function mentioning_multiple_users_works()
{ {
$response = $this->send( $response = $this->send(
@ -261,9 +250,7 @@ class UserMentionsTest extends TestCase
$this->assertCount(2, CommentPost::find($response['data']['id'])->mentionsUsers); $this->assertCount(2, CommentPost::find($response['data']['id'])->mentionsUsers);
} }
/** #[Test]
* @test
*/
public function old_user_mentions_still_render() public function old_user_mentions_still_render()
{ {
$response = $this->send( $response = $this->send(
@ -281,9 +268,7 @@ class UserMentionsTest extends TestCase
$this->assertCount(1, CommentPost::find($response['data']['id'])->mentionsUsers); $this->assertCount(1, CommentPost::find($response['data']['id'])->mentionsUsers);
} }
/** #[Test]
* @test
*/
public function user_mentions_render_with_fresh_data() public function user_mentions_render_with_fresh_data()
{ {
$response = $this->send( $response = $this->send(
@ -312,9 +297,7 @@ class UserMentionsTest extends TestCase
$this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsUsers->find(3)); $this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsUsers->find(3));
} }
/** #[Test]
* @test
*/
public function user_mentions_unparse_with_fresh_data() public function user_mentions_unparse_with_fresh_data()
{ {
$response = $this->send( $response = $this->send(
@ -342,9 +325,7 @@ class UserMentionsTest extends TestCase
$this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsUsers->find(3)); $this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsUsers->find(3));
} }
/** #[Test]
* @test
*/
public function deleted_user_mentions_unparse_and_render_without_user_data() public function deleted_user_mentions_unparse_and_render_without_user_data()
{ {
$deleted_text = $this->app()->getContainer()->make('translator')->trans('core.lib.username.deleted_text'); $deleted_text = $this->app()->getContainer()->make('translator')->trans('core.lib.username.deleted_text');
@ -368,9 +349,7 @@ class UserMentionsTest extends TestCase
$this->assertCount(0, CommentPost::find($response['data']['id'])->mentionsUsers); $this->assertCount(0, CommentPost::find($response['data']['id'])->mentionsUsers);
} }
/** #[Test]
* @test
*/
public function user_mentions_with_unremoved_bad_string_from_display_names_doesnt_work() public function user_mentions_with_unremoved_bad_string_from_display_names_doesnt_work()
{ {
$response = $this->send( $response = $this->send(
@ -400,9 +379,7 @@ class UserMentionsTest extends TestCase
$this->assertNull(CommentPost::find($response['data']['id'])->mentionsUsers->find(5)); $this->assertNull(CommentPost::find($response['data']['id'])->mentionsUsers->find(5));
} }
/** #[Test]
* @test
*/
public function user_mentions_unparsing_removes_bad_display_name_string() public function user_mentions_unparsing_removes_bad_display_name_string()
{ {
$response = $this->send( $response = $this->send(
@ -421,9 +398,7 @@ class UserMentionsTest extends TestCase
$this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsUsers->find(5)); $this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsUsers->find(5));
} }
/** #[Test]
* @test
*/
public function user_mentions_with_removed_bad_string_from_display_names_works() public function user_mentions_with_removed_bad_string_from_display_names_works()
{ {
$response = $this->send( $response = $this->send(
@ -453,9 +428,7 @@ class UserMentionsTest extends TestCase
$this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsUsers->find(5)); $this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsUsers->find(5));
} }
/** #[Test]
* @test
*/
public function editing_a_post_that_has_a_mention_works() public function editing_a_post_that_has_a_mention_works()
{ {
$response = $this->send( $response = $this->send(
@ -482,9 +455,7 @@ class UserMentionsTest extends TestCase
$this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsUsers->find(5)); $this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsUsers->find(5));
} }
/** #[Test]
* @test
*/
public function editing_a_post_with_deleted_author_that_has_a_mention_works() public function editing_a_post_with_deleted_author_that_has_a_mention_works()
{ {
$response = $this->send( $response = $this->send(

View File

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

View File

@ -1,28 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit <phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
backupGlobals="false" backupGlobals="false"
backupStaticAttributes="false" cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true" colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false" processIsolation="false"
stopOnFailure="false" stopOnFailure="false"
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php" bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
> >
<coverage processUncoveredFiles="true"> <source>
<include> <include>
<directory suffix=".php">../src/</directory> <directory suffix=".php">../src/</directory>
</include> </include>
</coverage> </source>
<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>
<listeners>
<listener class="\Mockery\Adapter\Phpunit\TestListener" />
</listeners>
</phpunit> </phpunit>

View File

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

View File

@ -14,8 +14,9 @@ use Flarum\Locale\TranslatorInterface;
use Flarum\Testing\integration\RetrievesAuthorizedUsers; use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase; use Flarum\Testing\integration\TestCase;
use Flarum\User\User; use Flarum\User\User;
use PHPUnit\Framework\Attributes\Test;
class UpdateTest extends TestCase class EditUserTest extends TestCase
{ {
use RetrievesAuthorizedUsers; use RetrievesAuthorizedUsers;
@ -34,9 +35,7 @@ class UpdateTest extends TestCase
]); ]);
} }
/** #[Test]
* @test
*/
public function user_cant_edit_own_nickname_if_not_allowed() public function user_cant_edit_own_nickname_if_not_allowed()
{ {
$this->database()->table('group_permission')->where('permission', 'user.editOwnNickname')->where('group_id', Group::MEMBER_ID)->delete(); $this->database()->table('group_permission')->where('permission', 'user.editOwnNickname')->where('group_id', Group::MEMBER_ID)->delete();
@ -58,9 +57,7 @@ class UpdateTest extends TestCase
$this->assertEquals(403, $response->getStatusCode(), $response->getBody()->getContents()); $this->assertEquals(403, $response->getStatusCode(), $response->getBody()->getContents());
} }
/** #[Test]
* @test
*/
public function user_can_edit_own_nickname_if_allowed() public function user_can_edit_own_nickname_if_allowed()
{ {
$this->prepareDatabase([ $this->prepareDatabase([
@ -88,9 +85,7 @@ class UpdateTest extends TestCase
$this->assertEquals('new nickname', User::find(2)->nickname); $this->assertEquals('new nickname', User::find(2)->nickname);
} }
/** #[Test]
* @test
*/
public function cant_edit_nickname_if_invalid_regex() public function cant_edit_nickname_if_invalid_regex()
{ {
$this->setting('flarum-nicknames.set_on_registration', true); $this->setting('flarum-nicknames.set_on_registration', true);

View File

@ -12,6 +12,7 @@ namespace Flarum\Nicknames\Tests\integration;
use Flarum\Extend; use Flarum\Extend;
use Flarum\Testing\integration\TestCase; use Flarum\Testing\integration\TestCase;
use Flarum\User\User; use Flarum\User\User;
use PHPUnit\Framework\Attributes\Test;
class RegisterTest extends TestCase class RegisterTest extends TestCase
{ {
@ -26,9 +27,7 @@ class RegisterTest extends TestCase
); );
} }
/** #[Test]
* @test
*/
public function can_register_with_nickname() public function can_register_with_nickname()
{ {
$this->setting('flarum-nicknames.set_on_registration', true); $this->setting('flarum-nicknames.set_on_registration', true);
@ -54,9 +53,7 @@ class RegisterTest extends TestCase
$this->assertEquals('test@machine.local', $user->email); $this->assertEquals('test@machine.local', $user->email);
} }
/** #[Test]
* @test
*/
public function cant_register_with_nickname_if_not_allowed() public function cant_register_with_nickname_if_not_allowed()
{ {
$this->setting('flarum-nicknames.set_on_registration', false); $this->setting('flarum-nicknames.set_on_registration', false);
@ -75,9 +72,7 @@ class RegisterTest extends TestCase
$this->assertEquals(403, $response->getStatusCode(), $response->getBody()->getContents()); $this->assertEquals(403, $response->getStatusCode(), $response->getBody()->getContents());
} }
/** #[Test]
* @test
*/
public function cant_register_with_nickname_if_invalid_regex() public function cant_register_with_nickname_if_invalid_regex()
{ {
$this->setting('flarum-nicknames.set_on_registration', true); $this->setting('flarum-nicknames.set_on_registration', true);
@ -97,9 +92,7 @@ class RegisterTest extends TestCase
$this->assertEquals(422, $response->getStatusCode(), $response->getBody()->getContents()); $this->assertEquals(422, $response->getStatusCode(), $response->getBody()->getContents());
} }
/** #[Test]
* @test
*/
public function can_register_with_nickname_if_valid_regex() public function can_register_with_nickname_if_valid_regex()
{ {
$this->setting('flarum-nicknames.set_on_registration', true); $this->setting('flarum-nicknames.set_on_registration', true);

View File

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

View File

@ -1,28 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit <phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
backupGlobals="false" backupGlobals="false"
backupStaticAttributes="false" cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true" colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false" processIsolation="false"
stopOnFailure="false" stopOnFailure="false"
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php" bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
> >
<coverage processUncoveredFiles="true"> <source>
<include> <include>
<directory suffix=".php">../src/</directory> <directory suffix=".php">../src/</directory>
</include> </include>
</coverage> </source>
<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>
<listeners>
<listener class="\Mockery\Adapter\Phpunit\TestListener" />
</listeners>
</phpunit> </phpunit>

View File

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

View File

@ -13,15 +13,14 @@ use Flarum\ExtensionManager\Tests\integration\ChangeComposerConfig;
use Flarum\ExtensionManager\Tests\integration\RefreshComposerSetup; use Flarum\ExtensionManager\Tests\integration\RefreshComposerSetup;
use Flarum\ExtensionManager\Tests\integration\TestCase; use Flarum\ExtensionManager\Tests\integration\TestCase;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use PHPUnit\Framework\Attributes\Test;
class CheckForUpdatesTest extends TestCase class CheckForUpdatesTest extends TestCase
{ {
use RefreshComposerSetup; use RefreshComposerSetup;
use ChangeComposerConfig; use ChangeComposerConfig;
/** #[Test]
* @test
*/
public function can_check_for_updates() public function can_check_for_updates()
{ {
$this->setComposerConfig([ $this->setComposerConfig([

View File

@ -11,14 +11,13 @@ namespace Flarum\ExtensionManager\Tests\integration\api;
use Flarum\ExtensionManager\Tests\integration\RefreshComposerSetup; use Flarum\ExtensionManager\Tests\integration\RefreshComposerSetup;
use Flarum\ExtensionManager\Tests\integration\TestCase; use Flarum\ExtensionManager\Tests\integration\TestCase;
use PHPUnit\Framework\Attributes\Test;
class GlobalUpdateTest extends TestCase class GlobalUpdateTest extends TestCase
{ {
use RefreshComposerSetup; use RefreshComposerSetup;
/** #[Test]
* @test
*/
public function can_global_update() public function can_global_update()
{ {
$response = $this->send( $response = $this->send(

View File

@ -13,6 +13,7 @@ use Flarum\ExtensionManager\Tests\integration\ChangeComposerConfig;
use Flarum\ExtensionManager\Tests\integration\DummyExtensions; use Flarum\ExtensionManager\Tests\integration\DummyExtensions;
use Flarum\ExtensionManager\Tests\integration\RefreshComposerSetup; use Flarum\ExtensionManager\Tests\integration\RefreshComposerSetup;
use Flarum\ExtensionManager\Tests\integration\TestCase; use Flarum\ExtensionManager\Tests\integration\TestCase;
use PHPUnit\Framework\Attributes\Test;
class MajorUpdateTest extends TestCase class MajorUpdateTest extends TestCase
{ {
@ -20,9 +21,7 @@ class MajorUpdateTest extends TestCase
use ChangeComposerConfig; use ChangeComposerConfig;
use DummyExtensions; use DummyExtensions;
/** #[Test]
* @test
*/
public function cannot_update_when_no_update_check_ran() public function cannot_update_when_no_update_check_ran()
{ {
$this->makeDummyExtensionCompatibleWith('flarum/dummy-incompatible-extension', '>=0.1.0-beta.15 <=0.1.0-beta.16'); $this->makeDummyExtensionCompatibleWith('flarum/dummy-incompatible-extension', '>=0.1.0-beta.15 <=0.1.0-beta.16');
@ -45,9 +44,7 @@ class MajorUpdateTest extends TestCase
$this->assertEquals('no_new_major_version', $this->errorDetails($response)['code']); $this->assertEquals('no_new_major_version', $this->errorDetails($response)['code']);
} }
/** #[Test]
* @test
*/
public function can_update_when_major_update_available() public function can_update_when_major_update_available()
{ {
$this->makeDummyExtensionCompatibleWith('flarum/dummy-compatible-extension', '^0.1.0-beta.15 | ^1.0.0'); $this->makeDummyExtensionCompatibleWith('flarum/dummy-compatible-extension', '^0.1.0-beta.15 | ^1.0.0');
@ -87,9 +84,7 @@ class MajorUpdateTest extends TestCase
$this->assertPackageVersion('flarum/dummy-compatible-extension', '*'); $this->assertPackageVersion('flarum/dummy-compatible-extension', '*');
} }
/** #[Test]
* @test
*/
public function cannot_update_with_incompatible_extensions() public function cannot_update_with_incompatible_extensions()
{ {
$this->makeDummyExtensionCompatibleWith('flarum/dummy-incompatible-extension-a', '>=0.1.0-beta.16 <0.1.0-beta.17'); $this->makeDummyExtensionCompatibleWith('flarum/dummy-incompatible-extension-a', '>=0.1.0-beta.16 <0.1.0-beta.17');

View File

@ -15,6 +15,7 @@ use Flarum\ExtensionManager\Tests\integration\ChangeComposerConfig;
use Flarum\ExtensionManager\Tests\integration\DummyExtensions; use Flarum\ExtensionManager\Tests\integration\DummyExtensions;
use Flarum\ExtensionManager\Tests\integration\RefreshComposerSetup; use Flarum\ExtensionManager\Tests\integration\RefreshComposerSetup;
use Flarum\ExtensionManager\Tests\integration\TestCase; use Flarum\ExtensionManager\Tests\integration\TestCase;
use PHPUnit\Framework\Attributes\Test;
class MinorUpdateTest extends TestCase class MinorUpdateTest extends TestCase
{ {
@ -22,9 +23,7 @@ class MinorUpdateTest extends TestCase
use ChangeComposerConfig; use ChangeComposerConfig;
use DummyExtensions; use DummyExtensions;
/** #[Test]
* @test
*/
public function can_update_to_next_minor_version() public function can_update_to_next_minor_version()
{ {
$this->makeDummyExtensionCompatibleWith('flarum/dummy-compatible-extension', '^1.0.0'); $this->makeDummyExtensionCompatibleWith('flarum/dummy-compatible-extension', '^1.0.0');
@ -53,9 +52,7 @@ class MinorUpdateTest extends TestCase
$this->assertPackageVersion('flarum/dummy-compatible-extension', '*'); $this->assertPackageVersion('flarum/dummy-compatible-extension', '*');
} }
/** #[Test]
* @test
*/
public function can_update_with_latest_ext_incompatible_with_latest_core() public function can_update_with_latest_ext_incompatible_with_latest_core()
{ {
$this->makeDummyExtensionCompatibleWith('flarum/dummy-extension', '1.0.0'); $this->makeDummyExtensionCompatibleWith('flarum/dummy-extension', '1.0.0');

View File

@ -11,22 +11,19 @@ namespace Flarum\ExtensionManager\Tests\integration\api\extensions;
use Flarum\ExtensionManager\Tests\integration\RefreshComposerSetup; use Flarum\ExtensionManager\Tests\integration\RefreshComposerSetup;
use Flarum\ExtensionManager\Tests\integration\TestCase; use Flarum\ExtensionManager\Tests\integration\TestCase;
use PHPUnit\Framework\Attributes\Test;
class RemoveExtensionTest extends TestCase class RemoveExtensionTest extends TestCase
{ {
use RefreshComposerSetup; use RefreshComposerSetup;
/** #[Test]
* @test
*/
public function extension_installed_by_default() public function extension_installed_by_default()
{ {
$this->assertExtensionExists('flarum-tags'); $this->assertExtensionExists('flarum-tags');
} }
/** #[Test]
* @test
*/
public function removing_an_extension_works() public function removing_an_extension_works()
{ {
$response = $this->send( $response = $this->send(
@ -39,9 +36,7 @@ class RemoveExtensionTest extends TestCase
$this->assertExtensionNotExists('flarum-tags'); $this->assertExtensionNotExists('flarum-tags');
} }
/** #[Test]
* @test
*/
public function removing_a_non_existant_extension_fails() public function removing_a_non_existant_extension_fails()
{ {
$response = $this->send( $response = $this->send(

View File

@ -11,22 +11,19 @@ namespace Flarum\ExtensionManager\Tests\integration\api\extensions;
use Flarum\ExtensionManager\Tests\integration\RefreshComposerSetup; use Flarum\ExtensionManager\Tests\integration\RefreshComposerSetup;
use Flarum\ExtensionManager\Tests\integration\TestCase; use Flarum\ExtensionManager\Tests\integration\TestCase;
use PHPUnit\Framework\Attributes\Test;
class RequireExtensionTest extends TestCase class RequireExtensionTest extends TestCase
{ {
use RefreshComposerSetup; use RefreshComposerSetup;
/** #[Test]
* @test
*/
public function extension_uninstalled_by_default() public function extension_uninstalled_by_default()
{ {
$this->assertExtensionNotExists('v17development-blog'); $this->assertExtensionNotExists('v17development-blog');
} }
/** #[Test]
* @test
*/
public function requiring_an_existing_extension_fails() public function requiring_an_existing_extension_fails()
{ {
$response = $this->send( $response = $this->send(
@ -43,9 +40,7 @@ class RequireExtensionTest extends TestCase
$this->assertEquals(409, $response->getStatusCode()); $this->assertEquals(409, $response->getStatusCode());
} }
/** #[Test]
* @test
*/
public function requiring_a_compatible_extension_works() public function requiring_a_compatible_extension_works()
{ {
$response = $this->send( $response = $this->send(
@ -63,9 +58,7 @@ class RequireExtensionTest extends TestCase
$this->assertExtensionExists('v17development-blog'); $this->assertExtensionExists('v17development-blog');
} }
/** #[Test]
* @test
*/
public function requiring_a_compatible_extension_with_specific_version_works() public function requiring_a_compatible_extension_with_specific_version_works()
{ {
$response = $this->send( $response = $this->send(
@ -83,9 +76,7 @@ class RequireExtensionTest extends TestCase
$this->assertExtensionExists('v17development-blog'); $this->assertExtensionExists('v17development-blog');
} }
/** #[Test]
* @test
*/
public function requiring_an_uncompatible_extension_fails() public function requiring_an_uncompatible_extension_fails()
{ {
$response = $this->send( $response = $this->send(
@ -103,9 +94,7 @@ class RequireExtensionTest extends TestCase
$this->assertEquals('extension_incompatible_with_instance', $this->errorDetails($response)['guessed_cause']); $this->assertEquals('extension_incompatible_with_instance', $this->errorDetails($response)['guessed_cause']);
} }
/** #[Test]
* @test
*/
public function requiring_an_uncompatible_extension_with_specific_version_fails() public function requiring_an_uncompatible_extension_with_specific_version_fails()
{ {
$response = $this->send( $response = $this->send(

View File

@ -11,22 +11,19 @@ namespace Flarum\ExtensionManager\Tests\integration\api\extensions;
use Flarum\ExtensionManager\Tests\integration\RefreshComposerSetup; use Flarum\ExtensionManager\Tests\integration\RefreshComposerSetup;
use Flarum\ExtensionManager\Tests\integration\TestCase; use Flarum\ExtensionManager\Tests\integration\TestCase;
use PHPUnit\Framework\Attributes\Test;
class UpdateExtensionTest extends TestCase class UpdateExtensionTest extends TestCase
{ {
use RefreshComposerSetup; use RefreshComposerSetup;
/** #[Test]
* @test
*/
public function extension_installed_by_default() public function extension_installed_by_default()
{ {
$this->assertExtensionExists('flarum-tags'); $this->assertExtensionExists('flarum-tags');
} }
/** #[Test]
* @test
*/
public function updating_an_existing_extension_works() public function updating_an_existing_extension_works()
{ {
$response = $this->send( $response = $this->send(
@ -39,9 +36,7 @@ class UpdateExtensionTest extends TestCase
$this->assertExtensionExists('flarum-tags'); $this->assertExtensionExists('flarum-tags');
} }
/** #[Test]
* @test
*/
public function updating_a_non_existing_extension_fails() public function updating_a_non_existing_extension_fails()
{ {
$response = $this->send( $response = $this->send(

View File

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

View File

@ -1,27 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit <phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
backupGlobals="false" backupGlobals="false"
backupStaticAttributes="false" cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true" colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false" processIsolation="false"
stopOnFailure="false" stopOnFailure="false"
> >
<coverage processUncoveredFiles="true"> <source>
<include> <include>
<directory suffix=".php">../src/</directory> <directory suffix=".php">../src/</directory>
</include> </include>
</coverage> </source>
<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>
<listeners>
<listener class="\Mockery\Adapter\Phpunit\TestListener" />
</listeners>
</phpunit> </phpunit>

View File

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

View File

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

View File

@ -15,6 +15,7 @@ use Flarum\Post\Post;
use Flarum\Testing\integration\RetrievesAuthorizedUsers; use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase; use Flarum\Testing\integration\TestCase;
use Flarum\User\User; use Flarum\User\User;
use PHPUnit\Framework\Attributes\Test;
class CanRequestCustomTimedStatisticsTest extends TestCase class CanRequestCustomTimedStatisticsTest extends TestCase
{ {
@ -60,9 +61,7 @@ class CanRequestCustomTimedStatisticsTest extends TestCase
]; ];
} }
/** #[Test]
* @test
*/
public function can_request_timed_stats() public function can_request_timed_stats()
{ {
$time = $this->nowTime->copy(); $time = $this->nowTime->copy();

View File

@ -15,6 +15,7 @@ use Flarum\Post\Post;
use Flarum\Testing\integration\RetrievesAuthorizedUsers; use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase; use Flarum\Testing\integration\TestCase;
use Flarum\User\User; use Flarum\User\User;
use PHPUnit\Framework\Attributes\Test;
class CanRequestLifetimeStatisticsTest extends TestCase class CanRequestLifetimeStatisticsTest extends TestCase
{ {
@ -59,9 +60,7 @@ class CanRequestLifetimeStatisticsTest extends TestCase
]; ];
} }
/** #[Test]
* @test
*/
public function can_request_lifetime_stats() public function can_request_lifetime_stats()
{ {
$response = $this->send( $response = $this->send(

View File

@ -15,6 +15,7 @@ use Flarum\Post\Post;
use Flarum\Testing\integration\RetrievesAuthorizedUsers; use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase; use Flarum\Testing\integration\TestCase;
use Flarum\User\User; use Flarum\User\User;
use PHPUnit\Framework\Attributes\Test;
class CanRequestTimedStatisticsTest extends TestCase class CanRequestTimedStatisticsTest extends TestCase
{ {
@ -59,9 +60,7 @@ class CanRequestTimedStatisticsTest extends TestCase
]; ];
} }
/** #[Test]
* @test
*/
public function can_request_timed_stats() public function can_request_timed_stats()
{ {
$time = $this->nowTime->copy(); $time = $this->nowTime->copy();

View File

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

View File

@ -1,28 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit <phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
backupGlobals="false" backupGlobals="false"
backupStaticAttributes="false" cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true" colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false" processIsolation="false"
stopOnFailure="false" stopOnFailure="false"
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php" bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
> >
<coverage processUncoveredFiles="true"> <source>
<include> <include>
<directory suffix=".php">../src/</directory> <directory suffix=".php">../src/</directory>
</include> </include>
</coverage> </source>
<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>
<listeners>
<listener class="\Mockery\Adapter\Phpunit\TestListener" />
</listeners>
</phpunit> </phpunit>

View File

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

View File

@ -16,6 +16,7 @@ use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase; use Flarum\Testing\integration\TestCase;
use Flarum\User\User; use Flarum\User\User;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use PHPUnit\Framework\Attributes\Test;
class ListDiscussionsTest extends TestCase class ListDiscussionsTest extends TestCase
{ {
@ -55,7 +56,7 @@ class ListDiscussionsTest extends TestCase
]); ]);
} }
/** @test */ #[Test]
public function list_discussions_shows_sticky_first_as_guest() public function list_discussions_shows_sticky_first_as_guest()
{ {
$response = $this->send( $response = $this->send(
@ -71,7 +72,7 @@ class ListDiscussionsTest extends TestCase
$this->assertEquals([3, 1, 2, 4], Arr::pluck($data['data'], 'id')); $this->assertEquals([3, 1, 2, 4], Arr::pluck($data['data'], 'id'));
} }
/** @test */ #[Test]
public function list_discussions_shows_sticky_unread_first_as_user() public function list_discussions_shows_sticky_unread_first_as_user()
{ {
$response = $this->send( $response = $this->send(
@ -87,7 +88,7 @@ class ListDiscussionsTest extends TestCase
$this->assertEqualsCanonicalizing([3, 1, 2, 4], Arr::pluck($data['data'], 'id')); $this->assertEqualsCanonicalizing([3, 1, 2, 4], Arr::pluck($data['data'], 'id'));
} }
/** @test */ #[Test]
public function list_discussions_shows_normal_order_when_all_read_as_user() public function list_discussions_shows_normal_order_when_all_read_as_user()
{ {
$response = $this->send( $response = $this->send(
@ -103,7 +104,7 @@ class ListDiscussionsTest extends TestCase
$this->assertEqualsCanonicalizing([2, 4, 3, 1], Arr::pluck($data['data'], 'id')); $this->assertEqualsCanonicalizing([2, 4, 3, 1], Arr::pluck($data['data'], 'id'));
} }
/** @test */ #[Test]
public function list_discussions_shows_stick_first_on_a_tag() public function list_discussions_shows_stick_first_on_a_tag()
{ {
$response = $this->send( $response = $this->send(

View File

@ -16,6 +16,8 @@ use Flarum\Post\Post;
use Flarum\Testing\integration\RetrievesAuthorizedUsers; use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase; use Flarum\Testing\integration\TestCase;
use Flarum\User\User; use Flarum\User\User;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
class StickyDiscussionsTest extends TestCase class StickyDiscussionsTest extends TestCase
{ {
@ -57,10 +59,8 @@ class StickyDiscussionsTest extends TestCase
]); ]);
} }
/** #[Test]
* @dataProvider stickyDataProvider #[DataProvider('stickyDataProvider')]
* @test
*/
public function can_sticky_if_allowed(int $actorId, bool $allowed, bool $sticky) public function can_sticky_if_allowed(int $actorId, bool $allowed, bool $sticky)
{ {
$response = $this->send( $response = $this->send(

View File

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

View File

@ -1,28 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit <phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
backupGlobals="false" backupGlobals="false"
backupStaticAttributes="false" cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true" colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false" processIsolation="false"
stopOnFailure="false" stopOnFailure="false"
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php" bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
> >
<coverage processUncoveredFiles="true"> <source>
<include> <include>
<directory suffix=".php">../src/</directory> <directory suffix=".php">../src/</directory>
</include> </include>
</coverage> </source>
<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>
<listeners>
<listener class="\Mockery\Adapter\Phpunit\TestListener" />
</listeners>
</phpunit> </phpunit>

View File

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

View File

@ -17,6 +17,8 @@ use Flarum\Post\Post;
use Flarum\Testing\integration\RetrievesAuthorizedUsers; use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase; use Flarum\Testing\integration\TestCase;
use Flarum\User\User; use Flarum\User\User;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
class ReplyNotificationTest extends TestCase class ReplyNotificationTest extends TestCase
{ {
@ -62,10 +64,8 @@ class ReplyNotificationTest extends TestCase
]); ]);
} }
/** #[Test]
* @dataProvider replyingSendsNotificationsDataProvider #[DataProvider('replyingSendsNotificationsDataProvider')]
* @test
*/
public function replying_to_a_discussion_with_comment_post_as_last_post_sends_reply_notification(int $userId, int $discussionId, int $newNotificationCount) public function replying_to_a_discussion_with_comment_post_as_last_post_sends_reply_notification(int $userId, int $discussionId, int $newNotificationCount)
{ {
$this->app(); $this->app();
@ -96,7 +96,7 @@ class ReplyNotificationTest extends TestCase
$this->assertEquals($newNotificationCount, $mainUser->getUnreadNotificationCount()); $this->assertEquals($newNotificationCount, $mainUser->getUnreadNotificationCount());
} }
public function replyingSendsNotificationsDataProvider(): array public static function replyingSendsNotificationsDataProvider(): array
{ {
return [ return [
'admin receives a notification when another replies to a discussion they are following and caught up to' => [1, 1, 1], 'admin receives a notification when another replies to a discussion they are following and caught up to' => [1, 1, 1],
@ -106,7 +106,7 @@ class ReplyNotificationTest extends TestCase
]; ];
} }
/** @test */ #[Test]
public function replying_to_a_discussion_with_event_post_as_last_post_sends_reply_notification() public function replying_to_a_discussion_with_event_post_as_last_post_sends_reply_notification()
{ {
$this->app(); $this->app();
@ -166,10 +166,8 @@ class ReplyNotificationTest extends TestCase
$this->assertEquals(1, $mainUser->getUnreadNotificationCount()); $this->assertEquals(1, $mainUser->getUnreadNotificationCount());
} }
/** #[Test]
* @dataProvider deleteLastPostsProvider #[DataProvider('deleteLastPostsProvider')]
* @test
*/
public function deleting_last_posts_then_posting_new_one_sends_reply_notification(array $postIds) public function deleting_last_posts_then_posting_new_one_sends_reply_notification(array $postIds)
{ {
$this->prepareDatabase([ $this->prepareDatabase([
@ -222,7 +220,7 @@ class ReplyNotificationTest extends TestCase
$this->assertEquals(1, $mainUser->getUnreadNotificationCount()); $this->assertEquals(1, $mainUser->getUnreadNotificationCount());
} }
public function deleteLastPostsProvider(): array public static function deleteLastPostsProvider(): array
{ {
return [ return [
[[10, 9, 8]], [[10, 9, 8]],
@ -230,7 +228,7 @@ class ReplyNotificationTest extends TestCase
]; ];
} }
/** @test */ #[Test]
public function approving_reply_sends_reply_notification() public function approving_reply_sends_reply_notification()
{ {
// Flags was only specified because it is required for approval. // Flags was only specified because it is required for approval.
@ -288,7 +286,7 @@ class ReplyNotificationTest extends TestCase
$this->assertEquals(1, $mainUser->getUnreadNotificationCount()); $this->assertEquals(1, $mainUser->getUnreadNotificationCount());
} }
/** @test */ #[Test]
public function replying_to_a_discussion_with_a_restricted_post_only_sends_notifications_to_allowed_users() public function replying_to_a_discussion_with_a_restricted_post_only_sends_notifications_to_allowed_users()
{ {
// Add visibility scoper to only allow admin // Add visibility scoper to only allow admin

View File

@ -15,6 +15,8 @@ use Flarum\Post\Post;
use Flarum\Testing\integration\RetrievesAuthorizedUsers; use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase; use Flarum\Testing\integration\TestCase;
use Flarum\User\User; use Flarum\User\User;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
class SubscribeTest extends TestCase class SubscribeTest extends TestCase
{ {
@ -60,10 +62,8 @@ class SubscribeTest extends TestCase
]); ]);
} }
/** #[Test]
* @test #[DataProvider('provideStates')]
* @dataProvider provideStates
*/
public function can_subscribe_to_a_discussion(int $actorId, int $discussionId, ?string $newState) public function can_subscribe_to_a_discussion(int $actorId, int $discussionId, ?string $newState)
{ {
$this->app(); $this->app();

View File

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

View File

@ -1,28 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit <phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
backupGlobals="false" backupGlobals="false"
backupStaticAttributes="false" cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true" colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false" processIsolation="false"
stopOnFailure="false" stopOnFailure="false"
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php" bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
> >
<coverage processUncoveredFiles="true"> <source>
<include> <include>
<directory suffix=".php">../src/</directory> <directory suffix=".php">../src/</directory>
</include> </include>
</coverage> </source>
<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>
<listeners>
<listener class="\Mockery\Adapter\Phpunit\TestListener" />
</listeners>
</phpunit> </phpunit>

View File

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

View File

@ -15,6 +15,7 @@ use Flarum\Post\Post;
use Flarum\Testing\integration\RetrievesAuthorizedUsers; use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase; use Flarum\Testing\integration\TestCase;
use Flarum\User\User; use Flarum\User\User;
use PHPUnit\Framework\Attributes\Test;
class UseForumTest extends TestCase class UseForumTest extends TestCase
{ {
@ -40,7 +41,7 @@ class UseForumTest extends TestCase
]); ]);
} }
/** @test */ #[Test]
public function suspended_user_cannot_create_discussions() public function suspended_user_cannot_create_discussions()
{ {
$response = $this->send( $response = $this->send(
@ -61,7 +62,7 @@ class UseForumTest extends TestCase
$this->assertEquals(403, $response->getStatusCode()); $this->assertEquals(403, $response->getStatusCode());
} }
/** @test */ #[Test]
public function suspended_user_cannot_reply_to_discussions() public function suspended_user_cannot_reply_to_discussions()
{ {
$response = $this->send( $response = $this->send(

View File

@ -14,6 +14,7 @@ use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase; use Flarum\Testing\integration\TestCase;
use Flarum\User\User; use Flarum\User\User;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use PHPUnit\Framework\Attributes\Test;
class ListUsersTest extends TestCase class ListUsersTest extends TestCase
{ {
@ -55,7 +56,7 @@ class ListUsersTest extends TestCase
$this->assertEqualsCanonicalizing([1, 2, 3, 4, 5, 6], Arr::pluck($body['data'], 'id')); $this->assertEqualsCanonicalizing([1, 2, 3, 4, 5, 6], Arr::pluck($body['data'], 'id'));
} }
/** @test */ #[Test]
public function can_filter_users_by_suspension() public function can_filter_users_by_suspension()
{ {
$response = $this->send( $response = $this->send(

View File

@ -14,6 +14,8 @@ use Flarum\Group\Group;
use Flarum\Testing\integration\RetrievesAuthorizedUsers; use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase; use Flarum\Testing\integration\TestCase;
use Flarum\User\User; use Flarum\User\User;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
class SuspendUserTest extends TestCase class SuspendUserTest extends TestCase
@ -44,10 +46,8 @@ class SuspendUserTest extends TestCase
]); ]);
} }
/** #[Test]
* @dataProvider allowedToSuspendUser #[DataProvider('allowedToSuspendUser')]
* @test
*/
public function can_suspend_user_if_allowed(?int $authenticatedAs, int $targetUserId, string $message) public function can_suspend_user_if_allowed(?int $authenticatedAs, int $targetUserId, string $message)
{ {
$response = $this->sendSuspensionRequest($authenticatedAs, $targetUserId); $response = $this->sendSuspensionRequest($authenticatedAs, $targetUserId);
@ -55,10 +55,8 @@ class SuspendUserTest extends TestCase
$this->assertEquals(200, $response->getStatusCode(), $response->getBody()->getContents()); $this->assertEquals(200, $response->getStatusCode(), $response->getBody()->getContents());
} }
/** #[Test]
* @dataProvider unallowedToSuspendUser #[DataProvider('unallowedToSuspendUser')]
* @test
*/
public function cannot_suspend_user_if_not_allowed(?int $authenticatedAs, int $targetUserId, string $message) public function cannot_suspend_user_if_not_allowed(?int $authenticatedAs, int $targetUserId, string $message)
{ {
$response = $this->sendSuspensionRequest($authenticatedAs, $targetUserId); $response = $this->sendSuspensionRequest($authenticatedAs, $targetUserId);
@ -66,7 +64,7 @@ class SuspendUserTest extends TestCase
$this->assertEquals(403, $response->getStatusCode()); $this->assertEquals(403, $response->getStatusCode());
} }
public function allowedToSuspendUser(): array public static function allowedToSuspendUser(): array
{ {
return [ return [
[1, 2, 'Admin can suspend any user'], [1, 2, 'Admin can suspend any user'],
@ -75,7 +73,7 @@ class SuspendUserTest extends TestCase
]; ];
} }
public function unallowedToSuspendUser(): array public static function unallowedToSuspendUser(): array
{ {
return [ return [
[1, 1, 'Admin cannot suspend self'], [1, 1, 'Admin cannot suspend self'],

View File

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

View File

@ -1,28 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit <phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
backupGlobals="false" backupGlobals="false"
backupStaticAttributes="false" cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true" colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false" processIsolation="false"
stopOnFailure="false" stopOnFailure="false"
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php" bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
> >
<coverage processUncoveredFiles="true"> <source>
<include> <include>
<directory suffix=".php">../src/</directory> <directory suffix=".php">../src/</directory>
</include> </include>
</coverage> </source>
<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>
<listeners>
<listener class="\Mockery\Adapter\Phpunit\TestListener" />
</listeners>
</phpunit> </phpunit>

View File

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

View File

@ -62,7 +62,7 @@ class DiscussionPolicy extends AbstractPolicy
if ( if (
$allowEditTags === '-1' $allowEditTags === '-1'
|| ($allowEditTags === 'reply' && $discussion->participant_count <= 1) || ($allowEditTags === 'reply' && $discussion->participant_count <= 1)
|| (is_numeric($allowEditTags) && $discussion->created_at->diffInMinutes(new Carbon) < $allowEditTags) || (is_numeric($allowEditTags) && $discussion->created_at->diffInMinutes(new Carbon, true) < $allowEditTags)
) { ) {
return $this->allow(); return $this->allow();
} }

View File

@ -15,6 +15,7 @@ use Flarum\Tags\Tests\integration\RetrievesRepresentativeTags;
use Flarum\Testing\integration\RetrievesAuthorizedUsers; use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase; use Flarum\Testing\integration\TestCase;
use Flarum\User\User; use Flarum\User\User;
use PHPUnit\Framework\Attributes\Test;
class CreateTest extends TestCase class CreateTest extends TestCase
{ {
@ -45,9 +46,7 @@ class CreateTest extends TestCase
]); ]);
} }
/** #[Test]
* @test
*/
public function admin_can_create_discussion_without_tags() public function admin_can_create_discussion_without_tags()
{ {
$response = $this->send( $response = $this->send(
@ -68,9 +67,7 @@ class CreateTest extends TestCase
$this->assertEquals(201, $response->getStatusCode()); $this->assertEquals(201, $response->getStatusCode());
} }
/** #[Test]
* @test
*/
public function user_cant_create_discussion_without_tags() public function user_cant_create_discussion_without_tags()
{ {
$response = $this->send( $response = $this->send(
@ -113,9 +110,7 @@ class CreateTest extends TestCase
$this->assertEquals(422, $response->getStatusCode()); $this->assertEquals(422, $response->getStatusCode());
} }
/** #[Test]
* @test
*/
public function user_can_create_discussion_without_tags_if_bypass_permission_granted() public function user_can_create_discussion_without_tags_if_bypass_permission_granted()
{ {
$this->prepareDatabase([ $this->prepareDatabase([
@ -142,9 +137,7 @@ class CreateTest extends TestCase
$this->assertEquals(201, $response->getStatusCode()); $this->assertEquals(201, $response->getStatusCode());
} }
/** #[Test]
* @test
*/
public function user_can_create_discussion_in_primary_tag() public function user_can_create_discussion_in_primary_tag()
{ {
$response = $this->send( $response = $this->send(
@ -172,9 +165,7 @@ class CreateTest extends TestCase
$this->assertEquals(201, $response->getStatusCode(), (string) $response->getBody()); $this->assertEquals(201, $response->getStatusCode(), (string) $response->getBody());
} }
/** #[Test]
* @test
*/
public function user_cant_create_discussion_in_primary_tag_where_can_view_but_cant_start() public function user_cant_create_discussion_in_primary_tag_where_can_view_but_cant_start()
{ {
$response = $this->send( $response = $this->send(
@ -202,9 +193,7 @@ class CreateTest extends TestCase
$this->assertEquals(403, $response->getStatusCode()); $this->assertEquals(403, $response->getStatusCode());
} }
/** #[Test]
* @test
*/
public function user_cant_create_discussion_in_primary_tag_where_can_view_but_cant_start_with_bypass_permission_granted() public function user_cant_create_discussion_in_primary_tag_where_can_view_but_cant_start_with_bypass_permission_granted()
{ {
$this->prepareDatabase([ $this->prepareDatabase([
@ -238,9 +227,7 @@ class CreateTest extends TestCase
$this->assertEquals(403, $response->getStatusCode()); $this->assertEquals(403, $response->getStatusCode());
} }
/** #[Test]
* @test
*/
public function user_can_create_discussion_in_tag_where_can_view_and_can_start() public function user_can_create_discussion_in_tag_where_can_view_and_can_start()
{ {
$response = $this->send( $response = $this->send(
@ -269,9 +256,7 @@ class CreateTest extends TestCase
$this->assertEquals(201, $response->getStatusCode()); $this->assertEquals(201, $response->getStatusCode());
} }
/** #[Test]
* @test
*/
public function user_cant_create_discussion_in_child_tag_without_parent_tag() public function user_cant_create_discussion_in_child_tag_without_parent_tag()
{ {
$response = $this->send( $response = $this->send(
@ -299,9 +284,7 @@ class CreateTest extends TestCase
$this->assertEquals(422, $response->getStatusCode()); $this->assertEquals(422, $response->getStatusCode());
} }
/** #[Test]
* @test
*/
public function user_can_create_discussion_in_child_tag_with_parent_tag() public function user_can_create_discussion_in_child_tag_with_parent_tag()
{ {
$response = $this->send( $response = $this->send(
@ -330,9 +313,7 @@ class CreateTest extends TestCase
$this->assertEquals(201, $response->getStatusCode()); $this->assertEquals(201, $response->getStatusCode());
} }
/** #[Test]
* @test
*/
public function primary_tag_required_by_default() public function primary_tag_required_by_default()
{ {
$response = $this->send( $response = $this->send(

View File

@ -18,6 +18,8 @@ use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase; use Flarum\Testing\integration\TestCase;
use Flarum\User\User; use Flarum\User\User;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
class ListTest extends TestCase class ListTest extends TestCase
{ {
@ -110,9 +112,7 @@ class ListTest extends TestCase
]); ]);
} }
/** #[Test]
* @test
*/
public function admin_sees_all() public function admin_sees_all()
{ {
$response = $this->send( $response = $this->send(
@ -129,9 +129,7 @@ class ListTest extends TestCase
$this->assertEqualsCanonicalizing(['1', '2', '3', '4', '5', '6'], $ids); $this->assertEqualsCanonicalizing(['1', '2', '3', '4', '5', '6'], $ids);
} }
/** #[Test]
* @test
*/
public function user_sees_where_allowed() public function user_sees_where_allowed()
{ {
$response = $this->send( $response = $this->send(
@ -148,9 +146,7 @@ class ListTest extends TestCase
$this->assertEqualsCanonicalizing(['1', '2', '3', '4'], $ids); $this->assertEqualsCanonicalizing(['1', '2', '3', '4'], $ids);
} }
/** #[Test]
* @test
*/
public function guest_can_see_where_allowed() public function guest_can_see_where_allowed()
{ {
$response = $this->send( $response = $this->send(
@ -165,10 +161,8 @@ class ListTest extends TestCase
$this->assertEqualsCanonicalizing(['1', '2'], $ids); $this->assertEqualsCanonicalizing(['1', '2'], $ids);
} }
/** #[Test]
* @dataProvider seeWhereAllowedWhenMoreTagsAreRequiredThanAvailableDataProvider #[DataProvider('seeWhereAllowedWhenMoreTagsAreRequiredThanAvailableDataProvider')]
* @test
*/
public function actor_can_see_where_allowed_when_more_tags_are_required_than_available(string $type, int $actorId, array $expectedDiscussions) public function actor_can_see_where_allowed_when_more_tags_are_required_than_available(string $type, int $actorId, array $expectedDiscussions)
{ {
if ($type === 'secondary') { if ($type === 'secondary') {
@ -201,7 +195,7 @@ class ListTest extends TestCase
$this->assertEqualsCanonicalizing($expectedDiscussions, $ids); $this->assertEqualsCanonicalizing($expectedDiscussions, $ids);
} }
public function seeWhereAllowedWhenMoreTagsAreRequiredThanAvailableDataProvider(): array public static function seeWhereAllowedWhenMoreTagsAreRequiredThanAvailableDataProvider(): array
{ {
return [ return [
// admin_can_see_where_allowed_when_more_primary_tags_are_required_than_available // admin_can_see_where_allowed_when_more_primary_tags_are_required_than_available
@ -219,10 +213,8 @@ class ListTest extends TestCase
]; ];
} }
/** #[Test]
* @dataProvider filterByTagsDataProvider #[DataProvider('filterByTagsDataProvider')]
* @test
*/
public function can_filter_by_authorized_tags(int $authenticatedAs, string $tags, array $expectedDiscussionIds) public function can_filter_by_authorized_tags(int $authenticatedAs, string $tags, array $expectedDiscussionIds)
{ {
$response = $this->send( $response = $this->send(
@ -242,7 +234,7 @@ class ListTest extends TestCase
$this->assertEqualsCanonicalizing($expectedDiscussionIds, array_map('intval', $ids)); $this->assertEqualsCanonicalizing($expectedDiscussionIds, array_map('intval', $ids));
} }
public function filterByTagsDataProvider(): array public static function filterByTagsDataProvider(): array
{ {
return [ return [
// Admin can filter by any tag. // Admin can filter by any tag.

View File

@ -18,6 +18,7 @@ use Flarum\Tags\Tests\integration\RetrievesRepresentativeTags;
use Flarum\Testing\integration\RetrievesAuthorizedUsers; use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase; use Flarum\Testing\integration\TestCase;
use Flarum\User\User; use Flarum\User\User;
use PHPUnit\Framework\Attributes\Test;
class UpdateTest extends TestCase class UpdateTest extends TestCase
{ {
@ -57,9 +58,7 @@ class UpdateTest extends TestCase
]); ]);
} }
/** #[Test]
* @test
*/
public function user_cant_change_tags_without_setting() public function user_cant_change_tags_without_setting()
{ {
$response = $this->send( $response = $this->send(
@ -82,9 +81,7 @@ class UpdateTest extends TestCase
$this->assertEquals(403, $response->getStatusCode()); $this->assertEquals(403, $response->getStatusCode());
} }
/** #[Test]
* @test
*/
public function user_can_change_tags_without_setting() public function user_can_change_tags_without_setting()
{ {
$this->setting('allow_tag_change', '-1'); $this->setting('allow_tag_change', '-1');
@ -109,9 +106,7 @@ class UpdateTest extends TestCase
$this->assertEquals(200, $response->getStatusCode()); $this->assertEquals(200, $response->getStatusCode());
} }
/** #[Test]
* @test
*/
public function admin_can_add_primary_tag_beyond_limit() public function admin_can_add_primary_tag_beyond_limit()
{ {
$response = $this->send( $response = $this->send(
@ -135,9 +130,7 @@ class UpdateTest extends TestCase
$this->assertEquals(200, $response->getStatusCode()); $this->assertEquals(200, $response->getStatusCode());
} }
/** #[Test]
* @test
*/
public function user_cant_add_primary_tag_beyond_limit() public function user_cant_add_primary_tag_beyond_limit()
{ {
$this->setting('allow_tag_change', '-1'); $this->setting('allow_tag_change', '-1');
@ -163,9 +156,7 @@ class UpdateTest extends TestCase
$this->assertEquals(422, $response->getStatusCode()); $this->assertEquals(422, $response->getStatusCode());
} }
/** #[Test]
* @test
*/
public function user_cant_add_tag_where_can_view_but_cant_start() public function user_cant_add_tag_where_can_view_but_cant_start()
{ {
$this->setting('allow_tag_change', '-1'); $this->setting('allow_tag_change', '-1');
@ -190,9 +181,7 @@ class UpdateTest extends TestCase
$this->assertEquals(403, $response->getStatusCode()); $this->assertEquals(403, $response->getStatusCode());
} }
/** #[Test]
* @test
*/
public function user_can_add_tag_where_can_view_and_can_start() public function user_can_add_tag_where_can_view_and_can_start()
{ {
$this->setting('allow_tag_change', '-1'); $this->setting('allow_tag_change', '-1');
@ -218,9 +207,7 @@ class UpdateTest extends TestCase
$this->assertEquals(200, $response->getStatusCode()); $this->assertEquals(200, $response->getStatusCode());
} }
/** #[Test]
* @test
*/
public function user_cant_add_child_tag_without_parent_tag() public function user_cant_add_child_tag_without_parent_tag()
{ {
$this->setting('allow_tag_change', '-1'); $this->setting('allow_tag_change', '-1');
@ -250,9 +237,7 @@ class UpdateTest extends TestCase
$this->assertEquals(403, $response->getStatusCode(), $response->getBody()); $this->assertEquals(403, $response->getStatusCode(), $response->getBody());
} }
/** #[Test]
* @test
*/
public function user_can_add_child_tag_with_parent_tag() public function user_can_add_child_tag_with_parent_tag()
{ {
$this->setting('allow_tag_change', '-1'); $this->setting('allow_tag_change', '-1');
@ -278,9 +263,7 @@ class UpdateTest extends TestCase
$this->assertEquals(200, $response->getStatusCode()); $this->assertEquals(200, $response->getStatusCode());
} }
/** #[Test]
* @test
*/
public function primary_tag_required_by_default() public function primary_tag_required_by_default()
{ {
$this->setting('allow_tag_change', '-1'); $this->setting('allow_tag_change', '-1');

View File

@ -17,6 +17,8 @@ use Flarum\Tags\Tests\integration\RetrievesRepresentativeTags;
use Flarum\Testing\integration\RetrievesAuthorizedUsers; use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase; use Flarum\Testing\integration\TestCase;
use Flarum\User\User; use Flarum\User\User;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
class ListTest extends TestCase class ListTest extends TestCase
{ {
@ -74,10 +76,8 @@ class ListTest extends TestCase
]); ]);
} }
/** #[Test]
* @dataProvider authorizedUsers #[DataProvider('authorizedUsers')]
* @test
*/
public function event_mentioned_tags_are_included_in_response_for_authorized_users(int $userId) public function event_mentioned_tags_are_included_in_response_for_authorized_users(int $userId)
{ {
$response = $this->send( $response = $this->send(
@ -101,10 +101,8 @@ class ListTest extends TestCase
$this->assertEqualsCanonicalizing([1, 5], $tagIds, $body); $this->assertEqualsCanonicalizing([1, 5], $tagIds, $body);
} }
/** #[Test]
* @dataProvider unauthorizedUsers #[DataProvider('unauthorizedUsers')]
* @test
*/
public function event_mentioned_tags_are_not_included_in_response_for_unauthorized_users(?int $userId) public function event_mentioned_tags_are_not_included_in_response_for_unauthorized_users(?int $userId)
{ {
$response = $this->send( $response = $this->send(
@ -126,7 +124,7 @@ class ListTest extends TestCase
$this->assertEqualsCanonicalizing([1], $tagIds); $this->assertEqualsCanonicalizing([1], $tagIds);
} }
public function authorizedUsers() public static function authorizedUsers()
{ {
return [ return [
'admin' => [1], 'admin' => [1],
@ -134,7 +132,7 @@ class ListTest extends TestCase
]; ];
} }
public function unauthorizedUsers() public static function unauthorizedUsers()
{ {
return [ return [
'normal user without permission' => [3], 'normal user without permission' => [3],

View File

@ -14,6 +14,7 @@ use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase; use Flarum\Testing\integration\TestCase;
use Flarum\User\User; use Flarum\User\User;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use PHPUnit\Framework\Attributes\Test;
class CreateTest extends TestCase class CreateTest extends TestCase
{ {
@ -35,9 +36,7 @@ class CreateTest extends TestCase
]); ]);
} }
/** #[Test]
* @test
*/
public function normal_user_cant_create_tag() public function normal_user_cant_create_tag()
{ {
$response = $this->send( $response = $this->send(
@ -51,9 +50,7 @@ class CreateTest extends TestCase
$this->assertEquals(403, $response->getStatusCode()); $this->assertEquals(403, $response->getStatusCode());
} }
/** #[Test]
* @test
*/
public function admin_cannot_create_tag_without_data() public function admin_cannot_create_tag_without_data()
{ {
$response = $this->send( $response = $this->send(
@ -68,9 +65,7 @@ class CreateTest extends TestCase
$this->assertEquals(422, $response->getStatusCode(), (string) $response->getBody()); $this->assertEquals(422, $response->getStatusCode(), (string) $response->getBody());
} }
/** #[Test]
* @test
*/
public function admin_can_create_tag() public function admin_can_create_tag()
{ {
$response = $this->send( $response = $this->send(

View File

@ -16,6 +16,8 @@ use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase; use Flarum\Testing\integration\TestCase;
use Flarum\User\User; use Flarum\User\User;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
class ListTest extends TestCase class ListTest extends TestCase
{ {
@ -43,9 +45,7 @@ class ListTest extends TestCase
]); ]);
} }
/** #[Test]
* @test
*/
public function admin_sees_all() public function admin_sees_all()
{ {
$response = $this->send( $response = $this->send(
@ -62,9 +62,7 @@ class ListTest extends TestCase
$this->assertEquals(['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14'], $ids); $this->assertEquals(['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14'], $ids);
} }
/** #[Test]
* @test
*/
public function user_sees_where_allowed() public function user_sees_where_allowed()
{ {
$response = $this->send( $response = $this->send(
@ -84,10 +82,8 @@ class ListTest extends TestCase
$this->assertEquals(['1', '2', '3', '4', '9', '10', '11'], $ids); $this->assertEquals(['1', '2', '3', '4', '9', '10', '11'], $ids);
} }
/** #[Test]
* @dataProvider listTagsIncludesDataProvider #[DataProvider('listTagsIncludesDataProvider')]
* @test
*/
public function user_sees_where_allowed_with_included_tags(string $include, array $expectedIncludes) public function user_sees_where_allowed_with_included_tags(string $include, array $expectedIncludes)
{ {
$response = $this->send( $response = $this->send(
@ -121,9 +117,7 @@ class ListTest extends TestCase
); );
} }
/** #[Test]
* @test
*/
public function guest_cant_see_restricted_or_children_of_restricted() public function guest_cant_see_restricted_or_children_of_restricted()
{ {
$response = $this->send( $response = $this->send(
@ -138,7 +132,7 @@ class ListTest extends TestCase
$this->assertEquals(['1', '2', '3', '4', '9', '10'], $ids); $this->assertEquals(['1', '2', '3', '4', '9', '10'], $ids);
} }
public function listTagsIncludesDataProvider(): array public static function listTagsIncludesDataProvider(): array
{ {
return [ return [
['children', ['3', '4']], ['children', ['3', '4']],

View File

@ -12,6 +12,8 @@ namespace Flarum\Tags\Tests\integration\api\tags;
use Flarum\Tags\Tag; use Flarum\Tags\Tag;
use Flarum\Testing\integration\TestCase; use Flarum\Testing\integration\TestCase;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
class ListWithFulltextSearchTest extends TestCase class ListWithFulltextSearchTest extends TestCase
{ {
@ -36,10 +38,8 @@ class ListWithFulltextSearchTest extends TestCase
]); ]);
} }
/** #[Test]
* @dataProvider searchDataProvider #[DataProvider('searchDataProvider')]
* @test
*/
public function can_search_for_tags(string $search, array $expected) public function can_search_for_tags(string $search, array $expected)
{ {
$response = $this->send( $response = $this->send(
@ -56,7 +56,7 @@ class ListWithFulltextSearchTest extends TestCase
$this->assertEquals($expected, Arr::pluck($data, 'id')); $this->assertEquals($expected, Arr::pluck($data, 'id'));
} }
public function searchDataProvider(): array public static function searchDataProvider(): array
{ {
return [ return [
['fla', [8]], ['fla', [8]],

View File

@ -16,6 +16,8 @@ use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase; use Flarum\Testing\integration\TestCase;
use Flarum\User\User; use Flarum\User\User;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
class ShowTest extends TestCase class ShowTest extends TestCase
{ {
@ -43,7 +45,7 @@ class ShowTest extends TestCase
]); ]);
} }
/** @test */ #[Test]
public function can_show_tag_with_url_decoded_utf8_slug() public function can_show_tag_with_url_decoded_utf8_slug()
{ {
$this->prepareDatabase([ $this->prepareDatabase([
@ -65,7 +67,7 @@ class ShowTest extends TestCase
$this->assertEquals(200, $response2->getStatusCode()); $this->assertEquals(200, $response2->getStatusCode());
} }
/** @test */ #[Test]
public function can_show_tag_with_url_encoded_utf8_slug() public function can_show_tag_with_url_encoded_utf8_slug()
{ {
$this->prepareDatabase([ $this->prepareDatabase([
@ -87,10 +89,8 @@ class ShowTest extends TestCase
$this->assertEquals(200, $response2->getStatusCode()); $this->assertEquals(200, $response2->getStatusCode());
} }
/** #[Test]
* @dataProvider showTagIncludes #[DataProvider('showTagIncludes')]
* @test
*/
public function user_sees_tag_relations_where_allowed(string $include, array $expectedIncludes) public function user_sees_tag_relations_where_allowed(string $include, array $expectedIncludes)
{ {
$response = $this->send( $response = $this->send(
@ -109,7 +109,7 @@ class ShowTest extends TestCase
$this->assertEqualsCanonicalizing($expectedIncludes, Arr::pluck($included, 'id')); $this->assertEqualsCanonicalizing($expectedIncludes, Arr::pluck($included, 'id'));
} }
public function showTagIncludes(): array public static function showTagIncludes(): array
{ {
return [ return [
['children', []], ['children', []],

View File

@ -15,6 +15,7 @@ use Flarum\Tags\Tests\integration\RetrievesRepresentativeTags;
use Flarum\Testing\integration\RetrievesAuthorizedUsers; use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase; use Flarum\Testing\integration\TestCase;
use Flarum\User\User; use Flarum\User\User;
use PHPUnit\Framework\Attributes\Test;
class GlobalPolicyTest extends TestCase class GlobalPolicyTest extends TestCase
{ {
@ -38,9 +39,7 @@ class GlobalPolicyTest extends TestCase
]); ]);
} }
/** #[Test]
* @test
*/
public function cant_start_discussion_globally_if_permission_not_granted() public function cant_start_discussion_globally_if_permission_not_granted()
{ {
$this->database()->table('group_permission')->where('permission', 'startDiscussion')->delete(); $this->database()->table('group_permission')->where('permission', 'startDiscussion')->delete();
@ -48,9 +47,7 @@ class GlobalPolicyTest extends TestCase
$this->assertFalse(User::find(2)->can('startDiscussion')); $this->assertFalse(User::find(2)->can('startDiscussion'));
} }
/** #[Test]
* @test
*/
public function can_start_discussion_globally_if_allowed_in_primary_tag() public function can_start_discussion_globally_if_allowed_in_primary_tag()
{ {
$this->prepareDatabase([ $this->prepareDatabase([
@ -64,9 +61,7 @@ class GlobalPolicyTest extends TestCase
$this->assertTrue(User::find(2)->can('startDiscussion')); $this->assertTrue(User::find(2)->can('startDiscussion'));
} }
/** #[Test]
* @test
*/
public function cant_start_discussion_globally_if_allowed_in_child_tag_only() public function cant_start_discussion_globally_if_allowed_in_child_tag_only()
{ {
$this->prepareDatabase([ $this->prepareDatabase([
@ -80,9 +75,7 @@ class GlobalPolicyTest extends TestCase
$this->assertFalse(User::find(2)->can('startDiscussion')); $this->assertFalse(User::find(2)->can('startDiscussion'));
} }
/** #[Test]
* @test
*/
public function cant_start_discussion_globally_if_allowed_in_secondary_tag() public function cant_start_discussion_globally_if_allowed_in_secondary_tag()
{ {
$this->prepareDatabase([ $this->prepareDatabase([
@ -96,9 +89,7 @@ class GlobalPolicyTest extends TestCase
$this->assertFalse(User::find(2)->can('startDiscussion')); $this->assertFalse(User::find(2)->can('startDiscussion'));
} }
/** #[Test]
* @test
*/
public function can_start_discussion_globally_if_allowed_in_secondary_tag_and_minimums_adjusted() public function can_start_discussion_globally_if_allowed_in_secondary_tag_and_minimums_adjusted()
{ {
$this->prepareDatabase([ $this->prepareDatabase([
@ -115,9 +106,7 @@ class GlobalPolicyTest extends TestCase
$this->assertTrue(User::find(2)->can('startDiscussion')); $this->assertTrue(User::find(2)->can('startDiscussion'));
} }
/** #[Test]
* @test
*/
public function cant_start_discussion_globally_if_permission_in_insufficient_tags_requires_start_discussion_regardless_of_bypass() public function cant_start_discussion_globally_if_permission_in_insufficient_tags_requires_start_discussion_regardless_of_bypass()
{ {
$this->prepareDatabase([ $this->prepareDatabase([
@ -131,9 +120,7 @@ class GlobalPolicyTest extends TestCase
$this->assertFalse(User::find(2)->can('startDiscussion')); $this->assertFalse(User::find(2)->can('startDiscussion'));
} }
/** #[Test]
* @test
*/
public function can_start_discussion_globally_if_start_discussion_and_bypass_allows_regardless_of_tag_count() public function can_start_discussion_globally_if_start_discussion_and_bypass_allows_regardless_of_tag_count()
{ {
$this->prepareDatabase([ $this->prepareDatabase([
@ -147,9 +134,7 @@ class GlobalPolicyTest extends TestCase
$this->assertTrue(User::find(2)->can('startDiscussion')); $this->assertTrue(User::find(2)->can('startDiscussion'));
} }
/** #[Test]
* @test
*/
public function can_start_discussion_globally_if_sufficient_tags_and_allows_regardless_of_start_discussion_and_bypass() public function can_start_discussion_globally_if_sufficient_tags_and_allows_regardless_of_start_discussion_and_bypass()
{ {
$this->database()->table('group_permission')->where('permission', 'bypassTagCounts')->delete(); $this->database()->table('group_permission')->where('permission', 'bypassTagCounts')->delete();

View File

@ -15,6 +15,7 @@ use Flarum\Tags\Tests\integration\RetrievesRepresentativeTags;
use Flarum\Testing\integration\RetrievesAuthorizedUsers; use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase; use Flarum\Testing\integration\TestCase;
use Flarum\User\User; use Flarum\User\User;
use PHPUnit\Framework\Attributes\Test;
class TagPolicyTest extends TestCase class TagPolicyTest extends TestCase
{ {
@ -42,9 +43,7 @@ class TagPolicyTest extends TestCase
]); ]);
} }
/** #[Test]
* @test
*/
public function has_ability_when_allowed_in_restricted_tag() public function has_ability_when_allowed_in_restricted_tag()
{ {
$this->app(); $this->app();
@ -54,9 +53,7 @@ class TagPolicyTest extends TestCase
$this->assertTrue(User::find(2)->can('arbitraryAbility!', $tag)); $this->assertTrue(User::find(2)->can('arbitraryAbility!', $tag));
} }
/** #[Test]
* @test
*/
public function has_ability_in_child_when_allowed_in_top_tag_and_child() public function has_ability_in_child_when_allowed_in_top_tag_and_child()
{ {
$this->app(); $this->app();
@ -66,9 +63,7 @@ class TagPolicyTest extends TestCase
$this->assertTrue(User::find(2)->can('arbitraryAbility!', $tag)); $this->assertTrue(User::find(2)->can('arbitraryAbility!', $tag));
} }
/** #[Test]
* @test
*/
public function doesnt_have_ability_in_child_when_allowed_in_child_but_not_parent() public function doesnt_have_ability_in_child_when_allowed_in_child_but_not_parent()
{ {
$this->app(); $this->app();
@ -80,9 +75,7 @@ class TagPolicyTest extends TestCase
$this->assertFalse(User::find(2)->can('arbitraryAbility!', $tag)); $this->assertFalse(User::find(2)->can('arbitraryAbility!', $tag));
} }
/** #[Test]
* @test
*/
public function nonrestricted_tag_falls_back_to_global_when_allowed() public function nonrestricted_tag_falls_back_to_global_when_allowed()
{ {
$this->prepareDatabase([ $this->prepareDatabase([
@ -98,9 +91,7 @@ class TagPolicyTest extends TestCase
$this->assertTrue(User::find(2)->can('arbitraryAbility!', $tag)); $this->assertTrue(User::find(2)->can('arbitraryAbility!', $tag));
} }
/** #[Test]
* @test
*/
public function nonrestricted_tag_falls_back_to_global_when_not_allowed() public function nonrestricted_tag_falls_back_to_global_when_not_allowed()
{ {
$this->app(); $this->app();

View File

@ -19,6 +19,7 @@ use Flarum\Testing\integration\TestCase;
use Flarum\User\Guest; use Flarum\User\Guest;
use Flarum\User\User; use Flarum\User\User;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use PHPUnit\Framework\Attributes\Test;
class DiscussionVisibilityTest extends TestCase class DiscussionVisibilityTest extends TestCase
{ {
@ -82,9 +83,7 @@ class DiscussionVisibilityTest extends TestCase
]); ]);
} }
/** #[Test]
* @test
*/
public function admin_sees_all() public function admin_sees_all()
{ {
$this->app(); $this->app();
@ -96,9 +95,7 @@ class DiscussionVisibilityTest extends TestCase
$this->assertEqualsCanonicalizing([1, 2, 3, 4, 5, 6, 7], $ids); $this->assertEqualsCanonicalizing([1, 2, 3, 4, 5, 6, 7], $ids);
} }
/** #[Test]
* @test
*/
public function user_sees_where_allowed() public function user_sees_where_allowed()
{ {
$this->app(); $this->app();
@ -110,9 +107,7 @@ class DiscussionVisibilityTest extends TestCase
$this->assertEqualsCanonicalizing([1, 2, 3, 4, 7], $ids); $this->assertEqualsCanonicalizing([1, 2, 3, 4, 7], $ids);
} }
/** #[Test]
* @test
*/
public function user_sees_only_in_restricted_tags_without_global_perm() public function user_sees_only_in_restricted_tags_without_global_perm()
{ {
$this->database()->table('group_permission')->where('permission', 'arbitraryAbility')->delete(); $this->database()->table('group_permission')->where('permission', 'arbitraryAbility')->delete();
@ -124,9 +119,7 @@ class DiscussionVisibilityTest extends TestCase
$this->assertEqualsCanonicalizing([7], $ids); $this->assertEqualsCanonicalizing([7], $ids);
} }
/** #[Test]
* @test
*/
public function guest_can_see_where_allowed() public function guest_can_see_where_allowed()
{ {
$this->app(); $this->app();
@ -138,9 +131,7 @@ class DiscussionVisibilityTest extends TestCase
$this->assertEqualsCanonicalizing([1, 2], $ids); $this->assertEqualsCanonicalizing([1, 2], $ids);
} }
/** #[Test]
* @test
*/
public function guest_cant_see_without_global_perm() public function guest_cant_see_without_global_perm()
{ {
$this->database()->table('group_permission')->where('permission', 'arbitraryAbility')->delete(); $this->database()->table('group_permission')->where('permission', 'arbitraryAbility')->delete();

View File

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

View File

@ -1,28 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit <phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
backupGlobals="false" backupGlobals="false"
backupStaticAttributes="false" cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true" colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false" processIsolation="false"
stopOnFailure="false" stopOnFailure="false"
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php" bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
> >
<coverage processUncoveredFiles="true"> <source>
<include> <include>
<directory suffix=".php">../src/</directory> <directory suffix=".php">../src/</directory>
</include> </include>
</coverage> </source>
<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>
<listeners>
<listener class="\Mockery\Adapter\Phpunit\TestListener" />
</listeners>
</phpunit> </phpunit>

View File

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

View File

@ -36,7 +36,7 @@
"chat": "https://flarum.org/chat" "chat": "https://flarum.org/chat"
}, },
"require": { "require": {
"php": "^8.1", "php": "^8.2",
"components/font-awesome": "^5.15.0", "components/font-awesome": "^5.15.0",
"dflydev/fig-cookies": "^3.0", "dflydev/fig-cookies": "^3.0",
"doctrine/dbal": "^3.6", "doctrine/dbal": "^3.6",
@ -44,22 +44,22 @@
"fakerphp/faker": "^1.9.1", "fakerphp/faker": "^1.9.1",
"franzl/whoops-middleware": "2.0", "franzl/whoops-middleware": "2.0",
"guzzlehttp/guzzle": "^7.7", "guzzlehttp/guzzle": "^7.7",
"illuminate/bus": "^10.0", "illuminate/bus": "^11.0",
"illuminate/cache": "^10.0", "illuminate/cache": "^11.0",
"illuminate/config": "^10.0", "illuminate/config": "^11.0",
"illuminate/console": "^10.0", "illuminate/console": "^11.0",
"illuminate/container": "^10.0", "illuminate/container": "^11.0",
"illuminate/contracts": "^10.0", "illuminate/contracts": "^11.0",
"illuminate/database": "^10.0", "illuminate/database": "^11.0",
"illuminate/events": "^10.0", "illuminate/events": "^11.0",
"illuminate/filesystem": "^10.0", "illuminate/filesystem": "^11.0",
"illuminate/hashing": "^10.0", "illuminate/hashing": "^11.0",
"illuminate/mail": "^10.0", "illuminate/mail": "^11.0",
"illuminate/queue": "^10.0", "illuminate/queue": "^11.0",
"illuminate/session": "^10.0", "illuminate/session": "^11.0",
"illuminate/support": "^10.0", "illuminate/support": "^11.0",
"illuminate/validation": "^10.0", "illuminate/validation": "^11.0",
"illuminate/view": "^10.0", "illuminate/view": "^11.0",
"intervention/image": "^3.2", "intervention/image": "^3.2",
"jenssegers/agent": "^2.6.4", "jenssegers/agent": "^2.6.4",
"laminas/laminas-diactoros": "^3.0", "laminas/laminas-diactoros": "^3.0",
@ -72,31 +72,30 @@
"middlewares/base-path-router": "^2.0.1", "middlewares/base-path-router": "^2.0.1",
"middlewares/request-handler": "^2.0.2", "middlewares/request-handler": "^2.0.2",
"monolog/monolog": "^3.0", "monolog/monolog": "^3.0",
"nesbot/carbon": "^2.0", "nesbot/carbon": "^3.0",
"nikic/fast-route": "^1.3", "nikic/fast-route": "^1.3",
"psr/http-message": "^1.1", "psr/http-message": "^1.1",
"psr/http-server-handler": "^1.0.2", "psr/http-server-handler": "^1.0.2",
"psr/http-server-middleware": "^1.0.2", "psr/http-server-middleware": "^1.0.2",
"s9e/text-formatter": "^2.13", "s9e/text-formatter": "^2.13",
"staudenmeir/eloquent-eager-limit": "^1.8.2",
"sycho/sourcemap": "^2.0.0", "sycho/sourcemap": "^2.0.0",
"symfony/config": "^6.3", "symfony/config": "^7.0",
"symfony/console": "^6.3", "symfony/console": "^7.0",
"symfony/event-dispatcher": "^6.3", "symfony/event-dispatcher": "^7.0",
"symfony/http-client": "^6.3", "symfony/http-client": "^7.0",
"symfony/mailgun-mailer": "^6.3", "symfony/mailgun-mailer": "^7.0",
"symfony/mime": "^6.3", "symfony/mime": "^7.0",
"symfony/polyfill-intl-messageformatter": "^1.27", "symfony/polyfill-intl-messageformatter": "^1.27",
"symfony/postmark-mailer": "^6.3", "symfony/postmark-mailer": "^7.0",
"symfony/translation": "^6.3", "symfony/translation": "^7.0",
"symfony/translation-contracts": "^2.5", "symfony/translation-contracts": "^2.5",
"symfony/yaml": "^6.3", "symfony/yaml": "^7.0",
"flarum/json-api-server": "^0.1.0", "flarum/json-api-server": "^0.1.0",
"wikimedia/less.php": "^4.1" "wikimedia/less.php": "^4.1"
}, },
"require-dev": { "require-dev": {
"flarum/testing": "^2.0", "flarum/testing": "^2.0",
"symfony/var-dumper": "^6.3" "symfony/var-dumper": "^7.0"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {

View File

@ -13,13 +13,13 @@ use Illuminate\Database\Schema\Builder;
return [ return [
'up' => function (Builder $schema) { 'up' => function (Builder $schema) {
$schema->table('settings', function (Blueprint $table) { $schema->table('settings', function (Blueprint $table) {
$table->text('value')->change(); $table->text('value')->nullable()->change();
}); });
}, },
'down' => function (Builder $schema) { 'down' => function (Builder $schema) {
$schema->table('settings', function (Blueprint $table) { $schema->table('settings', function (Blueprint $table) {
$table->binary('value')->change(); $table->binary('value')->nullable()->change();
}); });
} }
]; ];

View File

@ -55,7 +55,7 @@ class ConsoleServiceProvider extends AbstractServiceProvider
}); });
$this->container->singleton(LaravelSchedule::class, function (Container $container) { $this->container->singleton(LaravelSchedule::class, function (Container $container) {
return $container->make(Schedule::class); return $container->make(Schedule::class, ['timezone' => $container['config']['app.timezone']]);
}); });
$this->container->singleton('flarum.console.commands', function () { $this->container->singleton('flarum.console.commands', function () {

View File

@ -151,8 +151,12 @@ abstract class AbstractModel extends Eloquent
return $callbacks; return $callbacks;
} }
/**
* @inheritDoc
*/
public function newModelQuery() public function newModelQuery()
{ {
/** @var \Illuminate\Database\Eloquent\Builder<static> $query */
$query = parent::newModelQuery(); $query = parent::newModelQuery();
if ($this->tableAlias) { if ($this->tableAlias) {
@ -183,8 +187,10 @@ abstract class AbstractModel extends Eloquent
return $result; return $result;
} }
// @phpstan-ignore-next-line
public function newCollection(array $models = []): Collection public function newCollection(array $models = []): Collection
{ {
// @phpstan-ignore-next-line
return new Collection($models); return new Collection($models);
} }

View File

@ -9,12 +9,10 @@
namespace Flarum\Database; namespace Flarum\Database;
use Doctrine\DBAL\Types\Type;
use Flarum\Database\Exception\MigrationKeyMissing; use Flarum\Database\Exception\MigrationKeyMissing;
use Flarum\Extension\Extension; use Flarum\Extension\Extension;
use Illuminate\Contracts\Filesystem\FileNotFoundException; use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Illuminate\Database\ConnectionInterface; use Illuminate\Database\ConnectionInterface;
use Illuminate\Database\DBAL\TimestampType;
use Illuminate\Filesystem\Filesystem; use Illuminate\Filesystem\Filesystem;
use RuntimeException; use RuntimeException;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
@ -31,14 +29,6 @@ class Migrator
protected ConnectionInterface $connection, protected ConnectionInterface $connection,
protected Filesystem $files protected Filesystem $files
) { ) {
$doctrine = $connection->getDoctrineConnection()->getDatabasePlatform();
if (! Type::hasType('timestamp')) {
Type::addType('timestamp', TimestampType::class);
}
// Workaround for https://github.com/laravel/framework/issues/1186
$doctrine->registerDoctrineTypeMapping('enum', 'string');
} }
/** /**

View File

@ -37,7 +37,7 @@ class DiscussionPolicy extends AbstractPolicy
if ($allowRenaming === '-1' if ($allowRenaming === '-1'
|| ($allowRenaming === 'reply' && $discussion->participant_count <= 1) || ($allowRenaming === 'reply' && $discussion->participant_count <= 1)
|| (is_numeric($allowRenaming) && $discussion->created_at->diffInMinutes() < $allowRenaming)) { || (is_numeric($allowRenaming) && $discussion->created_at->diffInMinutes(null, true) < $allowRenaming)) {
return $this->allow(); return $this->allow();
} }
} }

Some files were not shown because too many files have changed in this diff Show More