Convert more helpers in tests

This commit is contained in:
Franz Liedke 2019-07-06 01:11:19 +02:00
parent f4c0d4ba87
commit d66d2aa26e
No known key found for this signature in database
GPG Key ID: 9A0231A879B055F4
3 changed files with 5 additions and 3 deletions

View File

@ -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()
]);

View File

@ -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'));
}
/**

View File

@ -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");
}