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
required: false
# Keep PHP versions synced with build-install-packages.yml
default: '["8.1", "8.2", "8.3"]'
default: '["8.2", "8.3"]'
php_extensions:
description: PHP extensions to install.

View File

@ -6,7 +6,7 @@ on:
env:
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}" }'
jobs:

View File

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

View File

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

View File

@ -1,22 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
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"
backupStaticAttributes="false"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="true"
stopOnFailure="false"
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
>
<coverage processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">../src/</directory>
</include>
</coverage>
</source>
<testsuites>
<testsuite name="Flarum Integration Tests">
<directory suffix="Test.php">./integration</directory>

View File

@ -1,28 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
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"
backupStaticAttributes="false"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
>
<coverage processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">../src/</directory>
</include>
</coverage>
</source>
<testsuites>
<testsuite name="Flarum Unit Tests">
<directory suffix="Test.php">./unit</directory>
</testsuite>
</testsuites>
<listeners>
<listener class="\Mockery\Adapter\Phpunit\TestListener" />
</listeners>
</phpunit>

View File

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

View File

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

View File

@ -17,6 +17,7 @@ use Flarum\Post\Post;
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase;
use Flarum\User\User;
use PHPUnit\Framework\Attributes\Test;
class ApprovePostsTest extends TestCase
{
@ -59,9 +60,7 @@ class ApprovePostsTest extends TestCase
]);
}
/**
* @test
*/
#[Test]
public function can_approve_unapproved_post()
{
$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());
}
/**
* @test
*/
#[Test]
public function cannot_approve_post_without_permission()
{
$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());
}
/**
* @test
*/
#[Test]
public function hiding_post_silently_approves_it()
{
$response = $this->send(

View File

@ -17,6 +17,8 @@ use Flarum\Post\Post;
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase;
use Flarum\User\User;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
class CreatePostsTest extends TestCase
{
@ -68,10 +70,8 @@ class CreatePostsTest extends TestCase
]);
}
/**
* @dataProvider startDiscussionDataProvider
* @test
*/
#[Test]
#[DataProvider('startDiscussionDataProvider')]
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();
@ -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'));
}
/**
* @dataProvider replyToDiscussionDataProvider
* @test
*/
#[Test]
#[DataProvider('replyToDiscussionDataProvider')]
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();

View File

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

View File

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

View File

@ -1,22 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
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"
backupStaticAttributes="false"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="true"
stopOnFailure="false"
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
>
<coverage processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">../src/</directory>
</include>
</coverage>
</source>
<testsuites>
<testsuite name="Flarum Integration Tests">
<directory suffix="Test.php">./integration</directory>

View File

@ -1,28 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
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"
backupStaticAttributes="false"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
>
<coverage processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">../src/</directory>
</include>
</coverage>
</source>
<testsuites>
<testsuite name="Flarum Unit Tests">
<directory suffix="Test.php">./unit</directory>
</testsuite>
</testsuites>
<listeners>
<listener class="\Mockery\Adapter\Phpunit\TestListener" />
</listeners>
</phpunit>

View File

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

View File

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

View File

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

View File

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

View File

