mirror of
https://github.com/flarum/core.git
synced 2025-08-09 18:07:02 +02:00
Run API Client requests through middleware (#2783)
- Add integration tests for login and registration - Use URL instead of controller - Add fluent API - Allow setting parent request, user, session
This commit is contained in:
committed by
GitHub
parent
b0a26eb78c
commit
104a31ba30
72
tests/integration/forum/IndexTest.php
Normal file
72
tests/integration/forum/IndexTest.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?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\forum;
|
||||
|
||||
use Flarum\Extend;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
|
||||
class IndexTest extends TestCase
|
||||
{
|
||||
use RetrievesAuthorizedUsers;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->extend(
|
||||
(new Extend\Csrf)->exemptRoute('login')
|
||||
);
|
||||
|
||||
$this->prepareDatabase([
|
||||
'users' => [
|
||||
$this->normalUser()
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function guest_not_serialized_by_current_user_serializer()
|
||||
{
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/')
|
||||
);
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertStringNotContainsString('preferences', $response->getBody()->getContents());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function user_serialized_by_current_user_serializer()
|
||||
{
|
||||
$login = $this->send(
|
||||
$this->request('POST', '/login', [
|
||||
'json' => [
|
||||
'identification' => 'normal',
|
||||
'password' => 'too-obscure'
|
||||
]
|
||||
])
|
||||
);
|
||||
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/', [
|
||||
'cookiesFrom' => $login
|
||||
])
|
||||
);
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertStringContainsString('preferences', $response->getBody()->getContents());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user