mirror of
https://github.com/flarum/core.git
synced 2025-08-05 16:07:34 +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:
@@ -29,7 +29,7 @@ class IndexTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
public function admin_can_access_admin_route(): void
|
||||
public function test_admin_can_access_admin_route(): void
|
||||
{
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/admin', [
|
||||
@@ -40,7 +40,7 @@ class IndexTest extends TestCase
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
|
||||
public function user_cannot_access_admin_route(): void
|
||||
public function test_user_cannot_access_admin_route(): void
|
||||
{
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/admin', [
|
||||
|
@@ -14,6 +14,7 @@ use Flarum\Http\AccessToken;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Laminas\Diactoros\ServerRequest;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class AccessTokenLifecycleTest extends TestCase
|
||||
{
|
||||
@@ -35,9 +36,7 @@ class AccessTokenLifecycleTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function tokens_expire()
|
||||
{
|
||||
$this->populateDatabase();
|
||||
@@ -52,9 +51,7 @@ class AccessTokenLifecycleTest extends TestCase
|
||||
$this->assertEquals(['a', 'b'], AccessToken::whereExpired(Carbon::parse('2027-01-01 01:00:00'))->pluck('token')->sort()->values()->all());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function tokens_valid()
|
||||
{
|
||||
$this->populateDatabase();
|
||||
@@ -69,9 +66,7 @@ class AccessTokenLifecycleTest extends TestCase
|
||||
$this->assertEquals(['c'], AccessToken::whereValid(Carbon::parse('2027-01-01 01:00:00'))->pluck('token')->all());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function touch_updates_lifetime()
|
||||
{
|
||||
$this->populateDatabase();
|
||||
@@ -87,9 +82,7 @@ class AccessTokenLifecycleTest extends TestCase
|
||||
$this->assertTrue(AccessToken::whereValid(Carbon::parse('2021-01-01 03:30:00'))->whereToken('a')->exists());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function touch_without_request()
|
||||
{
|
||||
$this->populateDatabase();
|
||||
@@ -104,9 +97,7 @@ class AccessTokenLifecycleTest extends TestCase
|
||||
$this->assertNull($token->last_user_agent);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function touch_with_request()
|
||||
{
|
||||
$this->populateDatabase();
|
||||
@@ -123,9 +114,7 @@ class AccessTokenLifecycleTest extends TestCase
|
||||
$this->assertEquals('Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36', $token->last_user_agent);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function long_user_agent_id_truncated()
|
||||
{
|
||||
$this->populateDatabase();
|
||||
|
@@ -13,6 +13,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;
|
||||
|
||||
class CreateTest extends TestCase
|
||||
{
|
||||
@@ -42,10 +44,8 @@ class CreateTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider canCreateTokens
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('canCreateTokens')]
|
||||
public function user_can_create_developer_tokens(int $authenticatedAs)
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -65,10 +65,8 @@ class CreateTest extends TestCase
|
||||
$this->assertEquals(201, $response->getStatusCode(), (string) $response->getBody());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider cannotCreateTokens
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('cannotCreateTokens')]
|
||||
public function user_cannot_delete_other_users_tokens(int $authenticatedAs)
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -88,9 +86,7 @@ class CreateTest extends TestCase
|
||||
$this->assertEquals(403, $response->getStatusCode(), (string) $response->getBody());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function user_cannot_create_token_without_title()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -108,7 +104,7 @@ class CreateTest extends TestCase
|
||||
$this->assertEquals(422, $response->getStatusCode(), (string) $response->getBody());
|
||||
}
|
||||
|
||||
public function canCreateTokens(): array
|
||||
public static function canCreateTokens(): array
|
||||
{
|
||||
return [
|
||||
[1], // Admin
|
||||
@@ -116,7 +112,7 @@ class CreateTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
public function cannotCreateTokens(): array
|
||||
public static function cannotCreateTokens(): array
|
||||
{
|
||||
return [
|
||||
[2]
|
||||
|
@@ -18,6 +18,8 @@ use Flarum\Http\SessionAccessToken;
|
||||
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 DeleteTest extends TestCase
|
||||
{
|
||||
@@ -56,10 +58,8 @@ class DeleteTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider canDeleteTokensDataProvider
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('canDeleteTokensDataProvider')]
|
||||
public function user_can_delete_tokens(int $authenticatedAs, array $canDeleteIds)
|
||||
{
|
||||
foreach ($canDeleteIds as $id) {
|
||||
@@ -71,10 +71,8 @@ class DeleteTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider cannotDeleteTokensDataProvider
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('cannotDeleteTokensDataProvider')]
|
||||
public function user_cannot_delete_tokens(int $authenticatedAs, array $canDeleteIds)
|
||||
{
|
||||
foreach ($canDeleteIds as $id) {
|
||||
@@ -86,9 +84,7 @@ class DeleteTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function user_cannot_delete_current_session_token()
|
||||
{
|
||||
$responseWithSession = $this->send(
|
||||
@@ -120,9 +116,7 @@ class DeleteTest extends TestCase
|
||||
$this->assertEquals(403, $response->getStatusCode(), $response->getBody()->getContents());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function user_can_terminate_all_other_sessions()
|
||||
{
|
||||
$responseWithSession = $this->send(
|
||||
@@ -165,9 +159,7 @@ class DeleteTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function terminting_all_other_sessions_does_not_delete_dev_tokens()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -186,7 +178,7 @@ class DeleteTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function canDeleteTokensDataProvider(): array
|
||||
public static function canDeleteTokensDataProvider(): array
|
||||
{
|
||||
return [
|
||||
// Admin can delete any user tokens.
|
||||
@@ -201,7 +193,7 @@ class DeleteTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
public function cannotDeleteTokensDataProvider(): array
|
||||
public static function cannotDeleteTokensDataProvider(): array
|
||||
{
|
||||
return [
|
||||
// Normal users cannot delete other users' tokens.
|
||||
|
@@ -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
|
||||
{
|
||||
@@ -54,10 +56,8 @@ class ListTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider canViewTokensDataProvider
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('canViewTokensDataProvider')]
|
||||
public function user_can_view_access_tokens(int $authenticatedAs, array $canViewIds)
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -72,10 +72,8 @@ class ListTest extends TestCase
|
||||
$this->assertEqualsCanonicalizing(array_merge($canViewIds, [$testsTokenId]), Arr::pluck($data, 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider cannotSeeTokenValuesDataProvider
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('cannotSeeTokenValuesDataProvider')]
|
||||
public function user_cannot_see_token_values(int $authenticatedAs, ?int $userId, array $tokenValues)
|
||||
{
|
||||
if ($userId) {
|
||||
@@ -101,10 +99,8 @@ class ListTest extends TestCase
|
||||
$this->assertEqualsCanonicalizing($tokenValues, Arr::pluck($data, 'attributes.token'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider needsPermissionToUseUserfilterDataProvider
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('needsPermissionToUseUserfilterDataProvider')]
|
||||
public function user_needs_permissions_to_use_user_filter(int $authenticatedAs, int $userId, array $canViewIds)
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -125,7 +121,7 @@ class ListTest extends TestCase
|
||||
$this->assertEqualsCanonicalizing($canViewIds, Arr::pluck($data, 'id'));
|
||||
}
|
||||
|
||||
public function canViewTokensDataProvider(): array
|
||||
public static function canViewTokensDataProvider(): array
|
||||
{
|
||||
return [
|
||||
// Admin can view his and others access tokens.
|
||||
@@ -140,7 +136,7 @@ class ListTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
public function cannotSeeTokenValuesDataProvider(): array
|
||||
public static function cannotSeeTokenValuesDataProvider(): array
|
||||
{
|
||||
return [
|
||||
// Admin can only see his own developer token value.
|
||||
@@ -161,7 +157,7 @@ class ListTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
public function needsPermissionToUseUserfilterDataProvider(): array
|
||||
public static function needsPermissionToUseUserfilterDataProvider(): array
|
||||
{
|
||||
return [
|
||||
// Admin can use user filter.
|
||||
|
@@ -13,6 +13,7 @@ use Carbon\Carbon;
|
||||
use Flarum\Http\AccessToken;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class RemembererTest extends TestCase
|
||||
{
|
||||
@@ -33,9 +34,7 @@ class RemembererTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function non_remember_tokens_cannot_be_used()
|
||||
{
|
||||
$this->populateDatabase();
|
||||
@@ -54,9 +53,7 @@ class RemembererTest extends TestCase
|
||||
$this->assertFalse($data['data']['attributes']['canSearchUsers']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function expired_tokens_cannot_be_used()
|
||||
{
|
||||
$this->populateDatabase();
|
||||
@@ -75,9 +72,7 @@ class RemembererTest extends TestCase
|
||||
$this->assertFalse($data['data']['attributes']['canSearchUsers']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function valid_tokens_can_be_used()
|
||||
{
|
||||
$this->populateDatabase();
|
||||
|
@@ -14,6 +14,7 @@ use Flarum\Api\ApiKey;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Flarum\User\User;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class WithApiKeyTest extends TestCase
|
||||
{
|
||||
@@ -37,9 +38,7 @@ class WithApiKeyTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function cannot_authorize_without_key()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -50,9 +49,7 @@ class WithApiKeyTest extends TestCase
|
||||
$this->assertFalse($data['data']['attributes']['canSearchUsers']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function master_token_can_authenticate_as_anyone()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -69,9 +66,7 @@ class WithApiKeyTest extends TestCase
|
||||
$this->assertNotNull($key->last_activity_at);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function personal_api_token_cannot_authenticate_as_anyone()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -88,9 +83,7 @@ class WithApiKeyTest extends TestCase
|
||||
$this->assertNotNull($key->last_activity_at);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function personal_api_token_authenticates_user()
|
||||
{
|
||||
$response = $this->send(
|
||||
|
@@ -13,6 +13,7 @@ use Flarum\Http\AccessToken;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Flarum\User\User;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class WithTokenTest extends TestCase
|
||||
{
|
||||
@@ -32,9 +33,7 @@ class WithTokenTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function user_generates_token()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -64,9 +63,7 @@ class WithTokenTest extends TestCase
|
||||
$this->assertEquals(2, AccessToken::whereToken($token)->firstOrFail()->user_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function failure_with_invalid_credentials()
|
||||
{
|
||||
$response = $this->send(
|
||||
|
@@ -13,6 +13,7 @@ use Flarum\Api\ApiKey;
|
||||
use Flarum\Http\AccessToken;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class RequireCsrfTokenTest extends TestCase
|
||||
{
|
||||
@@ -34,9 +35,7 @@ class RequireCsrfTokenTest extends TestCase
|
||||
$this->setting('csrf_test', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function error_when_doing_cookie_auth_without_csrf_token()
|
||||
{
|
||||
$auth = $this->send(
|
||||
@@ -73,9 +72,7 @@ class RequireCsrfTokenTest extends TestCase
|
||||
$this->assertEquals('csrf_token_mismatch', $json['errors'][0]['code']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function cookie_auth_succeeds_with_csrf_token_in_header()
|
||||
{
|
||||
$initial = $this->send(
|
||||
@@ -118,9 +115,7 @@ class RequireCsrfTokenTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function cookie_auth_succeeds_with_csrf_token_in_body()
|
||||
{
|
||||
$initial = $this->send(
|
||||
@@ -163,9 +158,7 @@ class RequireCsrfTokenTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function master_api_token_does_not_need_csrf_token()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -188,9 +181,7 @@ class RequireCsrfTokenTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function access_token_does_not_need_csrf_token()
|
||||
{
|
||||
$this->database()->table('access_tokens')->insert(
|
||||
|
@@ -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
|
||||
{
|
||||
@@ -33,9 +34,7 @@ class CreateTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function cannot_create_discussion_without_content()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -71,9 +70,7 @@ class CreateTest extends TestCase
|
||||
], json_decode($body, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function cannot_create_discussion_without_title()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -108,9 +105,7 @@ class CreateTest extends TestCase
|
||||
], json_decode($body, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function can_create_discussion()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -140,9 +135,7 @@ class CreateTest extends TestCase
|
||||
$this->assertEquals('test - too-obscure', Arr::get($data, 'data.attributes.title'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function can_create_discussion_with_current_lang_slug_transliteration()
|
||||
{
|
||||
// Forum default is traditional Chinese.
|
||||
@@ -171,9 +164,7 @@ class CreateTest extends TestCase
|
||||
$this->assertEquals('wo-shi-yi-ge-tu-dou', $discussion->slug);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function can_create_discussion_with_forum_locale_transliteration()
|
||||
{
|
||||
// Forum default is traditional Chinese.
|
||||
@@ -204,9 +195,7 @@ class CreateTest extends TestCase
|
||||
$this->assertEquals('wo-shi-yi-ge-tu-dou', $discussion->slug);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function discussion_creation_limited_by_throttler()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -244,9 +233,7 @@ class CreateTest extends TestCase
|
||||
$this->assertEquals(429, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function throttler_doesnt_apply_to_admin()
|
||||
{
|
||||
$this->send(
|
||||
|
@@ -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 DeletionTest extends TestCase
|
||||
{
|
||||
@@ -40,9 +41,7 @@ class DeletionTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function admin_can_delete()
|
||||
{
|
||||
$response = $this->send(
|
||||
|
@@ -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 ListTest extends TestCase
|
||||
{
|
||||
@@ -57,9 +58,7 @@ class ListTest extends TestCase
|
||||
$user->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shows_index_for_guest()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -72,9 +71,7 @@ class ListTest extends TestCase
|
||||
$this->assertEquals(3, count($data['data']));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function author_filter_works()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -95,9 +92,7 @@ class ListTest extends TestCase
|
||||
$this->assertEqualsCanonicalizing(['2', '3'], Arr::pluck($data, 'id'), 'IDs do not match');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function author_filter_works_negated()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -114,9 +109,7 @@ class ListTest extends TestCase
|
||||
$this->assertEquals(['1'], Arr::pluck($data, 'id'), 'IDs do not match');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function created_filter_works_with_date()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -135,9 +128,7 @@ class ListTest extends TestCase
|
||||
$this->assertEquals(['3'], Arr::pluck($data, 'id'), 'IDs do not match');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function created_filter_works_negated_with_date()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -154,9 +145,7 @@ class ListTest extends TestCase
|
||||
$this->assertEqualsCanonicalizing(['1', '2'], Arr::pluck($data, 'id'), 'IDs do not match');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function created_filter_works_with_range()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -173,9 +162,7 @@ class ListTest extends TestCase
|
||||
$this->assertEqualsCanonicalizing(['2', '3'], Arr::pluck($data, 'id'), 'IDs do not match');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function created_filter_works_negated_with_range()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -192,9 +179,7 @@ class ListTest extends TestCase
|
||||
$this->assertEquals(['1'], Arr::pluck($data, 'id'), 'IDs do not match');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function hidden_filter_works()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -211,9 +196,7 @@ class ListTest extends TestCase
|
||||
$this->assertEquals(['4'], Arr::pluck($data, 'id'), 'IDs do not match');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function hidden_filter_works_negated()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -230,9 +213,7 @@ class ListTest extends TestCase
|
||||
$this->assertEqualsCanonicalizing(['1', '2', '3'], Arr::pluck($data, 'id'), 'IDs do not match');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function unread_filter_works()
|
||||
{
|
||||
$this->app();
|
||||
@@ -252,9 +233,7 @@ class ListTest extends TestCase
|
||||
$this->assertEquals(['3'], Arr::pluck($data, 'id'), 'IDs do not match');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function unread_filter_works_when_negated()
|
||||
{
|
||||
$this->app();
|
||||
|
@@ -15,6 +15,7 @@ use Flarum\Post\Post;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Illuminate\Support\Arr;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class ListWithFulltextSearchTest extends TestCase
|
||||
{
|
||||
@@ -68,9 +69,7 @@ class ListWithFulltextSearchTest extends TestCase
|
||||
$this->database()->table('posts')->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function can_search_for_word_or_title_in_post()
|
||||
{
|
||||
if ($this->database()->getDriverName() === 'sqlite') {
|
||||
@@ -96,9 +95,7 @@ class ListWithFulltextSearchTest extends TestCase
|
||||
$this->assertEqualsCanonicalizing(['2', '1', '3'], $ids, 'IDs do not match');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function ignores_non_word_characters_when_searching()
|
||||
{
|
||||
if ($this->database()->getDriverName() === 'sqlite') {
|
||||
@@ -121,9 +118,7 @@ class ListWithFulltextSearchTest extends TestCase
|
||||
$this->assertEqualsCanonicalizing(['2', '1', '3'], $ids, 'IDs do not match');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function can_search_telugu_like_languages()
|
||||
{
|
||||
if ($this->database()->getDriverName() === 'sqlite') {
|
||||
@@ -147,9 +142,7 @@ class ListWithFulltextSearchTest extends TestCase
|
||||
$this->assertEqualsCanonicalizing(['6'], Arr::pluck($data['included'], 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function can_search_cjk_languages()
|
||||
{
|
||||
if ($this->database()->getDriverName() === 'sqlite') {
|
||||
@@ -173,9 +166,7 @@ class ListWithFulltextSearchTest extends TestCase
|
||||
$this->assertEqualsCanonicalizing(['7'], Arr::pluck($data['included'], 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function search_for_special_characters_gives_empty_result()
|
||||
{
|
||||
if ($this->database()->getDriverName() === 'sqlite') {
|
||||
|
@@ -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 ShowTest extends TestCase
|
||||
{
|
||||
@@ -45,9 +46,7 @@ class ShowTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function author_can_see_discussion()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -59,9 +58,7 @@ class ShowTest extends TestCase
|
||||
$this->assertEquals(200, $response->getStatusCode(), $response->getBody()->getContents());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function author_can_see_discussion_via_slug()
|
||||
{
|
||||
// Note that here, the slug doesn't actually have to match the real slug
|
||||
@@ -77,9 +74,7 @@ class ShowTest extends TestCase
|
||||
$this->assertEquals(200, $response->getStatusCode(), $response->getBody()->getContents());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function guest_cannot_see_empty_discussion()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -89,9 +84,7 @@ class ShowTest extends TestCase
|
||||
$this->assertEquals(404, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function guest_cannot_see_hidden_posts()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -103,9 +96,7 @@ class ShowTest extends TestCase
|
||||
$this->assertEmpty(Arr::get($json, 'data.relationships.posts.data'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function author_can_see_hidden_posts()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -119,9 +110,7 @@ class ShowTest extends TestCase
|
||||
$this->assertEquals(2, Arr::get($json, 'data.relationships.posts.data.0.id'), $response->getBody()->getContents());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function guest_can_see_discussion()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -131,9 +120,7 @@ class ShowTest extends TestCase
|
||||
$this->assertEquals(200, $response->getStatusCode(), $response->getBody()->getContents());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function guests_cannot_see_private_discussion()
|
||||
{
|
||||
$response = $this->send(
|
||||
|
@@ -13,6 +13,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 ShowTest extends TestCase
|
||||
{
|
||||
@@ -32,9 +33,7 @@ class ShowTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function guest_user_does_not_see_actor_relationship()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -49,9 +48,7 @@ class ShowTest extends TestCase
|
||||
$this->assertNull(Arr::get($json, 'data.relationships.actor.data'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function normal_user_sees_most_information()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -73,9 +70,7 @@ class ShowTest extends TestCase
|
||||
$this->assertEquals(2, Arr::get($json, 'data.relationships.actor.data.id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function admin_user_sees_even_more()
|
||||
{
|
||||
$response = $this->send(
|
||||
|
@@ -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
|
||||
{
|
||||
@@ -33,9 +34,7 @@ class CreateTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function admin_cannot_create_group_without_data()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -48,9 +47,7 @@ class CreateTest extends TestCase
|
||||
$this->assertEquals(400, $response->getStatusCode(), (string) $response->getBody());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function admin_can_create_group()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -89,9 +86,7 @@ class CreateTest extends TestCase
|
||||
$this->assertNull($group->color);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function normal_user_cannot_create_group()
|
||||
{
|
||||
$response = $this->send(
|
||||
|
@@ -13,6 +13,7 @@ use Flarum\Group\Group;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Illuminate\Support\Arr;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class ListTest extends TestCase
|
||||
{
|
||||
@@ -32,9 +33,7 @@ class ListTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shows_limited_index_for_guest()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -48,9 +47,7 @@ class ListTest extends TestCase
|
||||
$this->assertEquals(['1', '2', '3', '4'], Arr::pluck($data['data'], 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shows_index_for_admin()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -66,9 +63,7 @@ class ListTest extends TestCase
|
||||
$this->assertEquals(['1', '2', '3', '4', '10'], Arr::pluck($data['data'], 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function filters_only_public_groups_for_admin()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -87,9 +82,7 @@ class ListTest extends TestCase
|
||||
$this->assertEquals(['1', '2', '3', '4'], Arr::pluck($data['data'], 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function filters_only_hidden_groups_for_admin()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -108,9 +101,7 @@ class ListTest extends TestCase
|
||||
$this->assertEquals(['10'], Arr::pluck($data['data'], 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function filters_only_public_groups_for_guest()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -127,9 +118,7 @@ class ListTest extends TestCase
|
||||
$this->assertEquals(['1', '2', '3', '4'], Arr::pluck($data['data'], 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function hides_hidden_groups_when_filtering_for_guest()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -147,9 +136,7 @@ class ListTest extends TestCase
|
||||
$this->assertEquals([], Arr::pluck($data['data'], 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function paginates_groups_without_filter()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -166,9 +153,7 @@ class ListTest extends TestCase
|
||||
$this->assertEquals(['3', '4'], Arr::pluck($data['data'], 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function paginates_groups_with_filter()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -187,9 +172,7 @@ class ListTest extends TestCase
|
||||
$this->assertEmpty($data['data']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function sorts_groups_by_name()
|
||||
{
|
||||
$response = $this->send(
|
||||
|
@@ -13,6 +13,7 @@ use Flarum\Group\Group;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Illuminate\Support\Arr;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class ShowTest extends TestCase
|
||||
{
|
||||
@@ -32,9 +33,7 @@ class ShowTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shows_public_group_for_guest()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -48,9 +47,7 @@ class ShowTest extends TestCase
|
||||
$this->assertEquals('1', Arr::get($data, 'data.id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shows_public_group_for_admin()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -66,9 +63,7 @@ class ShowTest extends TestCase
|
||||
$this->assertEquals('1', Arr::get($data, 'data.id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function hides_hidden_group_for_guest()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -79,9 +74,7 @@ class ShowTest extends TestCase
|
||||
$this->assertEquals(404, $response->getStatusCode(), (string) $response->getBody());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shows_hidden_group_for_admin()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -97,9 +90,7 @@ class ShowTest extends TestCase
|
||||
$this->assertEquals('10', Arr::get($data, 'data.id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function rejects_request_for_non_existing_group()
|
||||
{
|
||||
$response = $this->send(
|
||||
|
@@ -14,6 +14,8 @@ use Flarum\Discussion\Discussion;
|
||||
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 DeleteTest extends TestCase
|
||||
{
|
||||
@@ -45,10 +47,8 @@ class DeleteTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider canDeleteAllNotifications
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('canDeleteAllNotifications')]
|
||||
public function user_can_delete_all_notifications(int $authenticatedAs)
|
||||
{
|
||||
$this->app();
|
||||
@@ -63,7 +63,7 @@ class DeleteTest extends TestCase
|
||||
$this->assertEquals(0, User::query()->find($authenticatedAs)->notifications()->count());
|
||||
}
|
||||
|
||||
public function canDeleteAllNotifications(): array
|
||||
public static function canDeleteAllNotifications(): array
|
||||
{
|
||||
return [
|
||||
[1],
|
||||
|
@@ -12,6 +12,7 @@ namespace Flarum\Tests\integration\api\notifications;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Flarum\User\User;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class ListTest extends TestCase
|
||||
{
|
||||
@@ -31,9 +32,7 @@ class ListTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function disallows_index_for_guest()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -43,9 +42,7 @@ class ListTest extends TestCase
|
||||
$this->assertEquals(401, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shows_index_for_user()
|
||||
{
|
||||
$response = $this->send(
|
||||
|
@@ -16,6 +16,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 UpdateTest extends TestCase
|
||||
{
|
||||
@@ -44,9 +45,7 @@ class UpdateTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function can_mark_all_as_read()
|
||||
{
|
||||
$response = $this->send(
|
||||
|
@@ -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 CreateTest extends TestCase
|
||||
{
|
||||
@@ -53,10 +55,8 @@ class CreateTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider discussionRepliesPrvider
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('discussionRepliesPrvider')]
|
||||
public function can_create_reply_if_allowed(int $actorId, int $discussionId, int $responseStatus)
|
||||
{
|
||||
// Reset permissions for normal users group.
|
||||
@@ -88,7 +88,7 @@ class CreateTest extends TestCase
|
||||
$this->assertEquals($responseStatus, $response->getStatusCode(), (string) $response->getBody());
|
||||
}
|
||||
|
||||
public function discussionRepliesPrvider(): array
|
||||
public static function discussionRepliesPrvider(): array
|
||||
{
|
||||
return [
|
||||
// [$actorId, $discussionId, $responseStatus]
|
||||
@@ -99,9 +99,7 @@ class CreateTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function limited_by_throttler()
|
||||
{
|
||||
$response = $this->send(
|
||||
|
@@ -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 DeleteTest extends TestCase
|
||||
{
|
||||
@@ -52,10 +54,8 @@ class DeleteTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider deleteLastPostsProvider
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('deleteLastPostsProvider')]
|
||||
public function deleting_last_posts_syncs_discussion_state_for_other_users(array $postIds, int $newLastReadNumber, int $userId)
|
||||
{
|
||||
// Delete the last post.
|
||||
@@ -76,7 +76,7 @@ class DeleteTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function deleteLastPostsProvider(): array
|
||||
public static function deleteLastPostsProvider(): array
|
||||
{
|
||||
return [
|
||||
// User 2
|
||||
|
@@ -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 ListTest extends TestCase
|
||||
{
|
||||
@@ -48,9 +49,7 @@ class ListTest extends TestCase
|
||||
$this->database()->table('group_permission')->where('permission', 'viewForum')->where('group_id', 2)->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function guests_cant_see_anything_if_not_allowed()
|
||||
{
|
||||
$this->forbidGuestsFromSeeingForum();
|
||||
@@ -65,9 +64,7 @@ class ListTest extends TestCase
|
||||
$this->assertEqualsCanonicalizing([], $data['data']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function authorized_users_can_see_posts()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -82,9 +79,7 @@ class ListTest extends TestCase
|
||||
$this->assertEquals(5, count($data['data']));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function author_filter_works()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -100,9 +95,7 @@ class ListTest extends TestCase
|
||||
$this->assertEqualsCanonicalizing(['1', '2'], Arr::pluck($data['data'], 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function author_filter_works_with_multiple_values()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -118,9 +111,7 @@ class ListTest extends TestCase
|
||||
$this->assertEqualsCanonicalizing(['1', '2', '3', '4', '5'], Arr::pluck($data['data'], 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function discussion_filter_works()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -136,9 +127,7 @@ class ListTest extends TestCase
|
||||
$this->assertEqualsCanonicalizing(['1', '3'], Arr::pluck($data['data'], 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function type_filter_works()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -154,9 +143,7 @@ class ListTest extends TestCase
|
||||
$this->assertEqualsCanonicalizing(['5'], Arr::pluck($data['data'], 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function number_filter_works()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -172,9 +159,7 @@ class ListTest extends TestCase
|
||||
$this->assertEqualsCanonicalizing(['3', '4'], Arr::pluck($data['data'], 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function id_filter_works()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -190,9 +175,7 @@ class ListTest extends TestCase
|
||||
$this->assertEqualsCanonicalizing(['4'], Arr::pluck($data['data'], 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function id_filter_works_with_multiple_ids()
|
||||
{
|
||||
$response = $this->send(
|
||||
|
@@ -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 ShowTest extends TestCase
|
||||
{
|
||||
@@ -41,9 +42,7 @@ class ShowTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function properly_formatted_post_rendered_correctly()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -62,9 +61,7 @@ class ShowTest extends TestCase
|
||||
$this->assertEquals($data['data']['attributes']['contentHtml'], '<p>valid</p>');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function malformed_post_caught_by_renderer()
|
||||
{
|
||||
$response = $this->send(
|
||||
|
@@ -12,6 +12,7 @@ namespace Flarum\Tests\integration\api\settings;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Flarum\User\User;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class SetTest extends TestCase
|
||||
{
|
||||
@@ -31,9 +32,7 @@ class SetTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function settings_cant_be_updated_by_user()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -49,9 +48,7 @@ class SetTest extends TestCase
|
||||
$this->assertNotEquals('world', $this->app->getContainer()->make('flarum.settings')->get('hello'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function settings_can_be_updated_by_admin()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -67,9 +64,7 @@ class SetTest extends TestCase
|
||||
$this->assertEquals('world', $this->app->getContainer()->make('flarum.settings')->get('hello'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function max_setting_length_validated()
|
||||
{
|
||||
$response = $this->send(
|
||||
|
@@ -14,6 +14,7 @@ use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Flarum\User\RegistrationToken;
|
||||
use Flarum\User\User;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class CreateTest extends TestCase
|
||||
{
|
||||
@@ -29,9 +30,7 @@ class CreateTest extends TestCase
|
||||
$this->setting('mail_driver', 'log');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function cannot_create_user_without_data()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -77,9 +76,7 @@ class CreateTest extends TestCase
|
||||
], json_decode($body, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function can_create_user()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -110,9 +107,7 @@ class CreateTest extends TestCase
|
||||
$this->assertEquals('test@machine.local', $user->email);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function admins_can_create_activated_users()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -143,9 +138,7 @@ class CreateTest extends TestCase
|
||||
$this->assertEquals(1, $user->is_email_confirmed);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function disabling_sign_up_prevents_user_creation()
|
||||
{
|
||||
/** @var SettingsRepositoryInterface $settings */
|
||||
@@ -174,9 +167,7 @@ class CreateTest extends TestCase
|
||||
$settings->set('allow_sign_up', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function cannot_create_user_with_invalid_avatar_uri_scheme()
|
||||
{
|
||||
// Boot app
|
||||
@@ -240,9 +231,7 @@ class CreateTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function cannot_create_user_with_invalid_avatar_uri()
|
||||
{
|
||||
// Boot app
|
||||
@@ -314,9 +303,7 @@ class CreateTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function can_create_user_with_valid_avatar_uri()
|
||||
{
|
||||
// Boot app
|
||||
|
@@ -12,6 +12,8 @@ namespace integration\api\users;
|
||||
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 DeleteTest extends TestCase
|
||||
{
|
||||
@@ -33,10 +35,8 @@ class DeleteTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider authorizedUsersProvider
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('authorizedUsersProvider')]
|
||||
public function can_delete_user(int $actorId, int $userId)
|
||||
{
|
||||
$this->database()->table('group_permission')->insert([
|
||||
@@ -54,7 +54,7 @@ class DeleteTest extends TestCase
|
||||
$this->assertNull(User::find($userId));
|
||||
}
|
||||
|
||||
public function authorizedUsersProvider()
|
||||
public static function authorizedUsersProvider()
|
||||
{
|
||||
return [
|
||||
'admin can delete user' => [1, 2],
|
||||
@@ -63,10 +63,8 @@ class DeleteTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider unauthorizedUsersProvider
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('unauthorizedUsersProvider')]
|
||||
public function cannot_delete_user(int $actorId, int $userId)
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -79,7 +77,7 @@ class DeleteTest extends TestCase
|
||||
$this->assertNotNull(User::find($userId));
|
||||
}
|
||||
|
||||
public function unauthorizedUsersProvider()
|
||||
public static function unauthorizedUsersProvider()
|
||||
{
|
||||
return [
|
||||
'user without permission cannot delete self' => [2, 2],
|
||||
|
@@ -13,6 +13,7 @@ use Flarum\Group\Group;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Flarum\User\User;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class GroupSearchTest extends TestCase
|
||||
{
|
||||
@@ -29,9 +30,7 @@ class GroupSearchTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function disallows_group_filter_for_user_without_permission()
|
||||
{
|
||||
$response = $this->createRequest(['admin']);
|
||||
@@ -39,9 +38,7 @@ class GroupSearchTest extends TestCase
|
||||
$this->assertEquals(403, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function allows_group_filter_for_admin()
|
||||
{
|
||||
$response = $this->createRequest(['admin'], 1);
|
||||
@@ -49,9 +46,7 @@ class GroupSearchTest extends TestCase
|
||||
$this->assertEquals(200, $response->getStatusCode(), $response->getBody()->getContents());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function allows_group_filter_for_user_with_permission()
|
||||
{
|
||||
$this->prepareDatabase([
|
||||
@@ -64,9 +59,7 @@ class GroupSearchTest extends TestCase
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function non_admin_gets_correct_results()
|
||||
{
|
||||
$this->prepareDatabase([
|
||||
@@ -115,9 +108,7 @@ class GroupSearchTest extends TestCase
|
||||
$this->assertCount(0, $responseBodyContents['included'], json_encode($responseBodyContents));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function non_admin_cannot_see_hidden_groups()
|
||||
{
|
||||
$this->prepareDatabase([
|
||||
@@ -134,9 +125,7 @@ class GroupSearchTest extends TestCase
|
||||
$this->assertCount(0, $responseBodyContents['included'], json_encode($responseBodyContents));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function non_admin_can_select_multiple_groups_but_not_hidden()
|
||||
{
|
||||
$this->prepareDatabase([
|
||||
@@ -153,9 +142,7 @@ class GroupSearchTest extends TestCase
|
||||
$this->assertEqualsCanonicalizing([1, 4, 5, 6], array_column($responseBodyContents['included'], 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function admin_gets_correct_results_group()
|
||||
{
|
||||
$response = $this->createRequest(['admin'], 1);
|
||||
@@ -198,9 +185,7 @@ class GroupSearchTest extends TestCase
|
||||
$this->assertCount(0, $responseBodyContents['included'], json_encode($responseBodyContents));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function admin_can_see_hidden_groups()
|
||||
{
|
||||
$this->createHiddenUser();
|
||||
@@ -212,9 +197,7 @@ class GroupSearchTest extends TestCase
|
||||
$this->assertEquals(99, $responseBodyContents['included'][0]['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function admin_can_select_multiple_groups_and_hidden()
|
||||
{
|
||||
$this->createMultipleUsersAndGroups();
|
||||
|
@@ -13,6 +13,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 ListTest extends TestCase
|
||||
{
|
||||
@@ -32,9 +33,7 @@ class ListTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function disallows_index_for_guest()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -44,9 +43,7 @@ class ListTest extends TestCase
|
||||
$this->assertEquals(403, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shows_index_for_guest_when_they_have_permission()
|
||||
{
|
||||
$this->prepareDatabase([
|
||||
@@ -62,9 +59,7 @@ class ListTest extends TestCase
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shows_index_for_admin()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -76,9 +71,7 @@ class ListTest extends TestCase
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shows_full_results_without_search_or_filter()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -92,9 +85,7 @@ class ListTest extends TestCase
|
||||
$this->assertEqualsCanonicalizing(['1', '2'], Arr::pluck($data, 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function allows_last_seen_sorting_with_permission()
|
||||
{
|
||||
$this->prepareDatabase([
|
||||
@@ -114,9 +105,7 @@ class ListTest extends TestCase
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function disallows_last_seen_sorting_without_permission()
|
||||
{
|
||||
$this->prepareDatabase([
|
||||
@@ -135,9 +124,7 @@ class ListTest extends TestCase
|
||||
$this->assertEquals(400, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function group_filter_works()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -153,9 +140,7 @@ class ListTest extends TestCase
|
||||
$this->assertEquals(['1'], Arr::pluck($data, 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function group_filter_works_negated()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -171,9 +156,7 @@ class ListTest extends TestCase
|
||||
$this->assertEquals(['2'], Arr::pluck($data, 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function email_filter_works()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -189,9 +172,7 @@ class ListTest extends TestCase
|
||||
$this->assertEquals(['1'], Arr::pluck($data, 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function email_filter_works_negated()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -207,9 +188,7 @@ class ListTest extends TestCase
|
||||
$this->assertEquals(['2'], Arr::pluck($data, 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function email_filter_only_works_for_admin()
|
||||
{
|
||||
$response = $this->send(
|
||||
|
@@ -14,6 +14,7 @@ use Flarum\Testing\integration\TestCase;
|
||||
use Flarum\User\EmailToken;
|
||||
use Flarum\User\PasswordToken;
|
||||
use Flarum\User\User;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class PasswordEmailTokensTest extends TestCase
|
||||
{
|
||||
@@ -30,7 +31,7 @@ class PasswordEmailTokensTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function actor_has_no_tokens_by_default()
|
||||
{
|
||||
$this->app();
|
||||
@@ -39,7 +40,7 @@ class PasswordEmailTokensTest extends TestCase
|
||||
$this->assertEquals(0, EmailToken::query()->where('user_id', 2)->count());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function password_tokens_are_generated_when_requesting_password_reset()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -55,7 +56,7 @@ class PasswordEmailTokensTest extends TestCase
|
||||
$this->assertEquals(1, PasswordToken::query()->where('user_id', 2)->count());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function password_tokens_are_deleted_after_password_reset()
|
||||
{
|
||||
$this->app();
|
||||
@@ -94,7 +95,7 @@ class PasswordEmailTokensTest extends TestCase
|
||||
$this->assertEquals(0, PasswordToken::query()->where('user_id', 2)->count());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function email_tokens_are_generated_when_requesting_email_change()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -118,7 +119,7 @@ class PasswordEmailTokensTest extends TestCase
|
||||
$this->assertEquals(1, EmailToken::query()->where('user_id', 2)->count());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function email_tokens_are_deleted_when_confirming_email()
|
||||
{
|
||||
$this->app();
|
||||
@@ -140,7 +141,7 @@ class PasswordEmailTokensTest extends TestCase
|
||||
$this->assertEquals(0, EmailToken::query()->where('user_id', 2)->count());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function email_tokens_are_deleted_after_password_reset()
|
||||
{
|
||||
$this->app();
|
||||
@@ -179,7 +180,7 @@ class PasswordEmailTokensTest extends TestCase
|
||||
$this->assertEquals(0, EmailToken::query()->where('user_id', 2)->count());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function password_tokens_are_deleted_when_confirming_email()
|
||||
{
|
||||
$this->app();
|
||||
|
@@ -13,6 +13,7 @@ use Carbon\Carbon;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Flarum\User\Throttler\EmailActivationThrottler;
|
||||
use Flarum\User\User;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class SendActivationEmailTest extends TestCase
|
||||
{
|
||||
@@ -34,7 +35,7 @@ class SendActivationEmailTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function users_can_send_confirmation_emails_in_moderate_intervals()
|
||||
{
|
||||
for ($i = 0; $i < 2; $i++) {
|
||||
@@ -52,7 +53,7 @@ class SendActivationEmailTest extends TestCase
|
||||
$this->assertEquals(204, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function users_cant_send_confirmation_emails_too_fast()
|
||||
{
|
||||
for ($i = 0; $i < 2; $i++) {
|
||||
|
@@ -13,6 +13,7 @@ use Carbon\Carbon;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Flarum\User\Throttler\PasswordResetThrottler;
|
||||
use Flarum\User\User;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class SendPasswordResetEmailTest extends TestCase
|
||||
{
|
||||
@@ -34,7 +35,7 @@ class SendPasswordResetEmailTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function users_can_send_password_reset_emails_in_moderate_intervals()
|
||||
{
|
||||
for ($i = 0; $i < 2; $i++) {
|
||||
@@ -55,7 +56,7 @@ class SendPasswordResetEmailTest extends TestCase
|
||||
$this->assertEquals(204, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function users_cant_send_confirmation_emails_too_fast()
|
||||
{
|
||||
for ($i = 0; $i < 2; $i++) {
|
||||
@@ -72,7 +73,7 @@ class SendPasswordResetEmailTest extends TestCase
|
||||
$this->assertEquals(429, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function request_password_reset_does_not_leak_user_existence()
|
||||
{
|
||||
$response = $this->send(
|
||||
|
@@ -12,6 +12,7 @@ namespace Flarum\Tests\integration\api\users;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Flarum\User\User;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class ShowTest extends TestCase
|
||||
{
|
||||
@@ -41,9 +42,7 @@ class ShowTest extends TestCase
|
||||
$this->database()->table('group_permission')->where('permission', 'searchUsers')->where('group_id', 3)->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function admin_can_see_user()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -55,9 +54,7 @@ class ShowTest extends TestCase
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function admin_can_see_user_via_slug()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -71,9 +68,7 @@ class ShowTest extends TestCase
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function guest_can_see_user_by_default()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -83,9 +78,7 @@ class ShowTest extends TestCase
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function guest_can_see_user_by_slug_by_default()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -97,9 +90,7 @@ class ShowTest extends TestCase
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function guest_cant_see_user_if_blocked()
|
||||
{
|
||||
$this->forbidGuestsFromSeeingForum();
|
||||
@@ -111,9 +102,7 @@ class ShowTest extends TestCase
|
||||
$this->assertEquals(404, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function guest_cant_see_user_by_slug_if_blocked()
|
||||
{
|
||||
$this->forbidGuestsFromSeeingForum();
|
||||
@@ -127,9 +116,7 @@ class ShowTest extends TestCase
|
||||
$this->assertEquals(404, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function user_can_see_themselves()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -141,9 +128,7 @@ class ShowTest extends TestCase
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function user_can_see_themselves_via_slug()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -157,9 +142,7 @@ class ShowTest extends TestCase
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function user_can_see_others_by_default()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -171,9 +154,7 @@ class ShowTest extends TestCase
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function user_can_see_others_by_default_via_slug()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -187,9 +168,7 @@ class ShowTest extends TestCase
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function user_can_still_see_others_via_slug_even_if_cant_search()
|
||||
{
|
||||
$this->forbidMembersFromSearchingUsers();
|
||||
|
@@ -14,6 +14,7 @@ use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Flarum\User\Throttler\EmailChangeThrottler;
|
||||
use Flarum\User\User;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class UpdateTest extends TestCase
|
||||
{
|
||||
@@ -60,9 +61,7 @@ class UpdateTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function users_can_see_their_private_information()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -79,9 +78,7 @@ class UpdateTest extends TestCase
|
||||
$this->assertStringContainsString('normal@machine.local', $body);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function users_can_not_see_other_users_private_information()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -99,10 +96,9 @@ class UpdateTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* This tests the generic user.edit permission used for non-credential/group attributes
|
||||
* This tests the generic user.edit permission used for non-credential/group attributes.
|
||||
*/
|
||||
#[Test]
|
||||
public function users_can_update_own_avatar()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -114,9 +110,7 @@ class UpdateTest extends TestCase
|
||||
$this->assertEquals(200, $response->getStatusCode(), (string) $response->getBody());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function users_cant_update_own_email_if_password_wrong()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -139,9 +133,7 @@ class UpdateTest extends TestCase
|
||||
$this->assertEquals(401, $response->getStatusCode(), (string) $response->getBody());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function users_can_update_own_email()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -163,9 +155,7 @@ class UpdateTest extends TestCase
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function users_can_request_email_change_in_moderate_intervals()
|
||||
{
|
||||
for ($i = 0; $i < 2; $i++) {
|
||||
@@ -193,9 +183,7 @@ class UpdateTest extends TestCase
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function users_cant_request_email_change_too_fast()
|
||||
{
|
||||
for ($i = 0; $i < 2; $i++) {
|
||||
@@ -219,9 +207,7 @@ class UpdateTest extends TestCase
|
||||
$this->assertEquals(429, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function users_cant_update_own_username()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -240,9 +226,7 @@ class UpdateTest extends TestCase
|
||||
$this->assertEquals(403, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function users_can_update_own_preferences()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -263,9 +247,7 @@ class UpdateTest extends TestCase
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function users_cant_update_own_groups()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -287,9 +269,7 @@ class UpdateTest extends TestCase
|
||||
$this->assertEquals(403, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function users_can_update_marked_all_as_read()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -308,9 +288,7 @@ class UpdateTest extends TestCase
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function users_cant_activate_themselves()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -330,10 +308,9 @@ class UpdateTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* This tests the generic user.edit permission used for non-credential/group attributes
|
||||
* This tests the generic user.edit permission used for non-credential/group attributes.
|
||||
*/
|
||||
#[Test]
|
||||
public function users_cant_update_others_avatars_without_permission()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -345,9 +322,7 @@ class UpdateTest extends TestCase
|
||||
$this->assertEquals(403, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function users_cant_update_others_emails_without_permission()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -369,9 +344,7 @@ class UpdateTest extends TestCase
|
||||
$this->assertEquals(403, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function users_cant_update_others_usernames_without_permission()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -390,9 +363,7 @@ class UpdateTest extends TestCase
|
||||
$this->assertEquals(403, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function users_cant_update_others_groups_without_permission()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -414,9 +385,7 @@ class UpdateTest extends TestCase
|
||||
$this->assertEquals(403, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function users_cant_activate_others_without_permission()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -436,10 +405,9 @@ class UpdateTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* This tests the generic user.edit permission used for non-credential/group attributes
|
||||
* This tests the generic user.edit permission used for non-credential/group attributes.
|
||||
*/
|
||||
#[Test]
|
||||
public function users_can_update_others_avatars_with_permissions()
|
||||
{
|
||||
$this->giveNormalUsersEditPerms();
|
||||
@@ -452,9 +420,7 @@ class UpdateTest extends TestCase
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function users_can_update_others_emails_with_permission()
|
||||
{
|
||||
$this->giveNormalUsersEditPerms();
|
||||
@@ -474,9 +440,7 @@ class UpdateTest extends TestCase
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function users_can_update_others_usernames_with_permission()
|
||||
{
|
||||
$this->giveNormalUsersEditPerms();
|
||||
@@ -496,9 +460,7 @@ class UpdateTest extends TestCase
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function users_cant_update_admin_emails_with_permission()
|
||||
{
|
||||
$this->giveNormalUsersEditPerms();
|
||||
@@ -518,9 +480,7 @@ class UpdateTest extends TestCase
|
||||
$this->assertEquals(403, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function users_cant_update_admin_usernames_with_permission()
|
||||
{
|
||||
$this->giveNormalUsersEditPerms();
|
||||
@@ -540,9 +500,7 @@ class UpdateTest extends TestCase
|
||||
$this->assertEquals(403, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function users_can_update_others_groups_with_permission()
|
||||
{
|
||||
$this->giveNormalUsersEditPerms();
|
||||
@@ -565,9 +523,7 @@ class UpdateTest extends TestCase
|
||||
$this->assertEquals(200, $response->getStatusCode(), (string) $response->getBody());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function regular_users_cant_demote_admins_even_with_permission()
|
||||
{
|
||||
$this->giveNormalUsersEditPerms();
|
||||
@@ -588,9 +544,7 @@ class UpdateTest extends TestCase
|
||||
$this->assertEquals(403, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function regular_users_cant_promote_others_to_admin_even_with_permission()
|
||||
{
|
||||
$this->giveNormalUsersEditPerms();
|
||||
@@ -613,9 +567,7 @@ class UpdateTest extends TestCase
|
||||
$this->assertEquals(403, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function regular_users_cant_promote_self_to_admin_even_with_permission()
|
||||
{
|
||||
$this->giveNormalUsersEditPerms();
|
||||
@@ -638,9 +590,7 @@ class UpdateTest extends TestCase
|
||||
$this->assertEquals(403, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function users_cant_activate_others_even_with_permissions()
|
||||
{
|
||||
$this->giveNormalUsersEditPerms();
|
||||
@@ -660,9 +610,7 @@ class UpdateTest extends TestCase
|
||||
$this->assertEquals(403, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function admins_cant_update_others_preferences()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -683,9 +631,7 @@ class UpdateTest extends TestCase
|
||||
$this->assertEquals(403, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function admins_cant_update_marked_all_as_read()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -704,9 +650,7 @@ class UpdateTest extends TestCase
|
||||
$this->assertEquals(403, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function admins_can_activate_others()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -725,9 +669,7 @@ class UpdateTest extends TestCase
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function admins_cant_demote_self()
|
||||
{
|
||||
$this->giveNormalUsersEditPerms();
|
||||
@@ -748,9 +690,7 @@ class UpdateTest extends TestCase
|
||||
$this->assertEquals(403, $response->getStatusCode(), (string) $response->getBody());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function last_seen_not_updated_quickly()
|
||||
{
|
||||
$this->app();
|
||||
@@ -769,9 +709,7 @@ class UpdateTest extends TestCase
|
||||
$this->assertTrue(Carbon::parse($last_seen)->equalTo($user->last_seen_at));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function last_seen_updated_after_long_time()
|
||||
{
|
||||
$this->app();
|
||||
|
@@ -26,6 +26,7 @@ use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Flarum\User\User;
|
||||
use Illuminate\Support\Arr;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tobyz\JsonApiServer\Schema\Field\Field;
|
||||
|
||||
class ApiControllerTest extends TestCase
|
||||
@@ -57,9 +58,7 @@ class ApiControllerTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function after_endpoint_callback_works_if_added()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -84,9 +83,7 @@ class ApiControllerTest extends TestCase
|
||||
$this->assertEquals('dataSerializationPrepCustomTitle', $payload['data']['attributes']['title'], $body);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function after_endpoint_callback_works_with_invokable_classes()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -107,9 +104,7 @@ class ApiControllerTest extends TestCase
|
||||
$this->assertEquals(CustomAfterEndpointInvokableClass::class, $payload['data']['attributes']['title'], $body);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function after_endpoint_callback_works_if_added_to_parent_class()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -136,9 +131,7 @@ class ApiControllerTest extends TestCase
|
||||
$this->assertEquals('dataSerializationPrepCustomTitle2', $payload['data']['attributes']['title']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function after_endpoint_callback_prioritizes_child_classes()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -173,9 +166,7 @@ class ApiControllerTest extends TestCase
|
||||
$this->assertEquals('dataSerializationPrepCustomTitle4', $payload['data']['attributes']['title'], $body);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function before_endpoint_callback_works_if_added_to_parent_class()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -199,9 +190,7 @@ class ApiControllerTest extends TestCase
|
||||
$this->assertStringContainsString('error on purpose', $body, $body);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function before_endpoint_callback_prioritizes_child_classes()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -231,9 +220,7 @@ class ApiControllerTest extends TestCase
|
||||
$this->assertStringContainsString('error on purpose from abstract resource', $body, $body);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_relationship_not_included_by_default()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -248,9 +235,7 @@ class ApiControllerTest extends TestCase
|
||||
$this->assertArrayNotHasKey('customApiControllerRelation2', $payload['data']['relationships']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_relationship_included_if_added()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -278,9 +263,7 @@ class ApiControllerTest extends TestCase
|
||||
$this->assertArrayHasKey('customApiControllerRelation', $payload['data']['relationships'] ?? [], $body);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_relationship_optionally_included_if_added()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -307,9 +290,7 @@ class ApiControllerTest extends TestCase
|
||||
$this->assertArrayHasKey('customApiControllerRelation2', $payload['data']['relationships'] ?? []);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_relationship_included_by_default()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -323,9 +304,7 @@ class ApiControllerTest extends TestCase
|
||||
$this->assertArrayHasKey('groups', $payload['data']['relationships']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_relationship_not_included_if_removed()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -346,9 +325,7 @@ class ApiControllerTest extends TestCase
|
||||
$this->assertArrayNotHasKey('groups', Arr::get($payload, 'data.relationships', []));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_relationship_not_optionally_included_if_removed()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -374,9 +351,7 @@ class ApiControllerTest extends TestCase
|
||||
$this->assertEquals(400, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_limit_doesnt_work_by_default()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -390,9 +365,7 @@ class ApiControllerTest extends TestCase
|
||||
$this->assertCount(3, $payload['data']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_limit_works_if_set()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -413,9 +386,7 @@ class ApiControllerTest extends TestCase
|
||||
$this->assertCount(1, $payload['data']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_max_limit_works_if_set()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -438,9 +409,7 @@ class ApiControllerTest extends TestCase
|
||||
$this->assertCount(1, $payload['data']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_sort_field_doesnt_exist_by_default()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -454,9 +423,7 @@ class ApiControllerTest extends TestCase
|
||||
$this->assertEquals(400, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_sort_field_exists_if_added()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -480,9 +447,7 @@ class ApiControllerTest extends TestCase
|
||||
$this->assertEquals([3, 1, 2], Arr::pluck($payload['data'], 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_sort_field_exists_by_default()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -496,9 +461,7 @@ class ApiControllerTest extends TestCase
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_sort_field_doesnt_exist_if_removed()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -517,9 +480,7 @@ class ApiControllerTest extends TestCase
|
||||
$this->assertEquals(400, $response->getStatusCode(), $response->getBody()->getContents());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_sort_field_works_if_set()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -544,9 +505,7 @@ class ApiControllerTest extends TestCase
|
||||
$this->assertEquals([2, 1, 3], Arr::pluck($payload['data'], 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_first_level_relation_is_not_loaded_by_default()
|
||||
{
|
||||
$users = null;
|
||||
@@ -573,9 +532,7 @@ class ApiControllerTest extends TestCase
|
||||
$this->assertTrue($users->filter->relationLoaded('firstLevelRelation')->isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_first_level_relation_is_loaded_if_added()
|
||||
{
|
||||
$users = null;
|
||||
@@ -604,9 +561,7 @@ class ApiControllerTest extends TestCase
|
||||
$this->assertFalse($users->filter->relationLoaded('firstLevelRelation')->isEmpty(), $response->getBody()->getContents());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_second_level_relation_is_not_loaded_by_default()
|
||||
{
|
||||
$users = null;
|
||||
@@ -634,9 +589,7 @@ class ApiControllerTest extends TestCase
|
||||
$this->assertTrue($users->pluck('firstLevelRelation')->filter->relationLoaded('secondLevelRelation')->isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_second_level_relation_is_loaded_if_added()
|
||||
{
|
||||
$users = null;
|
||||
@@ -667,9 +620,7 @@ class ApiControllerTest extends TestCase
|
||||
$this->assertFalse($users->pluck('firstLevelRelation')->filter->relationLoaded('secondLevelRelation')->isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_second_level_relation_is_not_loaded_when_first_level_is_not()
|
||||
{
|
||||
$users = null;
|
||||
@@ -698,9 +649,7 @@ class ApiControllerTest extends TestCase
|
||||
$this->assertTrue($users->pluck('firstLevelRelation')->filter->relationLoaded('secondLevelRelation')->isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_callable_first_level_relation_is_loaded_if_added()
|
||||
{
|
||||
$users = null;
|
||||
@@ -729,9 +678,7 @@ class ApiControllerTest extends TestCase
|
||||
$this->assertFalse($users->filter->relationLoaded('firstLevelRelation')->isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_callable_second_level_relation_is_loaded_if_added()
|
||||
{
|
||||
$users = null;
|
||||
|
@@ -21,6 +21,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 ApiSerializerTest extends TestCase
|
||||
{
|
||||
@@ -48,9 +49,7 @@ class ApiSerializerTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_attributes_dont_exist_by_default()
|
||||
{
|
||||
$this->app();
|
||||
@@ -66,9 +65,7 @@ class ApiSerializerTest extends TestCase
|
||||
$this->assertArrayNotHasKey('customAttribute', $payload['data']['attributes']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_attributes_exist_if_added()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -92,9 +89,7 @@ class ApiSerializerTest extends TestCase
|
||||
$this->assertArrayHasKey('customAttribute', $payload['data']['attributes']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_attributes_with_invokable_exist_if_added()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -115,9 +110,7 @@ class ApiSerializerTest extends TestCase
|
||||
$this->assertArrayHasKey('customAttributeFromInvokable', $payload['data']['attributes']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_attributes_exist_if_added_to_parent_class()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -141,9 +134,7 @@ class ApiSerializerTest extends TestCase
|
||||
$this->assertArrayHasKey('customAttribute', $payload['data']['attributes']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_attributes_prioritize_child_classes()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -173,9 +164,7 @@ class ApiSerializerTest extends TestCase
|
||||
$this->assertEquals('newValue', $payload['data']['attributes']['customAttribute']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_attributes_can_be_overriden()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -212,9 +201,7 @@ class ApiSerializerTest extends TestCase
|
||||
$this->assertEquals('newValue', $payload['data']['attributes']['someOtherCustomAttribute']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_relations_dont_exist_by_default()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -233,9 +220,7 @@ class ApiSerializerTest extends TestCase
|
||||
$this->assertEquals(400, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_hasMany_relationship_exists_if_added()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -264,9 +249,7 @@ class ApiSerializerTest extends TestCase
|
||||
$this->assertCount(3, $responseJson['data']['relationships']['customSerializerRelation']['data']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_hasOne_relationship_exists_if_added()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -295,9 +278,7 @@ class ApiSerializerTest extends TestCase
|
||||
$this->assertEquals('discussions', $responseJson['data']['relationships']['customSerializerRelation']['data']['type']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_relationship_is_inherited_to_child_classes()
|
||||
{
|
||||
$this->extend(
|
||||
|
@@ -13,14 +13,13 @@ use Flarum\Extend;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Flarum\User\User;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class AuthTest extends TestCase
|
||||
{
|
||||
use RetrievesAuthorizedUsers;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function standard_password_works_by_default()
|
||||
{
|
||||
$this->app();
|
||||
@@ -30,9 +29,7 @@ class AuthTest extends TestCase
|
||||
$this->assertTrue($user->checkPassword('password'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function standard_password_can_be_disabled()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -47,9 +44,7 @@ class AuthTest extends TestCase
|
||||
$this->assertFalse($user->checkPassword('password'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_checker_can_be_added()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -65,9 +60,7 @@ class AuthTest extends TestCase
|
||||
$this->assertTrue($user->checkPassword('DefinitelyNotThePassword'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function false_checker_overrides_true()
|
||||
{
|
||||
$this->extend(
|
||||
|
@@ -16,12 +16,13 @@ use Flarum\Extend;
|
||||
use Flarum\Extension\ExtensionManager;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class ConditionalTest extends TestCase
|
||||
{
|
||||
use RetrievesAuthorizedUsers;
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function conditional_works_if_condition_is_primitive_true()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -48,7 +49,7 @@ class ConditionalTest extends TestCase
|
||||
$this->assertArrayHasKey('customConditionalAttribute', $payload['data']['attributes']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function conditional_does_not_work_if_condition_is_primitive_false()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -75,7 +76,7 @@ class ConditionalTest extends TestCase
|
||||
$this->assertArrayNotHasKey('customConditionalAttribute', $payload['data']['attributes']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function conditional_works_if_condition_is_callable_true()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -102,7 +103,7 @@ class ConditionalTest extends TestCase
|
||||
$this->assertArrayHasKey('customConditionalAttribute', $payload['data']['attributes']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function conditional_does_not_work_if_condition_is_callable_false()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -129,7 +130,7 @@ class ConditionalTest extends TestCase
|
||||
$this->assertArrayNotHasKey('customConditionalAttribute', $payload['data']['attributes']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function conditional_injects_dependencies_to_condition_callable()
|
||||
{
|
||||
$this->expectNotToPerformAssertions();
|
||||
@@ -152,7 +153,7 @@ class ConditionalTest extends TestCase
|
||||
$this->app();
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function conditional_disabled_extension_not_enabled_applies_invokable_class()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -173,7 +174,7 @@ class ConditionalTest extends TestCase
|
||||
$this->assertArrayHasKey('customConditionalAttribute', $payload['data']['attributes']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function conditional_disabled_extension_enabled_does_not_apply_invokable_class()
|
||||
{
|
||||
$this->extension('flarum-tags');
|
||||
@@ -197,7 +198,7 @@ class ConditionalTest extends TestCase
|
||||
$this->assertArrayNotHasKey('customConditionalAttribute', $payload['data']['attributes']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function conditional_enabled_extension_disabled_does_not_apply_invokable_class()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -218,7 +219,7 @@ class ConditionalTest extends TestCase
|
||||
$this->assertArrayNotHasKey('customConditionalAttribute', $payload['data']['attributes']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function conditional_enabled_extension_enabled_applies_invokable_class()
|
||||
{
|
||||
$this->extension('flarum-tags');
|
||||
@@ -241,7 +242,7 @@ class ConditionalTest extends TestCase
|
||||
$this->assertArrayHasKey('customConditionalAttribute', $payload['data']['attributes']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function conditional_does_not_instantiate_extender_if_condition_is_false_using_callable()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -262,7 +263,7 @@ class ConditionalTest extends TestCase
|
||||
$this->assertArrayNotHasKey('customConditionalAttribute', $payload['data']['attributes']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function conditional_does_instantiate_extender_if_condition_is_true_using_callable()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -283,7 +284,7 @@ class ConditionalTest extends TestCase
|
||||
$this->assertArrayHasKey('customConditionalAttribute', $payload['data']['attributes']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function conditional_does_not_instantiate_extender_if_condition_is_false_using_callback()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -310,7 +311,7 @@ class ConditionalTest extends TestCase
|
||||
$this->assertArrayNotHasKey('customConditionalAttribute', $payload['data']['attributes']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function conditional_does_instantiate_extender_if_condition_is_true_using_callback()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -337,7 +338,7 @@ class ConditionalTest extends TestCase
|
||||
$this->assertArrayHasKey('customConditionalAttribute', $payload['data']['attributes']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function conditional_does_not_work_if_extension_is_disabled()
|
||||
{
|
||||
$this->extend(
|
||||
|
@@ -13,14 +13,13 @@ use Flarum\Console\AbstractCommand;
|
||||
use Flarum\Extend;
|
||||
use Flarum\Testing\integration\ConsoleTestCase;
|
||||
use Illuminate\Console\Scheduling\Event;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Exception\CommandNotFoundException;
|
||||
|
||||
class ConsoleTest extends ConsoleTestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_command_doesnt_exist_by_default()
|
||||
{
|
||||
$input = [
|
||||
@@ -31,9 +30,7 @@ class ConsoleTest extends ConsoleTestCase
|
||||
$this->runCommand($input);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_command_exists_when_added()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -48,9 +45,7 @@ class ConsoleTest extends ConsoleTestCase
|
||||
$this->assertEquals('Custom Command.', $this->runCommand($input));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function scheduled_command_doesnt_exist_by_default()
|
||||
{
|
||||
$input = [
|
||||
@@ -60,9 +55,7 @@ class ConsoleTest extends ConsoleTestCase
|
||||
$this->assertStringNotContainsString('cache:clear', $this->runCommand($input));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function scheduled_command_exists_when_added()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -79,9 +72,7 @@ class ConsoleTest extends ConsoleTestCase
|
||||
$this->assertStringContainsString('cache:clear', $this->runCommand($input));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function scheduled_command_exists_when_added_with_class_syntax()
|
||||
{
|
||||
$this->extend(
|
||||
|
@@ -12,6 +12,7 @@ namespace Flarum\Tests\integration\extenders;
|
||||
use Flarum\Extend;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Flarum\User\User;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class CsrfTest extends TestCase
|
||||
{
|
||||
@@ -21,9 +22,7 @@ class CsrfTest extends TestCase
|
||||
'email' => 'test@machine.local',
|
||||
];
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function create_user_post_needs_csrf_token_by_default()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -39,9 +38,7 @@ class CsrfTest extends TestCase
|
||||
$this->assertEquals(400, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function create_user_post_doesnt_need_csrf_token_if_whitelisted()
|
||||
{
|
||||
$this->extend(
|
||||
|
@@ -20,6 +20,7 @@ use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Flarum\User\User;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class EventTest extends TestCase
|
||||
{
|
||||
@@ -47,9 +48,7 @@ class EventTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_listener_doesnt_work_by_default()
|
||||
{
|
||||
$group = $this->buildGroup();
|
||||
@@ -57,9 +56,7 @@ class EventTest extends TestCase
|
||||
$this->assertEquals('test group', $group->name_singular);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_listener_works_with_closure()
|
||||
{
|
||||
$this->extend((new Extend\Event)->listen(Created::class, function (Created $event) {
|
||||
@@ -71,9 +68,7 @@ class EventTest extends TestCase
|
||||
$this->assertEquals('modified group', $group->name_singular);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_listener_works_with_class_with_handle_method_and_can_inject_stuff()
|
||||
{
|
||||
// Because it injects a translator, this also tests that stuff can be injected into this callback.
|
||||
@@ -84,9 +79,7 @@ class EventTest extends TestCase
|
||||
$this->assertEquals('Admin', $group->name_singular);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_subscriber_works()
|
||||
{
|
||||
// Because it injects a translator, this also tests that stuff can be injected into this callback.
|
||||
@@ -97,9 +90,7 @@ class EventTest extends TestCase
|
||||
$this->assertEquals('Admin', $group->name_singular);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_subscriber_applied_after_app_booted()
|
||||
{
|
||||
// Because it injects a translator, this also tests that stuff can be injected into this callback.
|
||||
|
@@ -22,23 +22,20 @@ use Illuminate\Filesystem\FilesystemAdapter;
|
||||
use InvalidArgumentException;
|
||||
use League\Flysystem\InMemory\InMemoryFilesystemAdapter;
|
||||
use League\Flysystem\Local\LocalFilesystemAdapter;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class FilesystemTest extends TestCase
|
||||
{
|
||||
use RetrievesAuthorizedUsers;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_disk_doesnt_exist_by_default()
|
||||
{
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->app()->getContainer()->make('filesystem')->disk('flarum-uploads');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_disk_exists_if_added_and_uses_local_adapter_by_default()
|
||||
{
|
||||
$this->extend((new Extend\Filesystem)->disk('flarum-uploads', function (Paths $paths, UrlGenerator $url) {
|
||||
@@ -54,9 +51,7 @@ class FilesystemTest extends TestCase
|
||||
$this->assertEquals($uploadsDisk->getAdapter()::class, LocalFilesystemAdapter::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_disk_exists_if_added_via_invokable_class_and_uses_local_adapter_by_default()
|
||||
{
|
||||
$this->extend((new Extend\Filesystem)->disk('flarum-uploads', UploadsDisk::class));
|
||||
@@ -67,9 +62,7 @@ class FilesystemTest extends TestCase
|
||||
$this->assertEquals($uploadsDisk->getAdapter()::class, LocalFilesystemAdapter::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function disk_uses_local_adapter_if_configured_adapter_unavailable()
|
||||
{
|
||||
$this->app()->getContainer()->make(SettingsRepositoryInterface::class)->set('disk_driver.flarum-assets', 'nonexistent_driver');
|
||||
@@ -80,9 +73,7 @@ class FilesystemTest extends TestCase
|
||||
$this->assertEquals($assetsDisk->getAdapter()::class, LocalFilesystemAdapter::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function disk_uses_local_adapter_if_configured_adapter_from_config_file_unavailable()
|
||||
{
|
||||
$this->config('disk_driver.flarum-assets', 'null');
|
||||
@@ -93,9 +84,7 @@ class FilesystemTest extends TestCase
|
||||
$this->assertEquals($assetsDisk->getAdapter()::class, LocalFilesystemAdapter::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function disk_uses_custom_adapter_if_configured_and_available()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -110,9 +99,7 @@ class FilesystemTest extends TestCase
|
||||
$this->assertEquals($assetsDisk->getAdapter()::class, InMemoryFilesystemAdapter::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function disk_uses_custom_adapter_from_config_file_if_configured_and_available()
|
||||
{
|
||||
$this->extend(
|
||||
|
@@ -13,6 +13,7 @@ use Flarum\Extend;
|
||||
use Flarum\Formatter\Formatter;
|
||||
use Flarum\Testing\integration\RefreshesFormatterCache;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class FormatterTest extends TestCase
|
||||
{
|
||||
@@ -23,9 +24,7 @@ class FormatterTest extends TestCase
|
||||
return $this->app()->getContainer()->make(Formatter::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_formatter_config_doesnt_work_by_default()
|
||||
{
|
||||
$formatter = $this->getFormatter();
|
||||
@@ -33,9 +32,7 @@ class FormatterTest extends TestCase
|
||||
$this->assertEquals('<t>[B]something[/B]</t>', $formatter->parse('[B]something[/B]'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_formatter_config_works_if_added_with_closure()
|
||||
{
|
||||
$this->extend((new Extend\Formatter)->configure(function ($config) {
|
||||
@@ -47,9 +44,7 @@ class FormatterTest extends TestCase
|
||||
$this->assertEquals('<b>something</b>', $formatter->render($formatter->parse('[B]something[/B]')));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_formatter_config_works_if_added_with_invokable_class()
|
||||
{
|
||||
$this->extend((new Extend\Formatter)->configure(InvokableConfig::class));
|
||||
@@ -59,17 +54,13 @@ class FormatterTest extends TestCase
|
||||
$this->assertEquals('<b>something</b>', $formatter->render($formatter->parse('[B]something[/B]')));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_formatter_parsing_doesnt_work_by_default()
|
||||
{
|
||||
$this->assertEquals('<t>Text<a></t>', $this->getFormatter()->parse('Text<a>'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_formatter_parsing_works_if_added_with_closure()
|
||||
{
|
||||
$this->extend((new Extend\Formatter)->parse(function ($parser, $context, $text) {
|
||||
@@ -79,9 +70,7 @@ class FormatterTest extends TestCase
|
||||
$this->assertEquals('<t>ReplacedText<a></t>', $this->getFormatter()->parse('Text<a>'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_formatter_parsing_works_if_added_with_invokable_class()
|
||||
{
|
||||
$this->extend((new Extend\Formatter)->parse(InvokableParsing::class));
|
||||
@@ -89,17 +78,13 @@ class FormatterTest extends TestCase
|
||||
$this->assertEquals('<t>ReplacedText<a></t>', $this->getFormatter()->parse('Text<a>'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_formatter_unparsing_doesnt_work_by_default()
|
||||
{
|
||||
$this->assertEquals('Text<a>', $this->getFormatter()->unparse('<t>Text<a></t>'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_formatter_unparsing_works_if_added_with_closure()
|
||||
{
|
||||
$this->extend((new Extend\Formatter)->unparse(function ($context, $xml) {
|
||||
@@ -109,9 +94,7 @@ class FormatterTest extends TestCase
|
||||
$this->assertEquals('ReplacedText<a>', $this->getFormatter()->unparse('<t>Text<a></t>'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_formatter_unparsing_works_if_added_with_invokable_class()
|
||||
{
|
||||
$this->extend((new Extend\Formatter)->unparse(InvokableUnparsing::class));
|
||||
@@ -119,17 +102,13 @@ class FormatterTest extends TestCase
|
||||
$this->assertEquals('ReplacedText<a>', $this->getFormatter()->unparse('<t>Text<a></t>'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_formatter_rendering_doesnt_work_by_default()
|
||||
{
|
||||
$this->assertEquals('Text', $this->getFormatter()->render('<p>Text</p>'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_formatter_rendering_works_if_added_with_closure()
|
||||
{
|
||||
$this->extend((new Extend\Formatter)->render(function ($renderer, $context, $xml, $request) {
|
||||
@@ -139,9 +118,7 @@ class FormatterTest extends TestCase
|
||||
$this->assertEquals('ReplacedText', $this->getFormatter()->render('<html>Text</html>'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_formatter_rendering_works_if_added_with_invokable_class()
|
||||
{
|
||||
$this->extend((new Extend\Formatter)->render(InvokableRendering::class));
|
||||
|
@@ -13,14 +13,13 @@ use Flarum\Extend\Frontend;
|
||||
use Flarum\Frontend\Document;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class FrontendContentTest extends TestCase
|
||||
{
|
||||
use RetrievesAuthorizedUsers;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function content_added_with_low_priority_by_default()
|
||||
{
|
||||
$title = null;
|
||||
@@ -39,9 +38,7 @@ class FrontendContentTest extends TestCase
|
||||
$this->assertNotNull($title, $body);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function content_can_be_added_with_high_priority()
|
||||
{
|
||||
$title = 1;
|
||||
@@ -60,9 +57,7 @@ class FrontendContentTest extends TestCase
|
||||
$this->assertNull($title, $body);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function contents_can_be_added_with_different_priorities()
|
||||
{
|
||||
$test = [];
|
||||
|
@@ -11,14 +11,13 @@ namespace Flarum\Tests\integration\extenders;
|
||||
|
||||
use Flarum\Extend;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class FrontendPreloadTest extends TestCase
|
||||
{
|
||||
private $customPreloadUrls = ['/my-preload', '/my-preload2'];
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function default_preloads_are_present()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -39,9 +38,7 @@ class FrontendPreloadTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function preloads_can_be_added()
|
||||
{
|
||||
$urls = $this->customPreloadUrls;
|
||||
@@ -65,9 +62,7 @@ class FrontendPreloadTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function preloads_can_be_added_via_callable()
|
||||
{
|
||||
$urls = $this->customPreloadUrls;
|
||||
|
@@ -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;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
class FrontendTitleTest extends TestCase
|
||||
@@ -40,17 +41,13 @@ class FrontendTitleTest extends TestCase
|
||||
$this->setting('forum_title', 'Flarum');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function basic_title_driver_is_used_by_default()
|
||||
{
|
||||
$this->assertTitleEquals('Test Discussion - Flarum');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_title_driver_works_if_set()
|
||||
{
|
||||
$this->extend((new Frontend('forum'))->title(CustomTitleDriver::class));
|
||||
|
@@ -12,6 +12,7 @@ namespace Flarum\Tests\integration\extenders;
|
||||
use Flarum\Extend;
|
||||
use Flarum\Locale\Translator;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class LocalesTest extends TestCase
|
||||
{
|
||||
@@ -25,9 +26,7 @@ class LocalesTest extends TestCase
|
||||
array_map('unlink', glob($this->tmpDir().'/storage/locale/*'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_translation_does_not_exist_by_default()
|
||||
{
|
||||
$this->app()->getContainer()->make('flarum.locales');
|
||||
@@ -36,9 +35,7 @@ class LocalesTest extends TestCase
|
||||
$this->assertEquals('test.hello', $translator->trans('test.hello', ['name' => 'ACME']));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_translation_exists_if_added()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -51,9 +48,7 @@ class LocalesTest extends TestCase
|
||||
$this->assertEquals('World ACME', $translator->trans('test.hello', ['name' => 'ACME']));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_translation_exists_if_added_with_intl_suffix()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -66,9 +61,7 @@ class LocalesTest extends TestCase
|
||||
$this->assertEquals('World-intl ACME', $translator->trans('test.hello-intl', ['name' => 'ACME']));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function messageformat_works_in_translations()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -81,9 +74,7 @@ class LocalesTest extends TestCase
|
||||
$this->assertEquals('ACME invites ACME2 and one other person to her party.', $translator->trans('test.party-invitation', ['gender_of_host' => 'female', 'host' => 'ACME', 'num_guests' => 2, 'guest' => 'ACME2']));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function laravel_interface_methods_work()
|
||||
{
|
||||
$this->extend(
|
||||
|
@@ -16,6 +16,7 @@ use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Illuminate\Contracts\Validation\Factory;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Symfony\Component\Mailer\Transport\NullTransport;
|
||||
use Symfony\Component\Mailer\Transport\TransportInterface;
|
||||
|
||||
@@ -23,9 +24,7 @@ class MailTest extends TestCase
|
||||
{
|
||||
use RetrievesAuthorizedUsers;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function drivers_are_unchanged_by_default()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -53,9 +52,7 @@ class MailTest extends TestCase
|
||||
], $fields['smtp']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function added_driver_appears_in_mail_settings()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -75,9 +72,7 @@ class MailTest extends TestCase
|
||||
$this->assertEquals(['customSetting1' => ''], $fields['custom']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function adding_driver_with_duplicate_name_overrides_fields()
|
||||
{
|
||||
$this->extend(
|
||||
|
@@ -11,6 +11,7 @@ namespace Flarum\Tests\integration\extenders;
|
||||
|
||||
use Flarum\Extend;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\MiddlewareInterface;
|
||||
@@ -26,9 +27,7 @@ class MiddlewareTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_header_is_not_present_by_default()
|
||||
{
|
||||
$response = $this->send($this->request('GET', '/'));
|
||||
@@ -37,9 +36,7 @@ class MiddlewareTest extends TestCase
|
||||
$this->assertArrayNotHasKey('X-First-Test-Middleware', $response->getHeaders());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function can_add_middleware()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -52,9 +49,7 @@ class MiddlewareTest extends TestCase
|
||||
$this->assertArrayHasKey('X-First-Test-Middleware', $response->getHeaders());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function can_replace_middleware()
|
||||
{
|
||||
$this->add_first_middleware();
|
||||
@@ -69,9 +64,7 @@ class MiddlewareTest extends TestCase
|
||||
$this->assertArrayHasKey('X-Second-Test-Middleware', $response->getHeaders());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function can_remove_middleware()
|
||||
{
|
||||
$this->add_first_middleware();
|
||||
@@ -85,9 +78,7 @@ class MiddlewareTest extends TestCase
|
||||
$this->assertArrayNotHasKey('X-First-Test-Middleware', $response->getHeaders());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function can_insert_before_middleware()
|
||||
{
|
||||
$this->add_first_middleware();
|
||||
@@ -104,9 +95,7 @@ class MiddlewareTest extends TestCase
|
||||
$this->assertLessThan($newMiddlewarePosition, $originalMiddlewarePosition);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function can_insert_after_middleware()
|
||||
{
|
||||
$this->add_first_middleware();
|
||||
|
@@ -15,6 +15,7 @@ use Flarum\Extend;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Flarum\User\User;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class ModelPrivateTest extends TestCase
|
||||
{
|
||||
@@ -27,9 +28,7 @@ class ModelPrivateTest extends TestCase
|
||||
Discussion::unguard();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function discussion_isnt_saved_as_private_by_default()
|
||||
{
|
||||
$this->app();
|
||||
@@ -45,9 +44,7 @@ class ModelPrivateTest extends TestCase
|
||||
$this->assertNull($discussion->is_private);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function discussion_is_saved_as_private_if_privacy_checker_added()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -76,9 +73,7 @@ class ModelPrivateTest extends TestCase
|
||||
$this->assertFalse($publicDiscussion->is_private);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function discussion_is_saved_as_private_if_privacy_checker_added_via_invokable_class()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -105,9 +100,7 @@ class ModelPrivateTest extends TestCase
|
||||
$this->assertFalse($publicDiscussion->is_private);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function private_checkers_that_return_false_dont_matter()
|
||||
{
|
||||
$this->extend(
|
||||
|
@@ -20,6 +20,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 ModelTest extends TestCase
|
||||
{
|
||||
@@ -51,9 +52,7 @@ class ModelTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_relationship_does_not_exist_by_default()
|
||||
{
|
||||
$this->app();
|
||||
@@ -64,9 +63,7 @@ class ModelTest extends TestCase
|
||||
$user->customRelation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_hasOne_relationship_exists_if_added()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -81,9 +78,7 @@ class ModelTest extends TestCase
|
||||
$this->assertEquals([], $user->customRelation()->get()->toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_hasMany_relationship_exists_if_added()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -98,9 +93,7 @@ class ModelTest extends TestCase
|
||||
$this->assertEquals([], $user->customRelation()->get()->toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_belongsTo_relationship_exists_if_added()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -115,9 +108,7 @@ class ModelTest extends TestCase
|
||||
$this->assertEquals([], $user->customRelation()->get()->toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_relationship_exists_if_added()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -134,9 +125,7 @@ class ModelTest extends TestCase
|
||||
$this->assertEquals([], $user->customRelation()->get()->toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_relationship_can_be_invokable_class()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -151,9 +140,7 @@ class ModelTest extends TestCase
|
||||
$this->assertEquals([], $user->customRelation()->get()->toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_relationship_exists_and_can_return_instances_if_added()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -177,9 +164,7 @@ class ModelTest extends TestCase
|
||||
$this->assertStringContainsString(json_encode(__CLASS__), json_encode($user->customRelation()->get()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_relationship_is_inherited_to_child_classes()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -197,9 +182,7 @@ class ModelTest extends TestCase
|
||||
$this->assertEquals(1, $post->ancestor->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_relationship_prioritizes_child_classes_within_2_parent_classes()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -219,9 +202,7 @@ class ModelTest extends TestCase
|
||||
$this->assertEquals(1, $post->ancestor->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_relationship_prioritizes_child_classes_within_child_class_and_immediate_parent()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -241,9 +222,7 @@ class ModelTest extends TestCase
|
||||
$this->assertEquals(2, $post->ancestor->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_relationship_does_not_exist_if_added_to_unrelated_model()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -261,9 +240,7 @@ class ModelTest extends TestCase
|
||||
$group->customRelation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_default_attribute_doesnt_exist_if_not_set()
|
||||
{
|
||||
$group = new Group;
|
||||
@@ -273,9 +250,7 @@ class ModelTest extends TestCase
|
||||
$this->assertNotEquals('Custom Default', $group->name_singular);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_default_attribute_works_if_set()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -290,9 +265,7 @@ class ModelTest extends TestCase
|
||||
$this->assertEquals('Custom Default', $group->name_singular);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_default_attribute_evaluated_at_runtime_if_callable()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -315,9 +288,7 @@ class ModelTest extends TestCase
|
||||
$this->assertEquals(4, $group2->counter);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_default_attribute_is_inherited_to_child_classes()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -332,9 +303,7 @@ class ModelTest extends TestCase
|
||||
$this->assertEquals(42, $post->answer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_default_attribute_inheritance_prioritizes_child_class()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -357,9 +326,7 @@ class ModelTest extends TestCase
|
||||
$this->assertEquals('ni!', $commentPost->answer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_default_attribute_doesnt_work_if_set_on_unrelated_model()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -374,9 +341,7 @@ class ModelTest extends TestCase
|
||||
$this->assertNotEquals('Custom Default', $user->name_singular);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_cast_attribute_doesnt_exist_by_default()
|
||||
{
|
||||
$post = new Post;
|
||||
@@ -386,9 +351,7 @@ class ModelTest extends TestCase
|
||||
$this->assertFalse($post->hasCast('custom'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_cast_attribute_can_be_set()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -403,9 +366,7 @@ class ModelTest extends TestCase
|
||||
$this->assertTrue($post->hasCast('custom', 'datetime'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_cast_attribute_is_inherited_to_child_classes()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -420,9 +381,7 @@ class ModelTest extends TestCase
|
||||
$this->assertTrue($post->hasCast('custom', 'boolean'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_cast_attribute_doesnt_work_if_set_on_unrelated_model()
|
||||
{
|
||||
$this->extend(
|
||||
|
@@ -16,6 +16,7 @@ use Flarum\Http\SlugManager;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Flarum\User\User;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class ModelUrlTest extends TestCase
|
||||
{
|
||||
@@ -39,9 +40,7 @@ class ModelUrlTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function uses_default_driver_by_default()
|
||||
{
|
||||
$slugManager = $this->app()->getContainer()->make(SlugManager::class);
|
||||
@@ -52,9 +51,7 @@ class ModelUrlTest extends TestCase
|
||||
$this->assertEquals('1', $slugManager->forResource(User::class)->fromSlug('admin', $testUser)->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_slug_driver_has_effect_if_added()
|
||||
{
|
||||
$this->extend((new Extend\ModelUrl(User::class))->addSlugDriver('testDriver', TestSlugDriver::class));
|
||||
|
@@ -19,6 +19,7 @@ use Flarum\Testing\integration\TestCase;
|
||||
use Flarum\User\User;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Arr;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class ModelVisibilityTest extends TestCase
|
||||
{
|
||||
@@ -47,9 +48,7 @@ class ModelVisibilityTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function when_allowed_guests_can_see_hidden_posts()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -68,9 +67,7 @@ class ModelVisibilityTest extends TestCase
|
||||
$this->assertEquals(1, Arr::get($json, 'data.relationships.posts.data.0.id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function user_can_see_posts_by_default()
|
||||
{
|
||||
$this->app();
|
||||
@@ -82,9 +79,7 @@ class ModelVisibilityTest extends TestCase
|
||||
$this->assertCount(1, $visiblePosts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_visibility_scoper_can_stop_user_from_seeing_posts()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -103,9 +98,7 @@ class ModelVisibilityTest extends TestCase
|
||||
$this->assertCount(0, $visiblePosts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_visibility_scoper_applies_if_added_to_parent_class()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -124,9 +117,7 @@ class ModelVisibilityTest extends TestCase
|
||||
$this->assertCount(0, $visiblePosts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_visibility_scoper_for_class_applied_after_scopers_for_parent_class()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -149,9 +140,7 @@ class ModelVisibilityTest extends TestCase
|
||||
$this->assertCount(2, $visiblePosts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_scoper_works_for_abilities_other_than_view()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -174,9 +163,7 @@ class ModelVisibilityTest extends TestCase
|
||||
$this->assertCount(2, $visiblePosts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function universal_scoper_works()
|
||||
{
|
||||
$this->extend(
|
||||
|
@@ -18,30 +18,25 @@ use Flarum\Notification\NotificationSyncer;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Flarum\User\User;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class NotificationTest extends TestCase
|
||||
{
|
||||
use RetrievesAuthorizedUsers;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function notification_type_doesnt_exist_by_default()
|
||||
{
|
||||
$this->assertArrayNotHasKey('customNotificationType', Notification::getSubjectModels());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function notification_driver_doesnt_exist_by_default()
|
||||
{
|
||||
$this->assertArrayNotHasKey('customNotificationDriver', NotificationSyncer::getNotificationDrivers());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function notification_type_exists_if_added()
|
||||
{
|
||||
$this->extend((new Extend\Notification)->type(CustomNotificationType::class));
|
||||
@@ -51,9 +46,7 @@ class NotificationTest extends TestCase
|
||||
$this->assertArrayHasKey('customNotificationType', Notification::getSubjectModels());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function notification_driver_exists_if_added()
|
||||
{
|
||||
$this->extend((new Extend\Notification())->driver(
|
||||
@@ -66,9 +59,7 @@ class NotificationTest extends TestCase
|
||||
$this->assertArrayHasKey('customNotificationDriver', NotificationSyncer::getNotificationDrivers());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function notification_driver_enabled_types_exist_if_added()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -91,9 +82,7 @@ class NotificationTest extends TestCase
|
||||
$this->assertEmpty($blueprints[ThirdCustomNotificationType::class]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function notification_before_sending_callback_works_if_added()
|
||||
{
|
||||
$this->extend(
|
||||
|
@@ -19,6 +19,7 @@ use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Flarum\User\Access\AbstractPolicy;
|
||||
use Flarum\User\User;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class PolicyTest extends TestCase
|
||||
{
|
||||
@@ -48,9 +49,7 @@ class PolicyTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function unrelated_user_cant_hide_discussion_by_default()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -60,9 +59,7 @@ class PolicyTest extends TestCase
|
||||
$this->assertEquals(403, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function unrelated_user_can_hide_discussion_if_allowed()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -77,9 +74,7 @@ class PolicyTest extends TestCase
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function unrelated_user_cant_hide_discussion_if_denied()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -95,9 +90,7 @@ class PolicyTest extends TestCase
|
||||
$this->assertEquals(403, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function unrelated_user_can_hide_discussion_if_force_allowed()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -114,9 +107,7 @@ class PolicyTest extends TestCase
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function unrelated_user_cant_hide_discussion_if_force_denied()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -134,9 +125,7 @@ class PolicyTest extends TestCase
|
||||
$this->assertEquals(403, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function regular_user_can_start_discussions_by_default()
|
||||
{
|
||||
$this->app();
|
||||
@@ -146,9 +135,7 @@ class PolicyTest extends TestCase
|
||||
$this->assertEquals(true, $user->can('startDiscussion'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function regular_user_cant_start_discussions_if_blocked_by_global_policy()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -163,9 +150,7 @@ class PolicyTest extends TestCase
|
||||
$this->assertEquals(false, $user->can('startDiscussion'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function global_policy_doesnt_apply_if_argument_provided()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -180,9 +165,7 @@ class PolicyTest extends TestCase
|
||||
$this->assertEquals(true, $user->can('startDiscussion', Discussion::find(1)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function unrelated_user_cant_hide_post_by_default()
|
||||
{
|
||||
$this->app();
|
||||
@@ -192,9 +175,7 @@ class PolicyTest extends TestCase
|
||||
$this->assertEquals(false, $user->can('hide', Post::find(1)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function unrelated_user_can_hide_post_if_allowed()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -207,9 +188,7 @@ class PolicyTest extends TestCase
|
||||
$this->assertEquals(true, $user->can('hide', Post::find(1)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function policies_are_inherited_to_child_classes()
|
||||
{
|
||||
$this->extend(
|
||||
|
@@ -14,20 +14,17 @@ use Flarum\Post\AbstractEventPost;
|
||||
use Flarum\Post\MergeableInterface;
|
||||
use Flarum\Post\Post;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class PostTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_post_type_doesnt_exist_by_default()
|
||||
{
|
||||
$this->assertArrayNotHasKey('customPost', Post::getModels());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_post_type_exists_if_added()
|
||||
{
|
||||
$this->extend((new Extend\Post)->type(PostTestCustomPost::class));
|
||||
|
@@ -12,15 +12,14 @@ namespace Flarum\Tests\integration\extenders;
|
||||
use Flarum\Extend;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Laminas\Diactoros\Response\TextResponse;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
|
||||
class RoutesTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_route_does_not_exist_by_default()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -30,9 +29,7 @@ class RoutesTest extends TestCase
|
||||
$this->assertEquals(404, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_route_can_be_added_by_extender()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -48,9 +45,7 @@ class RoutesTest extends TestCase
|
||||
$this->assertEquals('Hello Flarumites!', $response->getBody());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function existing_route_can_be_removed()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -65,9 +60,7 @@ class RoutesTest extends TestCase
|
||||
$this->assertEquals(404, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_route_can_override_existing_route_if_removed()
|
||||
{
|
||||
$this->extend(
|
||||
|
@@ -24,6 +24,7 @@ use Flarum\Search\SearchState;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Flarum\User\User;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class SearchDriverTest extends TestCase
|
||||
{
|
||||
@@ -78,9 +79,7 @@ class SearchDriverTest extends TestCase
|
||||
->getResults();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function works_as_expected_with_no_modifications()
|
||||
{
|
||||
$this->prepDb();
|
||||
@@ -94,9 +93,7 @@ class SearchDriverTest extends TestCase
|
||||
$this->assertStringContainsString('DISCUSSION 2', $searchForSecond);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_full_text_gambit_has_effect_if_added()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -107,9 +104,7 @@ class SearchDriverTest extends TestCase
|
||||
$this->assertEquals('[]', json_encode($this->searchDiscussions('in text', 5)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_filter_has_effect_if_added()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -125,9 +120,7 @@ class SearchDriverTest extends TestCase
|
||||
$this->assertEquals('[]', json_encode($this->searchDiscussions('', 5, ['noResult' => '1'])));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function existing_filter_can_be_replaced()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -142,9 +135,7 @@ class SearchDriverTest extends TestCase
|
||||
$this->assertEquals('[]', json_encode($this->searchDiscussions('', 5, ['noResult' => '1'])));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function search_mutator_has_effect_if_added()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -159,9 +150,7 @@ class SearchDriverTest extends TestCase
|
||||
$this->assertEquals('[]', json_encode($this->searchDiscussions('in text', 5)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function search_mutator_has_effect_if_added_with_invokable_class()
|
||||
{
|
||||
$this->extend(
|
||||
|
@@ -18,6 +18,7 @@ use Flarum\Search\IndexerInterface;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use PHPUnit\Framework\Assert;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
class SearchIndexTest extends TestCase
|
||||
{
|
||||
@@ -52,7 +53,7 @@ class SearchIndexTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/** @dataProvider modelProvider */
|
||||
#[DataProvider('modelProvider')]
|
||||
public function test_indexer_triggered_on_create(string $type, string $modelClass, array $attributes)
|
||||
{
|
||||
$this->extend(
|
||||
@@ -84,7 +85,7 @@ class SearchIndexTest extends TestCase
|
||||
Assert::assertEquals('save', TestIndexer::$triggered, $response->getBody()->getContents());
|
||||
}
|
||||
|
||||
/** @dataProvider modelProvider */
|
||||
#[DataProvider('modelProvider')]
|
||||
public function test_indexer_triggered_on_save(string $type, string $modelClass, array $attributes)
|
||||
{
|
||||
$this->extend(
|
||||
@@ -108,7 +109,7 @@ class SearchIndexTest extends TestCase
|
||||
Assert::assertEquals('save', TestIndexer::$triggered, $response->getBody()->getContents());
|
||||
}
|
||||
|
||||
/** @dataProvider modelProvider */
|
||||
#[DataProvider('modelProvider')]
|
||||
public function test_indexer_triggered_on_delete(string $type, string $modelClass, array $attributes)
|
||||
{
|
||||
$this->extend(
|
||||
@@ -127,7 +128,7 @@ class SearchIndexTest extends TestCase
|
||||
Assert::assertEquals('delete', TestIndexer::$triggered, $response->getBody()->getContents());
|
||||
}
|
||||
|
||||
/** @dataProvider modelProvider */
|
||||
#[DataProvider('modelProvider')]
|
||||
public function test_indexer_triggered_on_hide(string $type, string $modelClass, array $attributes)
|
||||
{
|
||||
$this->extend(
|
||||
@@ -153,7 +154,7 @@ class SearchIndexTest extends TestCase
|
||||
Assert::assertEquals('delete', TestIndexer::$triggered, $response->getBody()->getContents());
|
||||
}
|
||||
|
||||
/** @dataProvider modelProvider */
|
||||
#[DataProvider('modelProvider')]
|
||||
public function test_indexer_triggered_on_restore(string $type, string $modelClass, array $attributes)
|
||||
{
|
||||
$this->extend(
|
||||
|
@@ -12,12 +12,11 @@ namespace Flarum\Tests\integration\extenders;
|
||||
use Flarum\Extend;
|
||||
use Flarum\Foundation\AbstractServiceProvider;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class ServiceProviderTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function providers_dont_work_by_default()
|
||||
{
|
||||
$this->app();
|
||||
@@ -27,9 +26,7 @@ class ServiceProviderTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function providers_first_register_order_is_correct()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -45,9 +42,7 @@ class ServiceProviderTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function providers_second_register_order_is_correct()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -64,9 +59,7 @@ class ServiceProviderTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function providers_boot_order_is_correct()
|
||||
{
|
||||
$this->extend(
|
||||
|
@@ -18,33 +18,28 @@ use Flarum\User\SessionDriverInterface;
|
||||
use Illuminate\Session\FileSessionHandler;
|
||||
use Illuminate\Session\NullSessionHandler;
|
||||
use InvalidArgumentException;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use SessionHandlerInterface;
|
||||
|
||||
class SessionTest extends TestCase
|
||||
{
|
||||
use RetrievesAuthorizedUsers;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function default_driver_exists_by_default()
|
||||
{
|
||||
$this->expectNotToPerformAssertions();
|
||||
$this->app()->getContainer()->make('session.handler');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_driver_doesnt_exist_by_default()
|
||||
{
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->app()->getContainer()->make('session')->driver('flarum-acme');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_driver_exists_if_added()
|
||||
{
|
||||
$this->extend((new Extend\Session())->driver('flarum-acme', AcmeSessionDriver::class));
|
||||
@@ -54,9 +49,7 @@ class SessionTest extends TestCase
|
||||
$this->assertEquals(NullSessionHandler::class, $driver->getHandler()::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_driver_overrides_laravel_defined_drivers_if_added()
|
||||
{
|
||||
$this->extend((new Extend\Session())->driver('redis', AcmeSessionDriver::class));
|
||||
@@ -66,9 +59,7 @@ class SessionTest extends TestCase
|
||||
$this->assertEquals(NullSessionHandler::class, $driver->getHandler()::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function uses_default_driver_if_driver_from_config_file_not_configured()
|
||||
{
|
||||
$this->config('session.driver', null);
|
||||
@@ -78,9 +69,7 @@ class SessionTest extends TestCase
|
||||
$this->assertEquals(FileSessionHandler::class, $handler::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function uses_default_driver_if_configured_driver_from_config_file_unavailable()
|
||||
{
|
||||
$this->config('session.driver', 'nevergonnagiveyouup');
|
||||
@@ -90,9 +79,7 @@ class SessionTest extends TestCase
|
||||
$this->assertEquals(FileSessionHandler::class, $handler::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function uses_custom_driver_from_config_file_if_configured_and_available()
|
||||
{
|
||||
$this->extend(
|
||||
|
@@ -13,6 +13,7 @@ use Flarum\Extend;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Flarum\User\User;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class SettingsTest extends TestCase
|
||||
{
|
||||
@@ -35,9 +36,7 @@ class SettingsTest extends TestCase
|
||||
$this->setting('custom-prefix.custom_setting2', 'customValue');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_setting_isnt_serialized_by_default()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -51,9 +50,7 @@ class SettingsTest extends TestCase
|
||||
$this->assertArrayNotHasKey('customPrefix.customSetting', $payload['data']['attributes']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_setting_serialized_if_added()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -73,9 +70,7 @@ class SettingsTest extends TestCase
|
||||
$this->assertEquals('customValue', $payload['data']['attributes']['customPrefix.customSetting']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_setting_callback_works_if_added()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -97,9 +92,7 @@ class SettingsTest extends TestCase
|
||||
$this->assertEquals('customValueModified', $payload['data']['attributes']['customPrefix.customSetting']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_setting_callback_can_cast_to_type()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -121,9 +114,7 @@ class SettingsTest extends TestCase
|
||||
$this->assertEquals(true, $payload['data']['attributes']['customPrefix.customSetting']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_setting_callback_works_with_invokable_class()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -143,9 +134,7 @@ class SettingsTest extends TestCase
|
||||
$this->assertEquals('customValueModifiedByInvokable', $payload['data']['attributes']['customPrefix.customSetting2']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_setting_default_prioritizes_extender()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -164,9 +153,7 @@ class SettingsTest extends TestCase
|
||||
$this->assertEquals('extenderDefault200', $settings->get('custom-prefix.unavailable_custom_setting200'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_setting_default_falls_back_to_parameter()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -182,9 +169,7 @@ class SettingsTest extends TestCase
|
||||
$this->assertEquals('defaultParameterValue', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function null_custom_setting_returns_null()
|
||||
{
|
||||
$this->setting('custom-prefix.custom_null_setting', null);
|
||||
@@ -202,9 +187,7 @@ class SettingsTest extends TestCase
|
||||
$this->assertEquals(null, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_less_var_does_not_work_by_default()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -217,9 +200,7 @@ class SettingsTest extends TestCase
|
||||
$this->assertEquals(500, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_less_var_works_if_registered()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -237,9 +218,7 @@ class SettingsTest extends TestCase
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function cant_save_setting_if_invalid_less_var()
|
||||
{
|
||||
$this->extend(
|
||||
|
@@ -11,12 +11,11 @@ namespace Flarum\Tests\integration\extenders;
|
||||
|
||||
use Flarum\Extend;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class ThemeTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function theme_extender_override_import_doesnt_work_by_default()
|
||||
{
|
||||
$response = $this->send($this->request('GET', '/'));
|
||||
@@ -27,9 +26,7 @@ class ThemeTest extends TestCase
|
||||
$this->assertStringNotContainsString('.dummy_test_case{color:red}', file_get_contents($cssFilePath));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function theme_extender_override_import_works()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -46,9 +43,7 @@ class ThemeTest extends TestCase
|
||||
$this->assertStringContainsString('.dummy_test_case{color:red}', file_get_contents($cssFilePath));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function theme_extender_override_import_works_with_external_sources()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -70,9 +65,7 @@ class ThemeTest extends TestCase
|
||||
$this->assertStringContainsString('.dummy{color:yellow}', $contents);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function theme_extender_override_file_source_works()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -89,9 +82,7 @@ class ThemeTest extends TestCase
|
||||
$this->assertEquals('body{color:orange}', file_get_contents($cssFilePath));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function theme_extender_override_file_source_works_by_failing_when_necessary()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -105,9 +96,7 @@ class ThemeTest extends TestCase
|
||||
$this->assertEquals(500, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function theme_extender_can_add_custom_function()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -133,9 +122,7 @@ class ThemeTest extends TestCase
|
||||
$this->assertStringContainsString('.dummy_func_test2{--x:1000;--y:false}', $contents);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function theme_extender_can_add_custom_variable()
|
||||
{
|
||||
$this->extend(
|
||||
|
@@ -13,6 +13,7 @@ use Flarum\Extend;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Flarum\User\User;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class ThrottleApiTest extends TestCase
|
||||
{
|
||||
@@ -32,9 +33,7 @@ class ThrottleApiTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function list_discussions_not_restricted_by_default()
|
||||
{
|
||||
$response = $this->send($this->request('GET', '/api/discussions', ['authenticatedAs' => 2]));
|
||||
@@ -42,9 +41,7 @@ class ThrottleApiTest extends TestCase
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function list_discussions_can_be_restricted()
|
||||
{
|
||||
$this->extend((new Extend\ThrottleApi)->set('blockListDiscussions', function ($request) {
|
||||
@@ -58,9 +55,7 @@ class ThrottleApiTest extends TestCase
|
||||
$this->assertEquals(429, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function false_overrides_true_for_evaluating_throttlers()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -81,9 +76,7 @@ class ThrottleApiTest extends TestCase
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function throttling_applies_to_api_client()
|
||||
{
|
||||
$this->extend((new Extend\ThrottleApi)->set('blockRegistration', function ($request) {
|
||||
|
@@ -15,6 +15,7 @@ use Flarum\Testing\integration\TestCase;
|
||||
use Flarum\User\DisplayName\DriverInterface;
|
||||
use Flarum\User\User;
|
||||
use Illuminate\Support\Arr;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class UserTest extends TestCase
|
||||
{
|
||||
@@ -44,9 +45,7 @@ class UserTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function username_display_name_driver_used_by_default()
|
||||
{
|
||||
$this->app();
|
||||
@@ -56,9 +55,7 @@ class UserTest extends TestCase
|
||||
$this->assertEquals('admin', $user->displayName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function can_use_custom_display_name_driver()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -73,9 +70,7 @@ class UserTest extends TestCase
|
||||
$this->assertEquals('admin@machine.local$$$suffix', $user->displayName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function user_has_permissions_for_expected_groups_if_no_processors_added()
|
||||
{
|
||||
$this->app();
|
||||
@@ -85,9 +80,7 @@ class UserTest extends TestCase
|
||||
$this->assertContains('searchUsers', $user->getPermissions());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function processor_can_restrict_user_groups()
|
||||
{
|
||||
$this->extend((new Extend\User)->permissionGroups(function (User $user, array $groupIds) {
|
||||
@@ -103,9 +96,7 @@ class UserTest extends TestCase
|
||||
$this->assertNotContains('searchUsers', $user->getPermissions());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function processor_can_be_invokable_class()
|
||||
{
|
||||
$this->extend((new Extend\User)->permissionGroups(CustomGroupProcessorClass::class));
|
||||
@@ -117,9 +108,7 @@ class UserTest extends TestCase
|
||||
$this->assertNotContains('searchUsers', $user->getPermissions());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function can_add_user_preference()
|
||||
{
|
||||
$this->registerTestPreference();
|
||||
@@ -131,9 +120,7 @@ class UserTest extends TestCase
|
||||
$this->assertEquals(true, Arr::get($user->preferences, 'test'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function can_store_user_preference()
|
||||
{
|
||||
$this->registerTestPreference();
|
||||
@@ -148,9 +135,7 @@ class UserTest extends TestCase
|
||||
$this->assertEquals(false, $user->getPreference('test'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function storing_user_preference_modified_by_transformer()
|
||||
{
|
||||
$this->registerTestPreference();
|
||||
|
@@ -14,6 +14,7 @@ use Flarum\Foundation\AbstractValidator;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Flarum\User\User;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class ValidatorTest extends TestCase
|
||||
{
|
||||
@@ -34,9 +35,7 @@ class ValidatorTest extends TestCase
|
||||
$this->extend((new Extend\Validator(CustomUserValidator::class))->configure(CustomValidatorClass::class));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_validation_rule_does_not_exist_by_default()
|
||||
{
|
||||
$this->app()->getContainer()->make(CustomUserValidator::class)->assertValid(['password' => 'simplePassword']);
|
||||
@@ -45,9 +44,7 @@ class ValidatorTest extends TestCase
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_validation_rule_exists_if_added()
|
||||
{
|
||||
$this->extendToRequireLongPassword();
|
||||
@@ -57,9 +54,7 @@ class ValidatorTest extends TestCase
|
||||
$this->app()->getContainer()->make(CustomUserValidator::class)->assertValid(['password' => 'simplePassword']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_validation_rule_exists_if_added_via_invokable_class()
|
||||
{
|
||||
$this->extendToRequireLongPasswordViaInvokableClass();
|
||||
@@ -69,9 +64,7 @@ class ValidatorTest extends TestCase
|
||||
$this->app()->getContainer()->make(CustomUserValidator::class)->assertValid(['password' => 'simplePassword']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_validation_rule_doesnt_affect_other_validators()
|
||||
{
|
||||
$this->extendToRequireLongPassword();
|
||||
|
@@ -12,21 +12,18 @@ namespace Flarum\Tests\integration\extenders;
|
||||
use Flarum\Extend;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class ViewTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_view_namespace_does_not_exist_by_default()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->app()->getContainer()->make(Factory::class)->make('integration.test::test');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function custom_view_namespace_can_be_added_by_extender()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -37,9 +34,7 @@ class ViewTest extends TestCase
|
||||
$this->assertEquals('<html><body>Hello World!</body></html>', trim($this->app()->getContainer()->make(Factory::class)->make('integration.test::test')->render()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function can_add_view_to_namespace_by_prepend_extender()
|
||||
{
|
||||
$this->extend(
|
||||
@@ -50,9 +45,7 @@ class ViewTest extends TestCase
|
||||
$this->assertEquals('<html><body>Hello World!</body></html>', trim($this->app()->getContainer()->make(Factory::class)->make('flarum::test')->render()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function can_override_view_in_namespace_by_prepend_extender()
|
||||
{
|
||||
$this->extend(
|
||||
|
@@ -16,6 +16,7 @@ use Flarum\Foundation\AbstractServiceProvider;
|
||||
use Flarum\Post\Post;
|
||||
use Flarum\Settings\SettingsRepositoryInterface;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class DefaultRouteTest extends TestCase
|
||||
{
|
||||
@@ -47,9 +48,7 @@ class DefaultRouteTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function default_route_payload_includes_discussions()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -59,9 +58,7 @@ class DefaultRouteTest extends TestCase
|
||||
$this->assertStringContainsString('apiDocument', $response->getBody());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function nonexistent_custom_homepage_uses_default_payload()
|
||||
{
|
||||
$this->setDefaultRoute('/nonexistent');
|
||||
@@ -73,9 +70,7 @@ class DefaultRouteTest extends TestCase
|
||||
$this->assertStringContainsString('apiDocument', $response->getBody());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function existent_custom_homepage_doesnt_use_default_payload()
|
||||
{
|
||||
$this->setDefaultRoute('/settings');
|
||||
|
@@ -17,6 +17,8 @@ use Flarum\Testing\integration\TestCase;
|
||||
use Flarum\User\EmailToken;
|
||||
use Flarum\User\PasswordToken;
|
||||
use Flarum\User\User;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class GlobalLogoutTest extends TestCase
|
||||
{
|
||||
@@ -56,10 +58,8 @@ class GlobalLogoutTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider canGloballyLogoutDataProvider
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('canGloballyLogoutDataProvider')]
|
||||
public function can_globally_log_out(int $authenticatedAs)
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -75,7 +75,7 @@ class GlobalLogoutTest extends TestCase
|
||||
$this->assertEquals(0, PasswordToken::query()->where('user_id', $authenticatedAs)->count());
|
||||
}
|
||||
|
||||
public function canGloballyLogoutDataProvider(): array
|
||||
public static function canGloballyLogoutDataProvider(): array
|
||||
{
|
||||
return [
|
||||
// Admin
|
||||
|
@@ -12,6 +12,7 @@ namespace Flarum\Tests\integration\forum;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Flarum\User\User;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class IndexTest extends TestCase
|
||||
{
|
||||
@@ -29,9 +30,7 @@ class IndexTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function guest_not_serialized_by_current_user_serializer()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -42,9 +41,7 @@ class IndexTest extends TestCase
|
||||
$this->assertStringNotContainsString('preferences', $response->getBody()->getContents());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function user_serialized_by_current_user_serializer()
|
||||
{
|
||||
$response = $this->send(
|
||||
|
@@ -14,6 +14,7 @@ use Flarum\Http\AccessToken;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Flarum\User\User;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class LoginTest extends TestCase
|
||||
{
|
||||
@@ -35,9 +36,7 @@ class LoginTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function cant_login_without_data()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -49,9 +48,7 @@ class LoginTest extends TestCase
|
||||
$this->assertEquals(401, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function cant_login_with_wrong_password()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -66,9 +63,7 @@ class LoginTest extends TestCase
|
||||
$this->assertEquals(401, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function can_login_with_data()
|
||||
{
|
||||
$response = $this->send(
|
||||
|
@@ -12,6 +12,7 @@ namespace Flarum\Tests\integration\forum;
|
||||
use Flarum\Extend;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Flarum\User\User;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class RegisterTest extends TestCase
|
||||
{
|
||||
@@ -25,9 +26,7 @@ class RegisterTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function cant_register_without_data()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -64,9 +63,7 @@ class RegisterTest extends TestCase
|
||||
], json_decode($body, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function can_register_with_data()
|
||||
{
|
||||
$response = $this->send(
|
||||
|
@@ -10,12 +10,11 @@
|
||||
namespace Flarum\Tests\integration\middleware;
|
||||
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class ContentTypeOptionsTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function has_content_type_options_header()
|
||||
{
|
||||
$response = $this->send(
|
||||
|
@@ -10,12 +10,11 @@
|
||||
namespace Flarum\Tests\integration\middleware;
|
||||
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class ReferrerPolicyTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function has_referer_header()
|
||||
{
|
||||
$response = $this->send(
|
||||
@@ -25,9 +24,7 @@ class ReferrerPolicyTest extends TestCase
|
||||
$this->assertArrayHasKey('Referrer-Policy', $response->getHeaders());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function has_default_referer_policy()
|
||||
{
|
||||
$response = $this->send(
|
||||
|
@@ -1,120 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Tests\integration\notification;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Flarum\Database\AbstractModel;
|
||||
use Flarum\Discussion\Discussion;
|
||||
use Flarum\Extend;
|
||||
use Flarum\Notification\Blueprint\BlueprintInterface;
|
||||
use Flarum\Notification\Notification;
|
||||
use Flarum\Notification\NotificationSyncer;
|
||||
use Flarum\Post\Post;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Flarum\User\User;
|
||||
|
||||
class NotificationSyncerTest extends TestCase
|
||||
{
|
||||
use RetrievesAuthorizedUsers;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->prepareDatabase([
|
||||
User::class => [
|
||||
$this->normalUser(),
|
||||
['id' => 3, 'username' => 'Receiver', 'email' => 'receiver@machine.local', 'is_email_confirmed' => 1],
|
||||
],
|
||||
Discussion::class => [
|
||||
['id' => 1, 'title' => 'Public discussion', 'created_at' => Carbon::parse('2021-11-01 13:00:00')->toDateTimeString(), 'user_id' => 2, 'first_post_id' => 1, 'comment_count' => 2, 'is_private' => 0, 'last_post_number' => 2],
|
||||
|
||||
['id' => 2, 'title' => 'Private discussion', 'created_at' => Carbon::parse('2021-11-01 13:00:00')->toDateTimeString(), 'user_id' => 2, 'first_post_id' => 3, 'comment_count' => 2, 'is_private' => 1, 'last_post_number' => 2],
|
||||
],
|
||||
Post::class => [
|
||||
['id' => 1, 'discussion_id' => 1, 'number' => 1, 'created_at' => Carbon::parse('2021-11-01 13:00:00')->toDateTimeString(), 'user_id' => 2, 'type' => 'comment', 'content' => '<t></t>', 'is_private' => 0],
|
||||
['id' => 2, 'discussion_id' => 1, 'number' => 2, 'created_at' => Carbon::parse('2021-11-01 13:00:03')->toDateTimeString(), 'user_id' => 2, 'type' => 'comment', 'content' => '<t></t>', 'is_private' => 1],
|
||||
|
||||
['id' => 3, 'discussion_id' => 2, 'number' => 1, 'created_at' => Carbon::parse('2021-11-01 13:00:00')->toDateTimeString(), 'user_id' => 2, 'type' => 'comment', 'content' => '<t></t>', 'is_private' => 0],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param class-string<AbstractModel> $subjectClass
|
||||
*/
|
||||
protected function expect_notification_count_from_sending_notification_type_with_subject(int $count, string $subjectClass, int $subjectId, string $serializer)
|
||||
{
|
||||
CustomNotificationType::$subjectModel = $subjectClass;
|
||||
|
||||
$this->extend(
|
||||
(new Extend\Notification())
|
||||
->type(CustomNotificationType::class, $serializer, ['alert'])
|
||||
);
|
||||
|
||||
/** @var NotificationSyncer $syncer */
|
||||
$syncer = $this->app()->getContainer()->make(NotificationSyncer::class);
|
||||
|
||||
$subject = $subjectClass::query()->find($subjectId);
|
||||
|
||||
$syncer->sync(
|
||||
$blueprint = new CustomNotificationType($subject),
|
||||
User::query()
|
||||
->whereIn('id', [1, 3])
|
||||
->get()
|
||||
->all()
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
$count,
|
||||
Notification::query()
|
||||
->matchingBlueprint($blueprint)
|
||||
->whereSubject($subject)
|
||||
->count()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class CustomNotificationType implements BlueprintInterface
|
||||
{
|
||||
protected $subject;
|
||||
public static $subjectModel;
|
||||
|
||||
public function __construct($subject)
|
||||
{
|
||||
$this->subject = $subject;
|
||||
}
|
||||
|
||||
public function getFromUser(): ?User
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getSubject(): ?AbstractModel
|
||||
{
|
||||
return $this->subject;
|
||||
}
|
||||
|
||||
public function getData(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public static function getType(): string
|
||||
{
|
||||
return 'customNotificationType';
|
||||
}
|
||||
|
||||
public static function getSubjectModel(): string
|
||||
{
|
||||
return self::$subjectModel;
|
||||
}
|
||||
}
|
@@ -18,6 +18,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 DiscussionPolicyTest extends TestCase
|
||||
{
|
||||
@@ -54,9 +55,7 @@ class DiscussionPolicyTest extends TestCase
|
||||
Carbon::setTestNow();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function rename_indefinitely()
|
||||
{
|
||||
$this->setting('allow_renaming', '-1');
|
||||
@@ -76,9 +75,7 @@ class DiscussionPolicyTest extends TestCase
|
||||
$this->assertTrue($user->can('rename', $discussion));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function rename_until_reply()
|
||||
{
|
||||
$this->setting('allow_renaming', 'reply');
|
||||
@@ -126,9 +123,7 @@ class DiscussionPolicyTest extends TestCase
|
||||
$this->assertFalse($user->can('rename', $discussionWithReply));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function rename_10_minutes()
|
||||
{
|
||||
$this->setting('allow_renaming', '10');
|
||||
|
@@ -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 PostPolicyTest extends TestCase
|
||||
{
|
||||
@@ -48,9 +49,7 @@ class PostPolicyTest extends TestCase
|
||||
Carbon::setTestNow();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function edit_indefinitely()
|
||||
{
|
||||
$this->setting('allow_post_editing', '-1');
|
||||
@@ -73,9 +72,7 @@ class PostPolicyTest extends TestCase
|
||||
$this->assertTrue($user->can('edit', $lastPost));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function edit_until_reply()
|
||||
{
|
||||
$this->setting('allow_post_editing', 'reply');
|
||||
@@ -98,9 +95,7 @@ class PostPolicyTest extends TestCase
|
||||
$this->assertTrue($user->can('edit', $lastPost));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function edit_10_minutes()
|
||||
{
|
||||
$this->setting('allow_post_editing', '10');
|
||||
@@ -123,9 +118,7 @@ class PostPolicyTest extends TestCase
|
||||
$this->assertFalse($user->can('edit', $lastPost));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function hide_indefinitely()
|
||||
{
|
||||
$this->setting('allow_hide_own_posts', '-1');
|
||||
@@ -148,9 +141,7 @@ class PostPolicyTest extends TestCase
|
||||
$this->assertTrue($user->can('hide', $lastPost));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function hide_until_reply()
|
||||
{
|
||||
$this->setting('allow_hide_own_posts', 'reply');
|
||||
@@ -173,9 +164,7 @@ class PostPolicyTest extends TestCase
|
||||
$this->assertTrue($user->can('hide', $lastPost));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function hide_10_minutes()
|
||||
{
|
||||
$this->setting('allow_hide_own_posts', '10');
|
||||
@@ -198,9 +187,7 @@ class PostPolicyTest extends TestCase
|
||||
$this->assertFalse($user->can('hide', $lastPost));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function hide_never()
|
||||
{
|
||||
$this->setting('allow_hide_own_posts', '0');
|
||||
|
@@ -15,6 +15,8 @@ use Flarum\Http\SlugManager;
|
||||
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 SlugDriverTest extends TestCase
|
||||
{
|
||||
@@ -38,10 +40,8 @@ class SlugDriverTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider slugInstancePairDataProvider
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('slugInstancePairDataProvider')]
|
||||
public function slugger_formats_the_correct_slug_from_instance(string $driver, string $modelClassName, int $id, string $slug)
|
||||
{
|
||||
$this->setting("slug_driver_$modelClassName", $driver);
|
||||
@@ -59,10 +59,8 @@ class SlugDriverTest extends TestCase
|
||||
$this->assertEquals($slug, $slugger->toSlug($instance));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider slugInstancePairDataProvider
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('slugInstancePairDataProvider')]
|
||||
public function slugger_returns_the_correct_instance_from_slug(string $driver, string $modelClassName, int $id, string $slug)
|
||||
{
|
||||
$this->setting("slug_driver_$modelClassName", $driver);
|
||||
@@ -73,7 +71,7 @@ class SlugDriverTest extends TestCase
|
||||
$this->assertEquals($modelClassName::query()->find($id), $slugger->fromSlug($slug, User::query()->find(1)));
|
||||
}
|
||||
|
||||
public function slugInstancePairDataProvider(): array
|
||||
public static function slugInstancePairDataProvider(): array
|
||||
{
|
||||
return [
|
||||
['default', Discussion::class, 20, '20-empty-discussion'],
|
||||
|
@@ -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>
|
||||
|
@@ -13,11 +13,12 @@ use Flarum\Foundation\Config;
|
||||
use Flarum\Foundation\MaintenanceMode;
|
||||
use Flarum\Testing\unit\TestCase;
|
||||
use InvalidArgumentException;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use RuntimeException;
|
||||
|
||||
class ConfigTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function it_complains_when_base_url_is_missing()
|
||||
{
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
@@ -25,7 +26,7 @@ class ConfigTest extends TestCase
|
||||
new Config([]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function it_wraps_base_url_in_value_object()
|
||||
{
|
||||
$config = new Config([
|
||||
@@ -38,7 +39,7 @@ class ConfigTest extends TestCase
|
||||
$this->assertEquals('https://flarum.localhost/myforum', (string) $url);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function it_has_a_helper_for_debug_mode()
|
||||
{
|
||||
$config = new Config([
|
||||
@@ -56,7 +57,7 @@ class ConfigTest extends TestCase
|
||||
$this->assertTrue($config->inDebugMode());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function it_turns_off_debug_mode_by_default()
|
||||
{
|
||||
$config = new Config([
|
||||
@@ -66,7 +67,7 @@ class ConfigTest extends TestCase
|
||||
$this->assertFalse($config->inDebugMode());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function it_has_a_helper_for_maintenance_mode()
|
||||
{
|
||||
$config = new Config([
|
||||
@@ -102,7 +103,7 @@ class ConfigTest extends TestCase
|
||||
$this->assertFalse($config->inHighMaintenanceMode());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function it_turns_off_maintenance_mode_by_default()
|
||||
{
|
||||
$config = new Config([
|
||||
@@ -112,7 +113,7 @@ class ConfigTest extends TestCase
|
||||
$this->assertFalse($config->inHighMaintenanceMode());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function it_exposes_additional_keys_via_array_access()
|
||||
{
|
||||
$config = new Config([
|
||||
@@ -123,7 +124,7 @@ class ConfigTest extends TestCase
|
||||
$this->assertEquals('b', $config['custom_a']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function it_exposes_nested_keys_via_dot_syntax()
|
||||
{
|
||||
$config = new Config([
|
||||
@@ -138,7 +139,7 @@ class ConfigTest extends TestCase
|
||||
$this->assertEquals('2', $config['nested.second']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function it_does_not_allow_mutation_via_array_access()
|
||||
{
|
||||
$config = new Config([
|
||||
@@ -155,7 +156,7 @@ class ConfigTest extends TestCase
|
||||
$this->assertEquals('b', $config['custom_a']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function it_does_not_allow_removal_via_array_access()
|
||||
{
|
||||
$config = new Config([
|
||||
|
@@ -12,6 +12,7 @@ namespace Flarum\Tests\unit\Foundation;
|
||||
use Flarum\Foundation\ContainerUtil;
|
||||
use Flarum\Testing\unit\TestCase;
|
||||
use Illuminate\Container\Container;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class ContainerUtilTest extends TestCase
|
||||
{
|
||||
@@ -27,7 +28,7 @@ class ContainerUtilTest extends TestCase
|
||||
$this->container = new Container();
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function it_works_with_closures()
|
||||
{
|
||||
$callback = ContainerUtil::wrapCallback(function ($array) {
|
||||
@@ -43,7 +44,7 @@ class ContainerUtilTest extends TestCase
|
||||
$this->assertEquals('return', $return);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function it_works_with_invokable_classes()
|
||||
{
|
||||
$callback = ContainerUtil::wrapCallback(CustomInvokableClass::class, $this->container);
|
||||
@@ -55,7 +56,7 @@ class ContainerUtilTest extends TestCase
|
||||
$this->assertEquals('return2', $return);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function it_works_with_invokable_objects()
|
||||
{
|
||||
$callback = ContainerUtil::wrapCallback(new class {
|
||||
@@ -74,7 +75,7 @@ class ContainerUtilTest extends TestCase
|
||||
$this->assertEquals('return5', $return);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function it_works_with_global_functions()
|
||||
{
|
||||
$callback = ContainerUtil::wrapCallback('boolval', $this->container);
|
||||
@@ -86,7 +87,7 @@ class ContainerUtilTest extends TestCase
|
||||
$this->assertEquals(false, $callback(false));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function it_works_with_static_class_method_arrays()
|
||||
{
|
||||
$callback = ContainerUtil::wrapCallback([ClassWithMethod::class, 'staticMethod'], $this->container);
|
||||
@@ -94,7 +95,7 @@ class ContainerUtilTest extends TestCase
|
||||
$this->assertEquals('returnStatic', $callback());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function it_allows_passing_args_by_reference_on_closures()
|
||||
{
|
||||
$callback = ContainerUtil::wrapCallback(function (&$array) {
|
||||
@@ -110,7 +111,7 @@ class ContainerUtilTest extends TestCase
|
||||
$this->assertEquals('return3', $return);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function it_allows_passing_args_by_reference_on_invokable_classes()
|
||||
{
|
||||
$callback = ContainerUtil::wrapCallback(SecondCustomInvokableClass::class, $this->container);
|
||||
@@ -122,7 +123,7 @@ class ContainerUtilTest extends TestCase
|
||||
$this->assertEquals('return4', $return);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function it_allows_passing_args_by_reference_on_invokable_objects()
|
||||
{
|
||||
$callback = ContainerUtil::wrapCallback(new class {
|
||||
|
@@ -11,6 +11,7 @@ namespace Flarum\Tests\unit\Foundation;
|
||||
|
||||
use Flarum\Extension\ExtensionManager;
|
||||
use Flarum\Testing\unit\TestCase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class ExtensionDependencyResolutionTest extends TestCase
|
||||
{
|
||||
@@ -39,7 +40,7 @@ class ExtensionDependencyResolutionTest extends TestCase
|
||||
$this->optionalDependencyCategories = new FakeExtension('flarum-categories', ['flarum-tags'], ['flarum-tag-backgrounds', 'non-existent-optional-dependency']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function works_with_empty_set()
|
||||
{
|
||||
$expected = [
|
||||
@@ -51,7 +52,7 @@ class ExtensionDependencyResolutionTest extends TestCase
|
||||
$this->assertEquals($expected, ExtensionManager::resolveExtensionOrder([]));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function works_with_proper_data()
|
||||
{
|
||||
$exts = [$this->tags, $this->categories, $this->tagBackgrounds, $this->something, $this->help];
|
||||
@@ -65,7 +66,7 @@ class ExtensionDependencyResolutionTest extends TestCase
|
||||
$this->assertEquals($expected, ExtensionManager::resolveExtensionOrder($exts));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function works_with_missing_dependencies()
|
||||
{
|
||||
$exts = [$this->tags, $this->categories, $this->tagBackgrounds, $this->something, $this->help, $this->missing];
|
||||
@@ -79,7 +80,7 @@ class ExtensionDependencyResolutionTest extends TestCase
|
||||
$this->assertEquals($expected, ExtensionManager::resolveExtensionOrder($exts));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function works_with_circular_dependencies()
|
||||
{
|
||||
$exts = [$this->tags, $this->categories, $this->tagBackgrounds, $this->something, $this->help, $this->circular1, $this->circular2];
|
||||
@@ -93,7 +94,7 @@ class ExtensionDependencyResolutionTest extends TestCase
|
||||
$this->assertEquals($expected, ExtensionManager::resolveExtensionOrder($exts));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function works_with_optional_dependencies()
|
||||
{
|
||||
$exts = [$this->tags, $this->optionalDependencyCategories, $this->tagBackgrounds, $this->something, $this->help];
|
||||
@@ -107,7 +108,7 @@ class ExtensionDependencyResolutionTest extends TestCase
|
||||
$this->assertEquals($expected, ExtensionManager::resolveExtensionOrder($exts));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function works_with_optional_dependencies_if_optional_dependency_missing()
|
||||
{
|
||||
$exts = [$this->tags, $this->optionalDependencyCategories, $this->something, $this->help];
|
||||
|
@@ -12,10 +12,11 @@ namespace Flarum\Tests\unit\Foundation;
|
||||
use Flarum\Foundation\Paths;
|
||||
use Flarum\Testing\unit\TestCase;
|
||||
use InvalidArgumentException;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class PathsTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function it_complains_when_paths_are_missing()
|
||||
{
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
@@ -25,7 +26,7 @@ class PathsTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function it_makes_paths_available_as_properties()
|
||||
{
|
||||
$paths = new Paths([
|
||||
@@ -39,7 +40,7 @@ class PathsTest extends TestCase
|
||||
$this->assertEquals('/var/www/flarum/storage', $paths->storage);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function it_derives_the_vendor_dir_from_the_base_path()
|
||||
{
|
||||
$paths = new Paths([
|
||||
@@ -51,7 +52,7 @@ class PathsTest extends TestCase
|
||||
$this->assertEquals('/var/www/flarum/vendor', $paths->vendor);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function it_allows_setting_a_custom_vendor_dir()
|
||||
{
|
||||
$paths = new Paths([
|
||||
@@ -64,7 +65,7 @@ class PathsTest extends TestCase
|
||||
$this->assertEquals('/share/composer-vendor', $paths->vendor);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function it_strips_trailing_forward_slashes_from_paths()
|
||||
{
|
||||
$paths = new Paths([
|
||||
@@ -78,7 +79,7 @@ class PathsTest extends TestCase
|
||||
$this->assertEquals('/var/www/flarum/storage', $paths->storage);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function it_strips_trailing_backslashes_from_paths()
|
||||
{
|
||||
$paths = new Paths([
|
||||
|
@@ -11,11 +11,12 @@ namespace Flarum\Tests\unit\Foundation;
|
||||
|
||||
use Flarum\Http\RouteCollection;
|
||||
use Flarum\Testing\unit\TestCase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use RuntimeException;
|
||||
|
||||
class RouteCollectionTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function it_errors_when_nonexistent_route_requested()
|
||||
{
|
||||
$collection = new RouteCollection();
|
||||
@@ -25,7 +26,7 @@ class RouteCollectionTest extends TestCase
|
||||
$collection->getPath('nonexistent');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function it_properly_processes_a_simple_route_with_no_parameters()
|
||||
{
|
||||
$collection = new RouteCollection();
|
||||
@@ -35,7 +36,7 @@ class RouteCollectionTest extends TestCase
|
||||
$this->assertEquals('/custom/route', $collection->getPath('custom'));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function it_properly_processes_a_route_with_all_parameters_required()
|
||||
{
|
||||
$collection = new RouteCollection();
|
||||
@@ -49,7 +50,7 @@ class RouteCollectionTest extends TestCase
|
||||
]));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function it_works_if_optional_parameters_are_missing()
|
||||
{
|
||||
$collection = new RouteCollection();
|
||||
@@ -61,7 +62,7 @@ class RouteCollectionTest extends TestCase
|
||||
]));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function it_works_with_optional_parameters()
|
||||
{
|
||||
$collection = new RouteCollection();
|
||||
|
@@ -13,6 +13,7 @@ use Carbon\Carbon;
|
||||
use Flarum\Foundation\Config;
|
||||
use Flarum\Http\CookieFactory;
|
||||
use Flarum\Testing\unit\TestCase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class CookieFactoryTest extends TestCase
|
||||
{
|
||||
@@ -25,7 +26,7 @@ class CookieFactoryTest extends TestCase
|
||||
return new CookieFactory($config);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function can_create_cookies()
|
||||
{
|
||||
$cookie = $this->factory()->make('test', 'australia');
|
||||
@@ -37,7 +38,7 @@ class CookieFactoryTest extends TestCase
|
||||
$this->assertEquals('/', $cookie->getPath());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function can_override_cookie_settings_from_config()
|
||||
{
|
||||
$cookie = $this->factory([
|
||||
@@ -55,7 +56,7 @@ class CookieFactoryTest extends TestCase
|
||||
$this->assertEquals('SameSite=None', $cookie->getSameSite()->asString());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function can_expire_cookies()
|
||||
{
|
||||
$cookie = $this->factory()->expire('test');
|
||||
|
@@ -11,10 +11,11 @@ namespace Flarum\Tests\unit\Http;
|
||||
|
||||
use Flarum\Http\RouteCollection;
|
||||
use Flarum\Testing\unit\TestCase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class RouteCollectionTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function can_add_routes()
|
||||
{
|
||||
$routeCollection = (new RouteCollection)
|
||||
@@ -29,7 +30,7 @@ class RouteCollectionTest extends TestCase
|
||||
$this->assertEquals('/posts', $routeCollection->getPath('forum.posts.delete'));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function can_add_routes_late()
|
||||
{
|
||||
$routeCollection = (new RouteCollection)->addRoute('GET', '/index', 'index', function () {
|
||||
@@ -45,7 +46,7 @@ class RouteCollectionTest extends TestCase
|
||||
$this->assertEquals('/posts', $routeCollection->getPath('forum.posts.delete'));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function must_provide_required_parameters()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
@@ -58,7 +59,7 @@ class RouteCollectionTest extends TestCase
|
||||
$routeCollection->getPath('user', []);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function dont_need_to_provide_optional_parameters()
|
||||
{
|
||||
$routeCollection = (new RouteCollection)->addRoute('GET', '/user/{user}[/{test}]', 'user', function () {
|
||||
@@ -70,7 +71,7 @@ class RouteCollectionTest extends TestCase
|
||||
$this->assertEquals('/user/SomeUser', $path);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function can_provide_optional_parameters()
|
||||
{
|
||||
$routeCollection = (new RouteCollection)->addRoute('GET', '/user/{user}[/{test}]', 'user', function () {
|
||||
|
@@ -12,20 +12,17 @@ namespace Flarum\Tests\unit\Install;
|
||||
use Flarum\Install\BaseUrl;
|
||||
use Flarum\Testing\unit\TestCase;
|
||||
use Laminas\Diactoros\Uri;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
class BaseUrlTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider urlProvider
|
||||
*/
|
||||
#[DataProvider('urlProvider')]
|
||||
public function test_base_url_simulating_cli_installer($uri, $expected)
|
||||
{
|
||||
$this->assertEquals($expected, BaseUrl::fromString($uri));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider urlProvider
|
||||
*/
|
||||
#[DataProvider('urlProvider')]
|
||||
public function test_base_url_simulating_web_installer($uri, $expected)
|
||||
{
|
||||
$uri = new Uri($uri);
|
||||
@@ -33,9 +30,7 @@ class BaseUrlTest extends TestCase
|
||||
$this->assertEquals($expected, BaseUrl::fromUri($uri));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider emailProvider
|
||||
*/
|
||||
#[DataProvider('emailProvider')]
|
||||
public function test_default_email_generation($uri, $expected)
|
||||
{
|
||||
$this->assertEquals(
|
||||
@@ -44,7 +39,7 @@ class BaseUrlTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function urlProvider()
|
||||
public static function urlProvider()
|
||||
{
|
||||
return [
|
||||
['', ''],
|
||||
@@ -75,7 +70,7 @@ class BaseUrlTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
public function emailProvider()
|
||||
public static function emailProvider()
|
||||
{
|
||||
return [
|
||||
['flarum.org', 'noreply@flarum.org'],
|
||||
|
Reference in New Issue
Block a user