@ -13,13 +13,13 @@ use Illuminate\Database\Schema\Builder;
return [
'up' => function (Builder $schema) {
$schema->table('flags', function (Blueprint $table) {
$table->text('reason_detail')->change();
$table->text('reason_detail')->nullable()->change();
});
},
'down' => function (Builder $schema) {
$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 Illuminate\Database\PostgresConnection;
use Illuminate\Support\Arr;
use PHPUnit\Framework\Attributes\Test;
class ListTest extends TestCase
{
@ -70,9 +71,7 @@ class ListTest extends TestCase
]);
}
/**
* @test
*/
#[Test]
public function admin_can_see_one_flag_per_visible_post()
{
$response = $this->send(
@ -96,9 +95,7 @@ class ListTest extends TestCase
}
}
/**
* @test
*/
#[Test]
public function regular_user_sees_own_flags_of_visible_posts()
{
$response = $this->send(
@ -115,9 +112,7 @@ class ListTest extends TestCase
$this->assertEqualsCanonicalizing(['2', '4'], $ids);
}
/**
* @test
*/
#[Test]
public function mod_can_see_one_flag_per_visible_post()
{
$response = $this->send(
@ -134,9 +129,7 @@ class ListTest extends TestCase
$this->assertCount(3, $data);
}
/**
* @test
*/
#[Test]
public function guest_cant_see_flags()
{
$response = $this->send(

View File

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

View File

@ -18,6 +18,8 @@ use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase;
use Flarum\User\User;
use Illuminate\Support\Arr;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
class IncludeFlagsVisibilityTest extends TestCase
{
@ -106,10 +108,8 @@ class IncludeFlagsVisibilityTest extends TestCase
]);
}
/**
* @dataProvider listFlagsIncludesDataProvider
* @test
*/
#[Test]
#[DataProvider('listFlagsIncludesDataProvider')]
public function user_sees_where_allowed_with_included_tags(int $actorId, array $expectedIncludes)
{
$response = $this->send(
@ -137,7 +137,7 @@ class IncludeFlagsVisibilityTest extends TestCase
);
}
public function listFlagsIncludesDataProvider(): array
public static function listFlagsIncludesDataProvider(): array
{
return [
'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"?>
<phpunit
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"
backupStaticAttributes="false"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="true"
stopOnFailure="false"
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
>
<coverage processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">../src/</directory>
</include>
</coverage>
</source>
<testsuites>
<testsuite name="Flarum Integration Tests">
<directory suffix="Test.php">./integration</directory>

View File

@ -1,28 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
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"
backupStaticAttributes="false"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
>
<coverage processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">../src/</directory>
</include>
</coverage>
</source>
<testsuites>
<testsuite name="Flarum Unit Tests">
<directory suffix="Test.php">./unit</directory>
</testsuite>
</testsuites>
<listeners>
<listener class="\Mockery\Adapter\Phpunit\TestListener" />
</listeners>
</phpunit>

View File

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

View File

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

View File

@ -17,6 +17,8 @@ use Flarum\Post\Post;
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase;
use Flarum\User\User;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Psr\Http\Message\ResponseInterface;
class LikePostTest extends TestCase
@ -60,10 +62,8 @@ class LikePostTest extends TestCase
$this->database()->table('group_permission')->insert(['permission' => 'discussion.likePosts', 'group_id' => 5]);
}
/**
* @dataProvider allowedUsersToLike
* @test
*/
#[Test]
#[DataProvider('allowedUsersToLike')]
public function can_like_a_post_if_allowed(int $postId, ?int $authenticatedAs, string $message, bool $canLikeOwnPost = null)
{
if (! is_null($canLikeOwnPost)) {
@ -80,10 +80,8 @@ class LikePostTest extends TestCase
$this->assertNotNull($post->likes->where('id', $authenticatedAs)->first(), $message);
}
/**
* @dataProvider unallowedUsersToLike
* @test
*/
#[Test]
#[DataProvider('unallowedUsersToLike')]
public function cannot_like_a_post_if_not_allowed(int $postId, ?int $authenticatedAs, string $message, bool $canLikeOwnPost = null)
{
if (! is_null($canLikeOwnPost)) {
@ -100,10 +98,8 @@ class LikePostTest extends TestCase
$this->assertNull($post->likes->where('id', $authenticatedAs)->first());
}
/**
* @dataProvider allowedUsersToLike
* @test
*/
#[Test]
#[DataProvider('allowedUsersToLike')]
public function can_dislike_a_post_if_liked_and_allowed(int $postId, ?int $authenticatedAs, string $message, bool $canLikeOwnPost = null)
{
if (! is_null($canLikeOwnPost)) {
@ -121,7 +117,7 @@ class LikePostTest extends TestCase
$this->assertNull($post->likes->where('id', $authenticatedAs)->first(), $message);
}
public function allowedUsersToLike(): array
public static function allowedUsersToLike(): array
{
return [
[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 [
[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\User\User;
use Illuminate\Support\Arr;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
class ListPostsTest extends TestCase
{
@ -72,9 +74,7 @@ class ListPostsTest extends TestCase
]);
}
/**
* @test
*/
#[Test]
public function liked_filter_works()
{
$response = $this->send(
@ -95,9 +95,7 @@ class ListPostsTest extends TestCase
], $ids, 'IDs do not match');
}
/**
* @test
*/
#[Test]
public function liked_filter_works_negated()
{
$response = $this->send(
@ -116,7 +114,7 @@ class ListPostsTest extends TestCase
$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()
{
// List posts endpoint
@ -142,7 +140,7 @@ class ListPostsTest extends TestCase
$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()
{
// List posts endpoint
@ -169,10 +167,8 @@ class ListPostsTest extends TestCase
$this->assertEquals([2, 102, 104, 105], Arr::pluck($likes, 'id'));
}
/**
* @dataProvider likesIncludeProvider
* @test
*/
#[Test]
#[DataProvider('likesIncludeProvider')]
public function likes_relation_returns_limited_results_and_shows_only_visible_posts_in_show_discussion_endpoint(?string $include)
{
// Show discussion endpoint
@ -207,7 +203,7 @@ class ListPostsTest extends TestCase
$this->assertEquals([2, 102, 104, 105], Arr::pluck($likes, 'id'), $body);
}
public function likesIncludeProvider(): array
public static function likesIncludeProvider(): array
{
return [
['posts,posts.likes'],

View File

@ -1,22 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
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"
backupStaticAttributes="false"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="true"
stopOnFailure="false"
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
>
<coverage processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">../src/</directory>
</include>
</coverage>
</source>
<testsuites>
<testsuite name="Flarum Integration Tests">
<directory suffix="Test.php">./integration</directory>

View File

@ -1,28 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
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"
backupStaticAttributes="false"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
>
<coverage processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">../src/</directory>
</include>
</coverage>
</source>
<testsuites>
<testsuite name="Flarum Unit Tests">
<directory suffix="Test.php">./unit</directory>
</testsuite>
</testsuites>
<listeners>
<listener class="\Mockery\Adapter\Phpunit\TestListener" />
</listeners>
</phpunit>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -19,6 +19,7 @@ use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase;
use Flarum\User\DisplayName\DriverInterface;
use Flarum\User\User;
use PHPUnit\Framework\Attributes\Test;
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()
{
$response = $this->send(
@ -107,9 +106,7 @@ class PostMentionsTest extends TestCase
$this->assertNull(CommentPost::find($response['data']['id'])->mentionsPosts->find(4));
}
/**
* @test
*/
#[Test]
public function mentioning_a_valid_post_with_new_format_works()
{
$response = $this->send(
@ -139,9 +136,7 @@ class PostMentionsTest extends TestCase
$this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsPosts->find(4));
}
/**
* @test
*/
#[Test]
public function cannot_mention_a_post_without_access()
{
$response = $this->send(
@ -171,9 +166,7 @@ class PostMentionsTest extends TestCase
$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()
{
$response = $this->send(
@ -205,9 +198,7 @@ class PostMentionsTest extends TestCase
$this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsPosts->find(4));
}
/**
* @test
*/
#[Test]
public function mentioning_an_invalid_post_doesnt_work()
{
$response = $this->send(
@ -237,9 +228,7 @@ class PostMentionsTest extends TestCase
$this->assertCount(0, CommentPost::find($response['data']['id'])->mentionsPosts);
}
/**
* @test
*/
#[Test]
public function mentioning_multiple_posts_works()
{
$response = $this->send(
@ -271,9 +260,7 @@ class PostMentionsTest extends TestCase
$this->assertCount(2, CommentPost::find($response['data']['id'])->mentionsPosts);
}
/**
* @test
*/
#[Test]
public function post_mentions_render_with_fresh_data()
{
$response = $this->send(
@ -291,9 +278,7 @@ class PostMentionsTest extends TestCase
$this->assertCount(1, CommentPost::find($response['data']['id'])->mentionsPosts);
}
/**
* @test
*/
#[Test]
public function post_mentions_unparse_with_fresh_data()
{
$response = $this->send(
@ -310,9 +295,7 @@ class PostMentionsTest extends TestCase
$this->assertCount(1, CommentPost::find($response['data']['id'])->mentionsPosts);
}
/**
* @test
*/
#[Test]
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');
@ -335,9 +318,7 @@ class PostMentionsTest extends TestCase
$this->assertCount(1, CommentPost::find($response['data']['id'])->mentionsPosts);
}
/**
* @test
*/
#[Test]
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');
@ -360,9 +341,7 @@ class PostMentionsTest extends TestCase
$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()
{
$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);
}
/**
* @test
*/
#[Test]
public function post_mentions_with_unremoved_bad_string_from_display_names_doesnt_work()
{
$response = $this->send(
@ -417,9 +394,7 @@ class PostMentionsTest extends TestCase
$this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsPosts->find(6));
}
/**
* @test
*/
#[Test]
public function post_mentions_unparsing_removes_bad_display_name_string()
{
$response = $this->send(
@ -438,9 +413,7 @@ class PostMentionsTest extends TestCase
$this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsPosts->find(9));
}
/**
* @test
*/
#[Test]
public function post_mentions_with_removed_bad_string_from_display_names_works()
{
$response = $this->send(
@ -470,9 +443,7 @@ class PostMentionsTest extends TestCase
$this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsPosts->find(9));
}
/**
* @test
*/
#[Test]
public function editing_a_post_that_has_a_mention_works()
{
$response = $this->send(
@ -499,9 +470,7 @@ class PostMentionsTest extends TestCase
$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()
{
$response = $this->send(
@ -530,9 +499,7 @@ class PostMentionsTest extends TestCase
$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()
{
$response = $this->send(
@ -559,9 +526,7 @@ class PostMentionsTest extends TestCase
$this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsPosts->find(11));
}
/**
* @test
*/
#[Test]
public function rendering_post_mention_with_a_post_context_works()
{
/** @var Formatter $formatter */
@ -576,9 +541,7 @@ class PostMentionsTest extends TestCase
$this->assertStringContainsString('TOBY$', $renderedHtml);
}
/**
* @test
*/
#[Test]
public function rendering_post_mention_without_a_context_works()
{
/** @var Formatter $formatter */

View File

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

View File

@ -18,6 +18,7 @@ use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase;
use Flarum\User\DisplayName\DriverInterface;
use Flarum\User\User;
use PHPUnit\Framework\Attributes\Test;
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()
{
$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);
}
/**
* @test
*/
#[Test]
public function mentioning_a_valid_user_with_old_format_works_if_on()
{
$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));
}
/**
* @test
*/
#[Test]
public function mentioning_a_valid_user_with_new_format_works()
{
$response = $this->send(
@ -163,9 +158,7 @@ class UserMentionsTest extends TestCase
$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()
{
$response = $this->send(
@ -195,9 +188,7 @@ class UserMentionsTest extends TestCase
$this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsUsers->find(3));
}
/**
* @test
*/
#[Test]
public function mentioning_an_invalid_user_doesnt_work()
{
$response = $this->send(
@ -227,9 +218,7 @@ class UserMentionsTest extends TestCase
$this->assertCount(0, CommentPost::find($response['data']['id'])->mentionsUsers);
}
/**
* @test
*/
#[Test]
public function mentioning_multiple_users_works()
{
$response = $this->send(
@ -261,9 +250,7 @@ class UserMentionsTest extends TestCase
$this->assertCount(2, CommentPost::find($response['data']['id'])->mentionsUsers);
}
/**
* @test
*/
#[Test]
public function old_user_mentions_still_render()
{
$response = $this->send(
@ -281,9 +268,7 @@ class UserMentionsTest extends TestCase
$this->assertCount(1, CommentPost::find($response['data']['id'])->mentionsUsers);
}
/**
* @test
*/
#[Test]
public function user_mentions_render_with_fresh_data()
{
$response = $this->send(
@ -312,9 +297,7 @@ class UserMentionsTest extends TestCase
$this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsUsers->find(3));
}
/**
* @test
*/
#[Test]
public function user_mentions_unparse_with_fresh_data()
{
$response = $this->send(
@ -342,9 +325,7 @@ class UserMentionsTest extends TestCase
$this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsUsers->find(3));
}
/**
* @test
*/
#[Test]
public function deleted_user_mentions_unparse_and_render_without_user_data()
{
$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);
}
/**
* @test
*/
#[Test]
public function user_mentions_with_unremoved_bad_string_from_display_names_doesnt_work()
{
$response = $this->send(
@ -400,9 +379,7 @@ class UserMentionsTest extends TestCase
$this->assertNull(CommentPost::find($response['data']['id'])->mentionsUsers->find(5));
}
/**
* @test
*/
#[Test]
public function user_mentions_unparsing_removes_bad_display_name_string()
{
$response = $this->send(
@ -421,9 +398,7 @@ class UserMentionsTest extends TestCase
$this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsUsers->find(5));
}
/**
* @test
*/
#[Test]
public function user_mentions_with_removed_bad_string_from_display_names_works()
{
$response = $this->send(
@ -453,9 +428,7 @@ class UserMentionsTest extends TestCase
$this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsUsers->find(5));
}
/**
* @test
*/
#[Test]
public function editing_a_post_that_has_a_mention_works()
{
$response = $this->send(
@ -482,9 +455,7 @@ class UserMentionsTest extends TestCase
$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()
{
$response = $this->send(

View File

@ -1,22 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
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"
backupStaticAttributes="false"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="true"
stopOnFailure="false"
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
>
<coverage processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">../src/</directory>
</include>
</coverage>
</source>
<testsuites>
<testsuite name="Flarum Integration Tests">
<directory suffix="Test.php">./integration</directory>

View File

@ -1,28 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
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"
backupStaticAttributes="false"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
>
<coverage processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">../src/</directory>
</include>
</coverage>
</source>
<testsuites>
<testsuite name="Flarum Unit Tests">
<directory suffix="Test.php">./unit</directory>
</testsuite>
</testsuites>
<listeners>
<listener class="\Mockery\Adapter\Phpunit\TestListener" />
</listeners>
</phpunit>

View File

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

View File

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

View File

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

View File

@ -1,22 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
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"
backupStaticAttributes="false"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="true"
stopOnFailure="false"
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
>
<coverage processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">../src/</directory>
</include>
</coverage>
</source>
<testsuites>
<testsuite name="Flarum Integration Tests">
<directory suffix="Test.php">./integration</directory>

View File

@ -1,28 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
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"
backupStaticAttributes="false"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
>
<coverage processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">../src/</directory>
</include>
</coverage>
</source>
<testsuites>
<testsuite name="Flarum Unit Tests">
<directory suffix="Test.php">./unit</directory>
</testsuite>
</testsuites>
<listeners>
<listener class="\Mockery\Adapter\Phpunit\TestListener" />
</listeners>
</phpunit>

View File

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

View File

@ -13,15 +13,14 @@ use Flarum\ExtensionManager\Tests\integration\ChangeComposerConfig;
use Flarum\ExtensionManager\Tests\integration\RefreshComposerSetup;
use Flarum\ExtensionManager\Tests\integration\TestCase;
use Illuminate\Support\Arr;
use PHPUnit\Framework\Attributes\Test;
class CheckForUpdatesTest extends TestCase
{
use RefreshComposerSetup;
use ChangeComposerConfig;
/**
* @test
*/
#[Test]
public function can_check_for_updates()
{
$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\TestCase;
use PHPUnit\Framework\Attributes\Test;
class GlobalUpdateTest extends TestCase
{
use RefreshComposerSetup;
/**
* @test
*/
#[Test]
public function can_global_update()
{
$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\RefreshComposerSetup;
use Flarum\ExtensionManager\Tests\integration\TestCase;
use PHPUnit\Framework\Attributes\Test;
class MajorUpdateTest extends TestCase
{
@ -20,9 +21,7 @@ class MajorUpdateTest extends TestCase
use ChangeComposerConfig;
use DummyExtensions;
/**
* @test
*/
#[Test]
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');
@ -45,9 +44,7 @@ class MajorUpdateTest extends TestCase
$this->assertEquals('no_new_major_version', $this->errorDetails($response)['code']);
}
/**
* @test
*/
#[Test]
public function can_update_when_major_update_available()
{
$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', '*');
}
/**
* @test
*/
#[Test]
public function cannot_update_with_incompatible_extensions()
{
$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\RefreshComposerSetup;
use Flarum\ExtensionManager\Tests\integration\TestCase;
use PHPUnit\Framework\Attributes\Test;
class MinorUpdateTest extends TestCase
{
@ -22,9 +23,7 @@ class MinorUpdateTest extends TestCase
use ChangeComposerConfig;
use DummyExtensions;
/**
* @test
*/
#[Test]
public function can_update_to_next_minor_version()
{
$this->makeDummyExtensionCompatibleWith('flarum/dummy-compatible-extension', '^1.0.0');
@ -53,9 +52,7 @@ class MinorUpdateTest extends TestCase
$this->assertPackageVersion('flarum/dummy-compatible-extension', '*');
}
/**
* @test
*/
#[Test]
public function can_update_with_latest_ext_incompatible_with_latest_core()
{
$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\TestCase;
use PHPUnit\Framework\Attributes\Test;
class RemoveExtensionTest extends TestCase
{
use RefreshComposerSetup;
/**
* @test
*/
#[Test]
public function extension_installed_by_default()
{
$this->assertExtensionExists('flarum-tags');
}
/**
* @test
*/
#[Test]
public function removing_an_extension_works()
{
$response = $this->send(
@ -39,9 +36,7 @@ class RemoveExtensionTest extends TestCase
$this->assertExtensionNotExists('flarum-tags');
}
/**
* @test
*/
#[Test]
public function removing_a_non_existant_extension_fails()
{
$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\TestCase;
use PHPUnit\Framework\Attributes\Test;
class RequireExtensionTest extends TestCase
{
use RefreshComposerSetup;
/**
* @test
*/
#[Test]
public function extension_uninstalled_by_default()
{
$this->assertExtensionNotExists('v17development-blog');
}
/**
* @test
*/
#[Test]
public function requiring_an_existing_extension_fails()
{
$response = $this->send(
@ -43,9 +40,7 @@ class RequireExtensionTest extends TestCase
$this->assertEquals(409, $response->getStatusCode());
}
/**
* @test
*/
#[Test]
public function requiring_a_compatible_extension_works()
{
$response = $this->send(
@ -63,9 +58,7 @@ class RequireExtensionTest extends TestCase
$this->assertExtensionExists('v17development-blog');
}
/**
* @test
*/
#[Test]
public function requiring_a_compatible_extension_with_specific_version_works()
{
$response = $this->send(
@ -83,9 +76,7 @@ class RequireExtensionTest extends TestCase
$this->assertExtensionExists('v17development-blog');
}
/**
* @test
*/
#[Test]
public function requiring_an_uncompatible_extension_fails()
{
$response = $this->send(
@ -103,9 +94,7 @@ class RequireExtensionTest extends TestCase
$this->assertEquals('extension_incompatible_with_instance', $this->errorDetails($response)['guessed_cause']);
}
/**
* @test
*/
#[Test]
public function requiring_an_uncompatible_extension_with_specific_version_fails()
{
$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\TestCase;
use PHPUnit\Framework\Attributes\Test;
class UpdateExtensionTest extends TestCase
{
use RefreshComposerSetup;
/**
* @test
*/
#[Test]
public function extension_installed_by_default()
{
$this->assertExtensionExists('flarum-tags');
}
/**
* @test
*/
#[Test]
public function updating_an_existing_extension_works()
{
$response = $this->send(
@ -39,9 +36,7 @@ class UpdateExtensionTest extends TestCase
$this->assertExtensionExists('flarum-tags');
}
/**
* @test
*/
#[Test]
public function updating_a_non_existing_extension_fails()
{
$response = $this->send(

View File

@ -1,21 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
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"
backupStaticAttributes="false"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="true"
stopOnFailure="false"
>
<coverage processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">../src/</directory>
</include>
</coverage>
</source>
<testsuites>
<testsuite name="Flarum Integration Tests">
<directory suffix="Test.php">./integration</directory>

View File

@ -1,27 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
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"
backupStaticAttributes="false"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
>
<coverage processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">../src/</directory>
</include>
</coverage>
</source>
<testsuites>
<testsuite name="Flarum Unit Tests">
<directory suffix="Test.php">./unit</directory>
</testsuite>
</testsuites>
<listeners>
<listener class="\Mockery\Adapter\Phpunit\TestListener" />
</listeners>
</phpunit>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,22 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
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"
backupStaticAttributes="false"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="true"
stopOnFailure="false"
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
>
<coverage processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">../src/</directory>
</include>
</coverage>
</source>
<testsuites>
<testsuite name="Flarum Integration Tests">
<directory suffix="Test.php">./integration</directory>

View File

@ -1,28 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
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"
backupStaticAttributes="false"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
>
<coverage processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">../src/</directory>
</include>
</coverage>
</source>
<testsuites>
<testsuite name="Flarum Unit Tests">
<directory suffix="Test.php">./unit</directory>
</testsuite>
</testsuites>
<listeners>
<listener class="\Mockery\Adapter\Phpunit\TestListener" />
</listeners>
</phpunit>

View File

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

View File

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

View File

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

View File

@ -1,22 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
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"
backupStaticAttributes="false"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="true"
stopOnFailure="false"
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
>
<coverage processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">../src/</directory>
</include>
</coverage>
</source>
<testsuites>
<testsuite name="Flarum Integration Tests">
<directory suffix="Test.php">./integration</directory>

View File

@ -1,28 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
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"
backupStaticAttributes="false"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
>
<coverage processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">../src/</directory>
</include>
</coverage>
</source>
<testsuites>
<testsuite name="Flarum Unit Tests">
<directory suffix="Test.php">./unit</directory>
</testsuite>
</testsuites>
<listeners>
<listener class="\Mockery\Adapter\Phpunit\TestListener" />
</listeners>
</phpunit>

View File

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

View File

@ -17,6 +17,8 @@ use Flarum\Post\Post;
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase;
use Flarum\User\User;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
class ReplyNotificationTest extends TestCase
{
@ -62,10 +64,8 @@ class ReplyNotificationTest extends TestCase
]);
}
/**
* @dataProvider replyingSendsNotificationsDataProvider
* @test
*/
#[Test]
#[DataProvider('replyingSendsNotificationsDataProvider')]
public function replying_to_a_discussion_with_comment_post_as_last_post_sends_reply_notification(int $userId, int $discussionId, int $newNotificationCount)
{
$this->app();
@ -96,7 +96,7 @@ class ReplyNotificationTest extends TestCase
$this->assertEquals($newNotificationCount, $mainUser->getUnreadNotificationCount());
}
public function replyingSendsNotificationsDataProvider(): array
public static function replyingSendsNotificationsDataProvider(): array
{
return [
'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()
{
$this->app();
@ -166,10 +166,8 @@ class ReplyNotificationTest extends TestCase
$this->assertEquals(1, $mainUser->getUnreadNotificationCount());
}
/**
* @dataProvider deleteLastPostsProvider
* @test
*/
#[Test]
#[DataProvider('deleteLastPostsProvider')]
public function deleting_last_posts_then_posting_new_one_sends_reply_notification(array $postIds)
{
$this->prepareDatabase([
@ -222,7 +220,7 @@ class ReplyNotificationTest extends TestCase
$this->assertEquals(1, $mainUser->getUnreadNotificationCount());
}
public function deleteLastPostsProvider(): array
public static function deleteLastPostsProvider(): array
{
return [
[[10, 9, 8]],
@ -230,7 +228,7 @@ class ReplyNotificationTest extends TestCase
];
}
/** @test */
#[Test]
public function approving_reply_sends_reply_notification()
{
// Flags was only specified because it is required for approval.
@ -288,7 +286,7 @@ class ReplyNotificationTest extends TestCase
$this->assertEquals(1, $mainUser->getUnreadNotificationCount());
}
/** @test */
#[Test]
public function replying_to_a_discussion_with_a_restricted_post_only_sends_notifications_to_allowed_users()
{
// 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\TestCase;
use Flarum\User\User;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
class SubscribeTest extends TestCase
{
@ -60,10 +62,8 @@ class SubscribeTest extends TestCase
]);
}
/**
* @test
* @dataProvider provideStates
*/
#[Test]
#[DataProvider('provideStates')]
public function can_subscribe_to_a_discussion(int $actorId, int $discussionId, ?string $newState)
{
$this->app();

View File

@ -1,22 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
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"
backupStaticAttributes="false"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="true"
stopOnFailure="false"
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
>
<coverage processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">../src/</directory>
</include>
</coverage>
</source>
<testsuites>
<testsuite name="Flarum Integration Tests">
<directory suffix="Test.php">./integration</directory>

View File

@ -1,28 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
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"
backupStaticAttributes="false"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
>
<coverage processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">../src/</directory>
</include>
</coverage>
</source>
<testsuites>
<testsuite name="Flarum Unit Tests">
<directory suffix="Test.php">./unit</directory>
</testsuite>
</testsuites>
<listeners>
<listener class="\Mockery\Adapter\Phpunit\TestListener" />
</listeners>
</phpunit>

View File

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

View File

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

View File

@ -14,6 +14,7 @@ use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase;
use Flarum\User\User;
use Illuminate\Support\Arr;
use PHPUnit\Framework\Attributes\Test;
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'));
}
/** @test */
#[Test]
public function can_filter_users_by_suspension()
{
$response = $this->send(

View File

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

View File

@ -1,22 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
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"
backupStaticAttributes="false"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="true"
stopOnFailure="false"
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
>
<coverage processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">../src/</directory>
</include>
</coverage>
</source>
<testsuites>
<testsuite name="Flarum Integration Tests">
<directory suffix="Test.php">./integration</directory>

View File

@ -1,28 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
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"
backupStaticAttributes="false"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
>
<coverage processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">../src/</directory>
</include>
</coverage>
</source>
<testsuites>
<testsuite name="Flarum Unit Tests">
<directory suffix="Test.php">./unit</directory>
</testsuite>
</testsuites>
<listeners>
<listener class="\Mockery\Adapter\Phpunit\TestListener" />
</listeners>
</phpunit>

View File

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

View File

@ -62,7 +62,7 @@ class DiscussionPolicy extends AbstractPolicy
if (
$allowEditTags === '-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();
}

View File

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

View File

@ -18,6 +18,8 @@ use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase;
use Flarum\User\User;
use Illuminate\Support\Arr;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
class ListTest extends TestCase
{
@ -110,9 +112,7 @@ class ListTest extends TestCase
]);
}
/**
* @test
*/
#[Test]
public function admin_sees_all()
{
$response = $this->send(
@ -129,9 +129,7 @@ class ListTest extends TestCase
$this->assertEqualsCanonicalizing(['1', '2', '3', '4', '5', '6'], $ids);
}
/**
* @test
*/
#[Test]
public function user_sees_where_allowed()
{
$response = $this->send(
@ -148,9 +146,7 @@ class ListTest extends TestCase
$this->assertEqualsCanonicalizing(['1', '2', '3', '4'], $ids);
}
/**
* @test
*/
#[Test]
public function guest_can_see_where_allowed()
{
$response = $this->send(
@ -165,10 +161,8 @@ class ListTest extends TestCase
$this->assertEqualsCanonicalizing(['1', '2'], $ids);
}
/**
* @dataProvider seeWhereAllowedWhenMoreTagsAreRequiredThanAvailableDataProvider
* @test
*/
#[Test]
#[DataProvider('seeWhereAllowedWhenMoreTagsAreRequiredThanAvailableDataProvider')]
public function actor_can_see_where_allowed_when_more_tags_are_required_than_available(string $type, int $actorId, array $expectedDiscussions)
{
if ($type === 'secondary') {
@ -201,7 +195,7 @@ class ListTest extends TestCase
$this->assertEqualsCanonicalizing($expectedDiscussions, $ids);
}
public function seeWhereAllowedWhenMoreTagsAreRequiredThanAvailableDataProvider(): array
public static function seeWhereAllowedWhenMoreTagsAreRequiredThanAvailableDataProvider(): array
{
return [
// admin_can_see_where_allowed_when_more_primary_tags_are_required_than_available
@ -219,10 +213,8 @@ class ListTest extends TestCase
];
}
/**
* @dataProvider filterByTagsDataProvider
* @test
*/
#[Test]
#[DataProvider('filterByTagsDataProvider')]
public function can_filter_by_authorized_tags(int $authenticatedAs, string $tags, array $expectedDiscussionIds)
{
$response = $this->send(
@ -242,7 +234,7 @@ class ListTest extends TestCase
$this->assertEqualsCanonicalizing($expectedDiscussionIds, array_map('intval', $ids));
}
public function filterByTagsDataProvider(): array
public static function filterByTagsDataProvider(): array
{
return [
// 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\TestCase;
use Flarum\User\User;
use PHPUnit\Framework\Attributes\Test;
class UpdateTest extends TestCase
{
@ -57,9 +58,7 @@ class UpdateTest extends TestCase
]);
}
/**
* @test
*/
#[Test]
public function user_cant_change_tags_without_setting()
{
$response = $this->send(
@ -82,9 +81,7 @@ class UpdateTest extends TestCase
$this->assertEquals(403, $response->getStatusCode());
}
/**
* @test
*/
#[Test]
public function user_can_change_tags_without_setting()
{
$this->setting('allow_tag_change', '-1');
@ -109,9 +106,7 @@ class UpdateTest extends TestCase
$this->assertEquals(200, $response->getStatusCode());
}
/**
* @test
*/
#[Test]
public function admin_can_add_primary_tag_beyond_limit()
{
$response = $this->send(
@ -135,9 +130,7 @@ class UpdateTest extends TestCase
$this->assertEquals(200, $response->getStatusCode());
}
/**
* @test
*/
#[Test]
public function user_cant_add_primary_tag_beyond_limit()
{
$this->setting('allow_tag_change', '-1');
@ -163,9 +156,7 @@ class UpdateTest extends TestCase
$this->assertEquals(422, $response->getStatusCode());
}
/**
* @test
*/
#[Test]
public function user_cant_add_tag_where_can_view_but_cant_start()
{
$this->setting('allow_tag_change', '-1');
@ -190,9 +181,7 @@ class UpdateTest extends TestCase
$this->assertEquals(403, $response->getStatusCode());
}
/**
* @test
*/
#[Test]
public function user_can_add_tag_where_can_view_and_can_start()
{
$this->setting('allow_tag_change', '-1');
@ -218,9 +207,7 @@ class UpdateTest extends TestCase
$this->assertEquals(200, $response->getStatusCode());
}
/**
* @test
*/
#[Test]
public function user_cant_add_child_tag_without_parent_tag()
{
$this->setting('allow_tag_change', '-1');
@ -250,9 +237,7 @@ class UpdateTest extends TestCase
$this->assertEquals(403, $response->getStatusCode(), $response->getBody());
}
/**
* @test
*/
#[Test]
public function user_can_add_child_tag_with_parent_tag()
{
$this->setting('allow_tag_change', '-1');
@ -278,9 +263,7 @@ class UpdateTest extends TestCase
$this->assertEquals(200, $response->getStatusCode());
}
/**
* @test
*/
#[Test]
public function primary_tag_required_by_default()
{
$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\TestCase;
use Flarum\User\User;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
class ListTest extends TestCase
{
@ -74,10 +76,8 @@ class ListTest extends TestCase
]);
}
/**
* @dataProvider authorizedUsers
* @test
*/
#[Test]
#[DataProvider('authorizedUsers')]
public function event_mentioned_tags_are_included_in_response_for_authorized_users(int $userId)
{
$response = $this->send(
@ -101,10 +101,8 @@ class ListTest extends TestCase
$this->assertEqualsCanonicalizing([1, 5], $tagIds, $body);
}
/**
* @dataProvider unauthorizedUsers
* @test
*/
#[Test]
#[DataProvider('unauthorizedUsers')]
public function event_mentioned_tags_are_not_included_in_response_for_unauthorized_users(?int $userId)
{
$response = $this->send(
@ -126,7 +124,7 @@ class ListTest extends TestCase
$this->assertEqualsCanonicalizing([1], $tagIds);
}
public function authorizedUsers()
public static function authorizedUsers()
{
return [
'admin' => [1],
@ -134,7 +132,7 @@ class ListTest extends TestCase
];
}
public function unauthorizedUsers()
public static function unauthorizedUsers()
{
return [
'normal user without permission' => [3],

View File

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

View File

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

View File

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

View File

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

View File

@ -15,6 +15,7 @@ use Flarum\Tags\Tests\integration\RetrievesRepresentativeTags;
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase;
use Flarum\User\User;
use PHPUnit\Framework\Attributes\Test;
class GlobalPolicyTest extends TestCase
{
@ -38,9 +39,7 @@ class GlobalPolicyTest extends TestCase
]);
}
/**
* @test
*/
#[Test]
public function cant_start_discussion_globally_if_permission_not_granted()
{
$this->database()->table('group_permission')->where('permission', 'startDiscussion')->delete();
@ -48,9 +47,7 @@ class GlobalPolicyTest extends TestCase
$this->assertFalse(User::find(2)->can('startDiscussion'));
}
/**
* @test
*/
#[Test]
public function can_start_discussion_globally_if_allowed_in_primary_tag()
{
$this->prepareDatabase([
@ -64,9 +61,7 @@ class GlobalPolicyTest extends TestCase
$this->assertTrue(User::find(2)->can('startDiscussion'));
}
/**
* @test
*/
#[Test]
public function cant_start_discussion_globally_if_allowed_in_child_tag_only()
{
$this->prepareDatabase([
@ -80,9 +75,7 @@ class GlobalPolicyTest extends TestCase
$this->assertFalse(User::find(2)->can('startDiscussion'));
}
/**
* @test
*/
#[Test]
public function cant_start_discussion_globally_if_allowed_in_secondary_tag()
{
$this->prepareDatabase([
@ -96,9 +89,7 @@ class GlobalPolicyTest extends TestCase
$this->assertFalse(User::find(2)->can('startDiscussion'));
}
/**
* @test
*/
#[Test]
public function can_start_discussion_globally_if_allowed_in_secondary_tag_and_minimums_adjusted()
{
$this->prepareDatabase([
@ -115,9 +106,7 @@ class GlobalPolicyTest extends TestCase
$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()
{
$this->prepareDatabase([
@ -131,9 +120,7 @@ class GlobalPolicyTest extends TestCase
$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()
{
$this->prepareDatabase([
@ -147,9 +134,7 @@ class GlobalPolicyTest extends TestCase
$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()
{
$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\TestCase;
use Flarum\User\User;
use PHPUnit\Framework\Attributes\Test;
class TagPolicyTest extends TestCase
{
@ -42,9 +43,7 @@ class TagPolicyTest extends TestCase
]);
}
/**
* @test
*/
#[Test]
public function has_ability_when_allowed_in_restricted_tag()
{
$this->app();
@ -54,9 +53,7 @@ class TagPolicyTest extends TestCase
$this->assertTrue(User::find(2)->can('arbitraryAbility!', $tag));
}
/**
* @test
*/
#[Test]
public function has_ability_in_child_when_allowed_in_top_tag_and_child()
{
$this->app();
@ -66,9 +63,7 @@ class TagPolicyTest extends TestCase
$this->assertTrue(User::find(2)->can('arbitraryAbility!', $tag));
}
/**
* @test
*/
#[Test]
public function doesnt_have_ability_in_child_when_allowed_in_child_but_not_parent()
{
$this->app();
@ -80,9 +75,7 @@ class TagPolicyTest extends TestCase
$this->assertFalse(User::find(2)->can('arbitraryAbility!', $tag));
}
/**
* @test
*/
#[Test]
public function nonrestricted_tag_falls_back_to_global_when_allowed()
{
$this->prepareDatabase([
@ -98,9 +91,7 @@ class TagPolicyTest extends TestCase
$this->assertTrue(User::find(2)->can('arbitraryAbility!', $tag));
}
/**
* @test
*/
#[Test]
public function nonrestricted_tag_falls_back_to_global_when_not_allowed()
{
$this->app();

View File

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

View File

@ -1,22 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
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"
backupStaticAttributes="false"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="true"
stopOnFailure="false"
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
>
<coverage processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">../src/</directory>
</include>
</coverage>
</source>
<testsuites>
<testsuite name="Flarum Integration Tests">
<directory suffix="Test.php">./integration</directory>

View File

@ -1,28 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
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"
backupStaticAttributes="false"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
>
<coverage processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">../src/</directory>
</include>
</coverage>
</source>
<testsuites>
<testsuite name="Flarum Unit Tests">
<directory suffix="Test.php">./unit</directory>
</testsuite>
</testsuites>
<listeners>
<listener class="\Mockery\Adapter\Phpunit\TestListener" />
</listeners>
</phpunit>

View File

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

View File

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

View File

@ -13,13 +13,13 @@ use Illuminate\Database\Schema\Builder;
return [
'up' => function (Builder $schema) {
$schema->table('settings', function (Blueprint $table) {
$table->text('value')->change();
$table->text('value')->nullable()->change();
});
},
'down' => function (Builder $schema) {
$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) {
return $container->make(Schedule::class);
return $container->make(Schedule::class, ['timezone' => $container['config']['app.timezone']]);
});
$this->container->singleton('flarum.console.commands', function () {

View File

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

View File

@ -9,12 +9,10 @@
namespace Flarum\Database;
use Doctrine\DBAL\Types\Type;
use Flarum\Database\Exception\MigrationKeyMissing;
use Flarum\Extension\Extension;
use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Illuminate\Database\ConnectionInterface;
use Illuminate\Database\DBAL\TimestampType;
use Illuminate\Filesystem\Filesystem;
use RuntimeException;
use Symfony\Component\Console\Output\OutputInterface;
@ -31,14 +29,6 @@ class Migrator
protected ConnectionInterface $connection,
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'
|| ($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();
}
}

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