mirror of
https://github.com/wallabag/wallabag.git
synced 2025-08-01 17:38:38 +00:00
Fix createClient() depreciation
This commit is contained in:
parent
a351b0aada
commit
babe87c33b
6 changed files with 22 additions and 12 deletions
|
@ -31,7 +31,7 @@ class ConfigRestControllerTest extends WallabagApiTestCase
|
||||||
|
|
||||||
public function testGetConfigWithoutAuthentication()
|
public function testGetConfigWithoutAuthentication()
|
||||||
{
|
{
|
||||||
$client = static::createClient();
|
$client = $this->createUnauthorizedClient();
|
||||||
$client->request('GET', '/api/config.json');
|
$client->request('GET', '/api/config.json');
|
||||||
$this->assertSame(401, $client->getResponse()->getStatusCode());
|
$this->assertSame(401, $client->getResponse()->getStatusCode());
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ class UserRestControllerTest extends WallabagApiTestCase
|
||||||
|
|
||||||
public function testGetUserWithoutAuthentication()
|
public function testGetUserWithoutAuthentication()
|
||||||
{
|
{
|
||||||
$client = static::createClient();
|
$client = $this->createUnauthorizedClient();
|
||||||
$client->request('GET', '/api/user.json');
|
$client->request('GET', '/api/user.json');
|
||||||
$this->assertSame(401, $client->getResponse()->getStatusCode());
|
$this->assertSame(401, $client->getResponse()->getStatusCode());
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ class UserRestControllerTest extends WallabagApiTestCase
|
||||||
public function testCreateNewUserWithoutAuthentication()
|
public function testCreateNewUserWithoutAuthentication()
|
||||||
{
|
{
|
||||||
// create a new client instead of using $this->client to be sure client isn't authenticated
|
// create a new client instead of using $this->client to be sure client isn't authenticated
|
||||||
$client = static::createClient();
|
$client = $this->createUnauthorizedClient();
|
||||||
$client->getContainer()->get(Config::class)->set('api_user_registration', 1);
|
$client->getContainer()->get(Config::class)->set('api_user_registration', 1);
|
||||||
$client->request('PUT', '/api/user.json', [
|
$client->request('PUT', '/api/user.json', [
|
||||||
'username' => 'google',
|
'username' => 'google',
|
||||||
|
@ -115,7 +115,7 @@ class UserRestControllerTest extends WallabagApiTestCase
|
||||||
|
|
||||||
public function testCreateNewUserWithExistingEmail()
|
public function testCreateNewUserWithExistingEmail()
|
||||||
{
|
{
|
||||||
$client = static::createClient();
|
$client = $this->createUnauthorizedClient();
|
||||||
$client->getContainer()->get(Config::class)->set('api_user_registration', 1);
|
$client->getContainer()->get(Config::class)->set('api_user_registration', 1);
|
||||||
$client->request('PUT', '/api/user.json', [
|
$client->request('PUT', '/api/user.json', [
|
||||||
'username' => 'admin',
|
'username' => 'admin',
|
||||||
|
@ -144,7 +144,7 @@ class UserRestControllerTest extends WallabagApiTestCase
|
||||||
|
|
||||||
public function testCreateNewUserWithTooShortPassword()
|
public function testCreateNewUserWithTooShortPassword()
|
||||||
{
|
{
|
||||||
$client = static::createClient();
|
$client = $this->createUnauthorizedClient();
|
||||||
$client->getContainer()->get(Config::class)->set('api_user_registration', 1);
|
$client->getContainer()->get(Config::class)->set('api_user_registration', 1);
|
||||||
$client->request('PUT', '/api/user.json', [
|
$client->request('PUT', '/api/user.json', [
|
||||||
'username' => 'facebook',
|
'username' => 'facebook',
|
||||||
|
@ -168,7 +168,7 @@ class UserRestControllerTest extends WallabagApiTestCase
|
||||||
|
|
||||||
public function testCreateNewUserWhenRegistrationIsDisabled()
|
public function testCreateNewUserWhenRegistrationIsDisabled()
|
||||||
{
|
{
|
||||||
$client = static::createClient();
|
$client = $this->createUnauthorizedClient();
|
||||||
$client->request('PUT', '/api/user.json', [
|
$client->request('PUT', '/api/user.json', [
|
||||||
'username' => 'facebook',
|
'username' => 'facebook',
|
||||||
'password' => 'face',
|
'password' => 'face',
|
||||||
|
|
|
@ -10,7 +10,7 @@ class WallabagRestControllerTest extends WallabagApiTestCase
|
||||||
public function testGetVersion()
|
public function testGetVersion()
|
||||||
{
|
{
|
||||||
// create a new client instead of using $this->client to be sure client isn't authenticated
|
// create a new client instead of using $this->client to be sure client isn't authenticated
|
||||||
$client = static::createClient();
|
$client = $this->createUnauthorizedClient();
|
||||||
$client->request('GET', '/api/version');
|
$client->request('GET', '/api/version');
|
||||||
|
|
||||||
$this->assertSame(200, $client->getResponse()->getStatusCode());
|
$this->assertSame(200, $client->getResponse()->getStatusCode());
|
||||||
|
@ -23,7 +23,7 @@ class WallabagRestControllerTest extends WallabagApiTestCase
|
||||||
public function testGetInfo()
|
public function testGetInfo()
|
||||||
{
|
{
|
||||||
// create a new client instead of using $this->client to be sure client isn't authenticated
|
// create a new client instead of using $this->client to be sure client isn't authenticated
|
||||||
$client = static::createClient();
|
$client = $this->createUnauthorizedClient();
|
||||||
$client->request('GET', '/api/info');
|
$client->request('GET', '/api/info');
|
||||||
|
|
||||||
$this->assertSame(200, $client->getResponse()->getStatusCode());
|
$this->assertSame(200, $client->getResponse()->getStatusCode());
|
||||||
|
@ -40,7 +40,7 @@ class WallabagRestControllerTest extends WallabagApiTestCase
|
||||||
public function testAllowedRegistration()
|
public function testAllowedRegistration()
|
||||||
{
|
{
|
||||||
// create a new client instead of using $this->client to be sure client isn't authenticated
|
// create a new client instead of using $this->client to be sure client isn't authenticated
|
||||||
$client = static::createClient();
|
$client = $this->createUnauthorizedClient();
|
||||||
|
|
||||||
if (!$client->getContainer()->getParameter('fosuser_registration')) {
|
if (!$client->getContainer()->getParameter('fosuser_registration')) {
|
||||||
$this->markTestSkipped('fosuser_registration is not enabled.');
|
$this->markTestSkipped('fosuser_registration is not enabled.');
|
||||||
|
|
|
@ -31,12 +31,22 @@ abstract class WallabagApiTestCase extends WebTestCase
|
||||||
$this->client = $this->createAuthorizedClient();
|
$this->client = $this->createAuthorizedClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return KernelBrowser
|
||||||
|
*/
|
||||||
|
protected function createUnauthorizedClient()
|
||||||
|
{
|
||||||
|
static::ensureKernelShutdown();
|
||||||
|
|
||||||
|
return static::createClient();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return KernelBrowser
|
* @return KernelBrowser
|
||||||
*/
|
*/
|
||||||
protected function createAuthorizedClient()
|
protected function createAuthorizedClient()
|
||||||
{
|
{
|
||||||
$client = static::createClient();
|
$client = $this->createUnauthorizedClient();
|
||||||
$container = $client->getContainer();
|
$container = $client->getContainer();
|
||||||
|
|
||||||
/** @var UserManager $userManager */
|
/** @var UserManager $userManager */
|
||||||
|
|
|
@ -76,7 +76,7 @@ class InstallCommandTest extends WallabagCoreTestCase
|
||||||
} else {
|
} else {
|
||||||
// Create a new client to avoid the error:
|
// Create a new client to avoid the error:
|
||||||
// Transaction commit failed because the transaction has been marked for rollback only.
|
// Transaction commit failed because the transaction has been marked for rollback only.
|
||||||
$client = static::createClient();
|
$client = $this->getNewClient();
|
||||||
$this->resetDatabase($client);
|
$this->resetDatabase($client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ abstract class WallabagCoreTestCase extends WebTestCase
|
||||||
* [Doctrine\DBAL\ConnectionException]
|
* [Doctrine\DBAL\ConnectionException]
|
||||||
* Transaction commit failed because the transaction has been marked for rollback only.
|
* Transaction commit failed because the transaction has been marked for rollback only.
|
||||||
*/
|
*/
|
||||||
$this->client = static::createClient();
|
$this->client = $this->getNewClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEntityManager()
|
public function getEntityManager()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue