1
0
mirror of https://github.com/flarum/core.git synced 2025-08-11 19:04:29 +02:00

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
205 changed files with 1176 additions and 2361 deletions

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>