mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-12-20 18:09:30 +00:00
Applied code style to tests/
This commit is contained in:
parent
f861de791f
commit
fe0f69f762
44 changed files with 427 additions and 306 deletions
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
|
@ -48,7 +51,7 @@ abstract class AbstractAdminControllerTest extends WebTestCase
|
|||
* @group slow
|
||||
* Tests if you can access the /new part which is used to list all entities. Checks if permissions are working
|
||||
*/
|
||||
public function testListEntries(string $user, bool $read)
|
||||
public function testListEntries(string $user, bool $read): void
|
||||
{
|
||||
static::ensureKernelShutdown();
|
||||
|
||||
|
|
@ -58,7 +61,7 @@ abstract class AbstractAdminControllerTest extends WebTestCase
|
|||
'PHP_AUTH_PW' => 'test',
|
||||
]);
|
||||
|
||||
if (false == $read) {
|
||||
if (false === $read) {
|
||||
$this->expectException(AccessDeniedException::class);
|
||||
}
|
||||
|
||||
|
|
@ -67,8 +70,8 @@ abstract class AbstractAdminControllerTest extends WebTestCase
|
|||
//Test read/list access by access /new overview page
|
||||
$crawler = $client->request('GET', static::$base_path.'/new');
|
||||
$this->assertFalse($client->getResponse()->isRedirect());
|
||||
$this->assertEquals($read, $client->getResponse()->isSuccessful(), 'Controller was not successful!');
|
||||
$this->assertEquals($read, !$client->getResponse()->isForbidden(), 'Permission Checking not working!');
|
||||
$this->assertSame($read, $client->getResponse()->isSuccessful(), 'Controller was not successful!');
|
||||
$this->assertSame($read, ! $client->getResponse()->isForbidden(), 'Permission Checking not working!');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -76,7 +79,7 @@ abstract class AbstractAdminControllerTest extends WebTestCase
|
|||
* @group slow
|
||||
* Tests if it possible to access an specific entity. Checks if permissions are working.
|
||||
*/
|
||||
public function testReadEntity(string $user, bool $read)
|
||||
public function testReadEntity(string $user, bool $read): void
|
||||
{
|
||||
//Test read access
|
||||
$client = static::createClient([], [
|
||||
|
|
@ -85,15 +88,15 @@ abstract class AbstractAdminControllerTest extends WebTestCase
|
|||
]);
|
||||
|
||||
$client->catchExceptions(false);
|
||||
if (false == $read) {
|
||||
if (false === $read) {
|
||||
$this->expectException(AccessDeniedException::class);
|
||||
}
|
||||
|
||||
//Test read/list access by access /new overview page
|
||||
$crawler = $client->request('GET', static::$base_path.'/1');
|
||||
$this->assertFalse($client->getResponse()->isRedirect());
|
||||
$this->assertEquals($read, $client->getResponse()->isSuccessful(), 'Controller was not successful!');
|
||||
$this->assertEquals($read, !$client->getResponse()->isForbidden(), 'Permission Checking not working!');
|
||||
$this->assertSame($read, $client->getResponse()->isSuccessful(), 'Controller was not successful!');
|
||||
$this->assertSame($read, ! $client->getResponse()->isForbidden(), 'Permission Checking not working!');
|
||||
}
|
||||
|
||||
public function deleteDataProvider()
|
||||
|
|
@ -112,7 +115,7 @@ abstract class AbstractAdminControllerTest extends WebTestCase
|
|||
* @group slow
|
||||
* @dataProvider deleteDataProvider
|
||||
*/
|
||||
public function testDeleteEntity(string $user, bool $delete)
|
||||
public function testDeleteEntity(string $user, bool $delete): void
|
||||
{
|
||||
//Test read access
|
||||
$client = static::createClient([], [
|
||||
|
|
@ -121,7 +124,7 @@ abstract class AbstractAdminControllerTest extends WebTestCase
|
|||
]);
|
||||
|
||||
$client->catchExceptions(false);
|
||||
if (false == $delete) {
|
||||
if (false === $delete) {
|
||||
$this->expectException(AccessDeniedException::class);
|
||||
}
|
||||
|
||||
|
|
@ -129,7 +132,7 @@ abstract class AbstractAdminControllerTest extends WebTestCase
|
|||
$crawler = $client->request('DELETE', static::$base_path.'/7');
|
||||
|
||||
//Page is redirected to '/new', when delete was successful
|
||||
$this->assertEquals($delete, $client->getResponse()->isRedirect(static::$base_path.'/new'));
|
||||
$this->assertEquals($delete, !$client->getResponse()->isForbidden(), 'Permission Checking not working!');
|
||||
$this->assertSame($delete, $client->getResponse()->isRedirect(static::$base_path.'/new'));
|
||||
$this->assertSame($delete, ! $client->getResponse()->isForbidden(), 'Permission Checking not working!');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
|
@ -35,7 +38,7 @@ class RedirectControllerTest extends WebTestCase
|
|||
protected $userRepo;
|
||||
protected $client;
|
||||
|
||||
public function setUp(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->client = static::createClient([], [
|
||||
'PHP_AUTH_USER' => 'user',
|
||||
|
|
@ -66,15 +69,15 @@ class RedirectControllerTest extends WebTestCase
|
|||
* @dataProvider urlMatchDataProvider
|
||||
* @group slow
|
||||
*/
|
||||
public function testUrlMatch($url, $expect_redirect)
|
||||
public function testUrlMatch($url, $expect_redirect): void
|
||||
{
|
||||
//$client = static::createClient();
|
||||
$this->client->request('GET', $url);
|
||||
$response = $this->client->getResponse();
|
||||
if ($expect_redirect) {
|
||||
$this->assertEquals(302, $response->getStatusCode());
|
||||
$this->assertSame(302, $response->getStatusCode());
|
||||
}
|
||||
$this->assertEquals($expect_redirect, $response->isRedirect());
|
||||
$this->assertSame($expect_redirect, $response->isRedirect());
|
||||
}
|
||||
|
||||
public function urlAddLocaleDataProvider()
|
||||
|
|
@ -103,7 +106,7 @@ class RedirectControllerTest extends WebTestCase
|
|||
* @param $input_path
|
||||
* @param $redirect_path
|
||||
*/
|
||||
public function testAddLocale($user_locale, $input_path, $redirect_path)
|
||||
public function testAddLocale($user_locale, $input_path, $redirect_path): void
|
||||
{
|
||||
//Redirect path is absolute
|
||||
$redirect_path = 'http://localhost'.$redirect_path;
|
||||
|
|
@ -116,6 +119,6 @@ class RedirectControllerTest extends WebTestCase
|
|||
|
||||
$this->client->followRedirects(false);
|
||||
$this->client->request('GET', $input_path);
|
||||
$this->assertEquals($redirect_path, $this->client->getResponse()->headers->get('Location'));
|
||||
$this->assertSame($redirect_path, $this->client->getResponse()->headers->get('Location'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue