mirror of
https://github.com/flarum/core.git
synced 2025-08-18 22:31:32 +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:
1
extensions/likes/.gitignore
vendored
1
extensions/likes/.gitignore
vendored
@@ -4,6 +4,7 @@ composer.phar
|
||||
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
tests/.phpunit.cache
|
||||
tests/.phpunit.result.cache
|
||||
/tests/integration/tmp
|
||||
.vagrant
|
||||
|
@@ -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'],
|
||||
|
@@ -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'],
|
||||
|
@@ -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>
|
||||
|
@@ -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>
|
||||
|
Reference in New Issue
Block a user