mirror of
https://github.com/flarum/framework.git
synced 2024-11-23 21:19:18 +08:00
Convert more helpers in tests
This commit is contained in:
parent
f4c0d4ba87
commit
d66d2aa26e
|
@ -19,6 +19,7 @@ use Flarum\Tests\integration\RetrievesAuthorizedUsers;
|
|||
use Flarum\Tests\integration\TestCase;
|
||||
use Flarum\User\Guest;
|
||||
use Flarum\User\User;
|
||||
use Illuminate\Support\Str;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\MiddlewareInterface;
|
||||
|
@ -47,7 +48,7 @@ class AuthenticateWithApiKeyTest extends TestCase
|
|||
{
|
||||
return ApiKey::unguarded(function () use ($user_id) {
|
||||
return ApiKey::query()->firstOrCreate([
|
||||
'key' => str_random(),
|
||||
'key' => Str::random(),
|
||||
'user_id' => $user_id,
|
||||
'created_at' => Carbon::now()
|
||||
]);
|
||||
|
|
|
@ -60,7 +60,7 @@ class CreateDiscussionControllerTest extends ApiControllerTestCase
|
|||
$data = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
$this->assertEquals($this->data['title'], $discussion->title);
|
||||
$this->assertEquals($this->data['title'], array_get($data, 'data.attributes.title'));
|
||||
$this->assertEquals($this->data['title'], Arr::get($data, 'data.attributes.title'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace Flarum\Tests\integration\api\Controller;
|
|||
use Flarum\Api\Controller\CreateGroupController;
|
||||
use Flarum\Group\Group;
|
||||
use Flarum\User\User;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class CreateGroupControllerTest extends ApiControllerTestCase
|
||||
|
@ -72,7 +73,7 @@ class CreateGroupControllerTest extends ApiControllerTestCase
|
|||
$group = Group::where('icon', $this->data['icon'])->firstOrFail();
|
||||
|
||||
foreach ($this->data as $property => $value) {
|
||||
$this->assertEquals($value, array_get($data, "data.attributes.$property"), "$property not matching to json response");
|
||||
$this->assertEquals($value, Arr::get($data, "data.attributes.$property"), "$property not matching to json response");
|
||||
$property = Str::snake($property);
|
||||
$this->assertEquals($value, $group->{$property}, "$property not matching to database result");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user