1
0
mirror of https://github.com/flarum/core.git synced 2025-08-07 00:47:00 +02:00

Convert another controller test to feature test

Decouple from implementation, test closer to HTTP...
This commit is contained in:
Franz Liedke
2019-09-13 14:58:00 +02:00
parent 588cbaee2d
commit c330662241
2 changed files with 63 additions and 50 deletions

View File

@@ -1,50 +0,0 @@
<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full 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);
}
}