Migrated phpunit annotations to attributes

This commit is contained in:
Jan Böhmer 2025-07-14 00:32:06 +02:00
parent f1d34bbc24
commit dc480f755c
50 changed files with 171 additions and 246 deletions

View file

@ -22,13 +22,13 @@ declare(strict_types=1);
namespace App\Tests\Controller\AdminPages;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\DataProvider;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
/**
* @group slow
* @group DB
*/
#[Group('slow')]
#[Group('DB')]
abstract class AbstractAdminControllerTest extends WebTestCase
{
protected static string $base_path = 'not_valid';
@ -43,10 +43,10 @@ abstract class AbstractAdminControllerTest extends WebTestCase
}
/**
* @dataProvider readDataProvider
* @group slow
* Tests if you can access the /new part which is used to list all entities. Checks if permissions are working
*/
#[DataProvider('readDataProvider')]
#[Group('slow')]
public function testListEntries(string $user, bool $read): void
{
static::ensureKernelShutdown();
@ -72,10 +72,13 @@ abstract class AbstractAdminControllerTest extends WebTestCase
}
/**
* @dataProvider readDataProvider
* @group slow
* Tests if it is possible to access a specific entity. Checks if permissions are working.
* @param string $user
* @param bool $read
* @return void
*/
#[DataProvider('readDataProvider')]
#[Group('slow')]
public function testReadEntity(string $user, bool $read): void
{
//Test read access
@ -106,10 +109,9 @@ abstract class AbstractAdminControllerTest extends WebTestCase
/**
* Tests if deleting an entity is working.
*
* @group slow
* @dataProvider deleteDataProvider
*/
#[DataProvider('deleteDataProvider')]
#[Group('slow')]
public function testDeleteEntity(string $user, bool $delete): void
{
//Test read access

View file

@ -22,12 +22,11 @@ declare(strict_types=1);
namespace App\Tests\Controller\AdminPages;
use PHPUnit\Framework\Attributes\Group;
use App\Entity\Attachments\AttachmentType;
/**
* @group slow
* @group DB
*/
#[Group('slow')]
#[Group('DB')]
class AttachmentTypeControllerTest extends AbstractAdminControllerTest
{
protected static string $base_path = '/en/attachment_type';

View file

@ -22,12 +22,11 @@ declare(strict_types=1);
namespace App\Tests\Controller\AdminPages;
use PHPUnit\Framework\Attributes\Group;
use App\Entity\Parts\Category;
/**
* @group slow
* @group DB
*/
#[Group('slow')]
#[Group('DB')]
class CategoryControllerTest extends AbstractAdminControllerTest
{
protected static string $base_path = '/en/category';

View file

@ -22,12 +22,11 @@ declare(strict_types=1);
namespace App\Tests\Controller\AdminPages;
use PHPUnit\Framework\Attributes\Group;
use App\Entity\Parts\Footprint;
/**
* @group slow
* @group DB
*/
#[Group('slow')]
#[Group('DB')]
class FootprintControllerTest extends AbstractAdminControllerTest
{
protected static string $base_path = '/en/footprint';

View file

@ -41,6 +41,8 @@ declare(strict_types=1);
namespace App\Tests\Controller\AdminPages;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
use App\Entity\LabelSystem\LabelProfile;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
@ -51,10 +53,9 @@ class LabelProfileControllerTest extends AbstractAdminControllerTest
/**
* Tests if deleting an entity is working.
*
* @group slow
* @dataProvider deleteDataProvider
*/
#[DataProvider('deleteDataProvider')]
#[Group('slow')]
public function testDeleteEntity(string $user, bool $delete): void
{
//Test read access

View file

@ -22,12 +22,11 @@ declare(strict_types=1);
namespace App\Tests\Controller\AdminPages;
use PHPUnit\Framework\Attributes\Group;
use App\Entity\Parts\Manufacturer;
/**
* @group slow
* @group DB
*/
#[Group('slow')]
#[Group('DB')]
class ManufacturerControllerTest extends AbstractAdminControllerTest
{
protected static string $base_path = '/en/manufacturer';

View file

@ -22,12 +22,11 @@ declare(strict_types=1);
namespace App\Tests\Controller\AdminPages;
use PHPUnit\Framework\Attributes\Group;
use App\Entity\Parts\MeasurementUnit;
/**
* @group slow
* @group DB
*/
#[Group('slow')]
#[Group('DB')]
class MeasurementUnitControllerTest extends AbstractAdminControllerTest
{
protected static string $base_path = '/en/measurement_unit';

View file

@ -23,12 +23,11 @@ declare(strict_types=1);
namespace App\Tests\Controller\AdminPages;
use PHPUnit\Framework\Attributes\Group;
use App\Entity\ProjectSystem\Project;
/**
* @group slow
* @group DB
*/
#[Group('slow')]
#[Group('DB')]
class ProjectControllerTest extends AbstractAdminControllerTest
{
protected static string $base_path = '/en/project';

View file

@ -22,12 +22,11 @@ declare(strict_types=1);
namespace App\Tests\Controller\AdminPages;
use PHPUnit\Framework\Attributes\Group;
use App\Entity\Parts\StorageLocation;
/**
* @group slow
* @group DB
*/
#[Group('slow')]
#[Group('DB')]
class StorelocationControllerTest extends AbstractAdminControllerTest
{
protected static string $base_path = '/en/store_location';

View file

@ -22,12 +22,11 @@ declare(strict_types=1);
namespace App\Tests\Controller\AdminPages;
use PHPUnit\Framework\Attributes\Group;
use App\Entity\Parts\Supplier;
/**
* @group slow
* @group DB
*/
#[Group('slow')]
#[Group('DB')]
class SupplierControllerTest extends AbstractAdminControllerTest
{
protected static string $base_path = '/en/supplier';

View file

@ -22,16 +22,17 @@ declare(strict_types=1);
namespace App\Tests\Controller;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Depends;
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use App\Entity\UserSystem\User;
use App\Repository\UserRepository;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
/**
* @group slow
* @group DB
*/
#[Group('slow')]
#[Group('DB')]
class RedirectControllerTest extends WebTestCase
{
protected EntityManagerInterface $em;
@ -64,10 +65,9 @@ class RedirectControllerTest extends WebTestCase
/**
* Test if a certain request to an url will be redirected.
*
* @dataProvider urlMatchDataProvider
* @group slow
*/
#[DataProvider('urlMatchDataProvider')]
#[Group('slow')]
public function testUrlMatch($url, $expect_redirect): void
{
//$client = static::createClient();
@ -97,11 +97,10 @@ class RedirectControllerTest extends WebTestCase
/**
* Test if the user is redirected to the localized version of a page, based on his settings.
*
* @dataProvider urlAddLocaleDataProvider
* @group slow
* @depends testUrlMatch
*/
#[Depends('testUrlMatch')]
#[DataProvider('urlAddLocaleDataProvider')]
#[Group('slow')]
public function testAddLocale(?string $user_locale, string $input_path, string $redirect_path): void
{
//Redirect path is absolute
@ -121,10 +120,9 @@ class RedirectControllerTest extends WebTestCase
/**
* Test if the user is redirected to the localized version of a page, based on his settings.
* We simulate the situation of a reverse proxy here, by adding a prefix to the path.
*
* @dataProvider urlAddLocaleDataProvider
* @group slow
*/
#[DataProvider('urlAddLocaleDataProvider')]
#[Group('slow')]
public function testAddLocaleReverseProxy(?string $user_locale, string $input_path, string $redirect_path): void
{
//Input path remains unchanged, as this is what the server receives from the proxy
@ -147,10 +145,9 @@ class RedirectControllerTest extends WebTestCase
/**
* Test if the user is redirected to the localized version of a page, based on his settings.
* We simulate the situation of serving Part-DB in a subfolder here.
*
* @dataProvider urlAddLocaleDataProvider
* @group slow
*/
#[DataProvider('urlAddLocaleDataProvider')]
#[Group('slow')]
public function testAddLocaleSubfolder(?string $user_locale, string $input_path, string $redirect_path): void
{
//Prefix our path with the proxy prefix