mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-08-04 02:05:16 +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
|
@ -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');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue