framework/tests/integration/api/Controller/CreateTokenControllerTest.php
luceos 1948b7e6f4 Apply fixes from StyleCI
[ci skip] [skip ci]
2020-02-04 21:11:08 +00:00

49 lines
1.1 KiB
PHP

<?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\api\Controller;
use Flarum\Api\Controller\CreateTokenController;
use Flarum\Http\AccessToken;
class CreateTokenControllerTest extends ApiControllerTestCase
{
protected $controller = CreateTokenController::class;
public function setUp()
{
parent::setUp();
$this->prepareDatabase([
'users' => [
$this->normalUser(),
],
]);
}
/**
* @test
*/
public function user_generates_token()
{
$response = $this->call($this->controller, null, [], [
'identification' => 'normal',
'password' => 'too-obscure'
]);
$data = json_decode($response->getBody()->getContents(), true);
$this->assertEquals(2, $data['userId']);
$token = $data['token'];
$this->assertEquals(2, AccessToken::findOrFail($token)->user_id);
}
}