mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-20 17:15:51 +02:00
Applied rector to remaining test files
This commit is contained in:
parent
af325612aa
commit
d898ca736c
5 changed files with 52 additions and 61 deletions
|
@ -56,13 +56,11 @@ class APIDocsAvailabilityTest extends WebTestCase
|
|||
self::assertResponseStatusCodeSame(403);
|
||||
}
|
||||
|
||||
public static function urlProvider(): array
|
||||
public static function urlProvider(): \Iterator
|
||||
{
|
||||
return [
|
||||
['/api'],
|
||||
['/api/docs.html'],
|
||||
['/api/docs.json'],
|
||||
['/api/docs.jsonld'],
|
||||
];
|
||||
yield ['/api'];
|
||||
yield ['/api/docs.html'];
|
||||
yield ['/api/docs.json'];
|
||||
yield ['/api/docs.jsonld'];
|
||||
}
|
||||
}
|
|
@ -34,14 +34,12 @@ abstract class AbstractAdminControllerTest extends WebTestCase
|
|||
protected static string $base_path = 'not_valid';
|
||||
protected static string $entity_class = 'not valid';
|
||||
|
||||
public function readDataProvider(): array
|
||||
public function readDataProvider(): \Iterator
|
||||
{
|
||||
return [
|
||||
['noread', false],
|
||||
['anonymous', true],
|
||||
['user', true],
|
||||
['admin', true],
|
||||
];
|
||||
yield ['noread', false];
|
||||
yield ['anonymous', true];
|
||||
yield ['user', true];
|
||||
yield ['admin', true];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -98,14 +96,12 @@ abstract class AbstractAdminControllerTest extends WebTestCase
|
|||
$this->assertSame($read, !$client->getResponse()->isForbidden(), 'Permission Checking not working!');
|
||||
}
|
||||
|
||||
public function deleteDataProvider(): array
|
||||
public function deleteDataProvider(): \Iterator
|
||||
{
|
||||
return [
|
||||
['noread', false],
|
||||
['anonymous', false],
|
||||
['user', true],
|
||||
['admin', true],
|
||||
];
|
||||
yield ['noread', false];
|
||||
yield ['anonymous', false];
|
||||
yield ['user', true];
|
||||
yield ['admin', true];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -50,18 +50,16 @@ class RedirectControllerTest extends WebTestCase
|
|||
$this->userRepo = $this->em->getRepository(User::class);
|
||||
}
|
||||
|
||||
public function urlMatchDataProvider(): array
|
||||
public function urlMatchDataProvider(): \Iterator
|
||||
{
|
||||
return [
|
||||
['/', true],
|
||||
['/part/2/info', true],
|
||||
['/part/de/2', true],
|
||||
['/part/en/', true],
|
||||
['/de/', false],
|
||||
['/de_DE/', false],
|
||||
['/en/', false],
|
||||
['/en_US/', false],
|
||||
];
|
||||
yield ['/', true];
|
||||
yield ['/part/2/info', true];
|
||||
yield ['/part/de/2', true];
|
||||
yield ['/part/en/', true];
|
||||
yield ['/de/', false];
|
||||
yield ['/de_DE/', false];
|
||||
yield ['/en/', false];
|
||||
yield ['/en_US/', false];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -81,22 +79,20 @@ class RedirectControllerTest extends WebTestCase
|
|||
$this->assertSame($expect_redirect, $response->isRedirect());
|
||||
}
|
||||
|
||||
public function urlAddLocaleDataProvider(): array
|
||||
public function urlAddLocaleDataProvider(): \Iterator
|
||||
{
|
||||
return [
|
||||
//User locale, original target, redirect target
|
||||
['de', '/', '/de/'],
|
||||
['de', '/part/3', '/de/part/3'],
|
||||
['en', '/', '/en/'],
|
||||
['en', '/category/new', '/en/category/new'],
|
||||
['en_US', '/part/3', '/en_US/part/3'],
|
||||
//Without an explicit set value, the user should be redirected to english version
|
||||
[null, '/', '/en/'],
|
||||
['en_US', '/part/3', '/en_US/part/3'],
|
||||
//Test that query parameters work
|
||||
['de', '/dialog?target_id=133&target_type=part', '/de/dialog?target_id=133&target_type=part'],
|
||||
['en', '/dialog?storelocation=1', '/en/dialog?storelocation=1'],
|
||||
];
|
||||
//User locale, original target, redirect target
|
||||
yield ['de', '/', '/de/'];
|
||||
yield ['de', '/part/3', '/de/part/3'];
|
||||
yield ['en', '/', '/en/'];
|
||||
yield ['en', '/category/new', '/en/category/new'];
|
||||
yield ['en_US', '/part/3', '/en_US/part/3'];
|
||||
//Without an explicit set value, the user should be redirected to english version
|
||||
yield [null, '/', '/en/'];
|
||||
yield ['en_US', '/part/3', '/en_US/part/3'];
|
||||
//Test that query parameters work
|
||||
yield ['de', '/dialog?target_id=133&target_type=part', '/de/dialog?target_id=133&target_type=part'];
|
||||
yield ['en', '/dialog?storelocation=1', '/en/dialog?storelocation=1'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -17,7 +20,6 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Tests\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
|
||||
|
@ -49,4 +51,4 @@ class ScanControllerTest extends WebTestCase
|
|||
$this->client->request('GET', '/scan/part/1');
|
||||
$this->assertResponseRedirects('/en/part/1');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -17,7 +20,6 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Tests\Services\InfoProviderSystem\DTOs;
|
||||
|
||||
use App\Services\InfoProviderSystem\DTOs\FileDTO;
|
||||
|
@ -27,18 +29,15 @@ class FileDTOTest extends TestCase
|
|||
{
|
||||
|
||||
|
||||
public static function escapingDataProvider(): array
|
||||
public static function escapingDataProvider(): \Iterator
|
||||
{
|
||||
return [
|
||||
//Normal URLs must be unchanged, even if they contain special characters
|
||||
["https://localhost:8000/en/part/1335/edit#attachments", "https://localhost:8000/en/part/1335/edit#attachments"],
|
||||
["https://localhost:8000/en/part/1335/edit?test=%20%20&sfee_aswer=test-223!*()", "https://localhost:8000/en/part/1335/edit?test=%20%20&sfee_aswer=test-223!*()"],
|
||||
|
||||
//Remaining URL unsafe characters must be escaped
|
||||
["test%5Ese", "test^se"],
|
||||
["test%20se", "test se"],
|
||||
["test%7Cse", "test|se"],
|
||||
];
|
||||
//Normal URLs must be unchanged, even if they contain special characters
|
||||
yield ["https://localhost:8000/en/part/1335/edit#attachments", "https://localhost:8000/en/part/1335/edit#attachments"];
|
||||
yield ["https://localhost:8000/en/part/1335/edit?test=%20%20&sfee_aswer=test-223!*()", "https://localhost:8000/en/part/1335/edit?test=%20%20&sfee_aswer=test-223!*()"];
|
||||
//Remaining URL unsafe characters must be escaped
|
||||
yield ["test%5Ese", "test^se"];
|
||||
yield ["test%20se", "test se"];
|
||||
yield ["test%7Cse", "test|se"];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue