replace PHPUnit annotations with attributes (#5608)

This commit is contained in:
Kevin Papst
2025-08-11 18:57:42 +02:00
committed by GitHub
parent 04331420ae
commit 24778d3ffb
599 changed files with 1778 additions and 2313 deletions

View File

@@ -10,11 +10,10 @@
namespace App\Tests\Repository;
use App\Repository\InvoiceDocumentRepository;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
/**
* @covers \App\Repository\InvoiceDocumentRepository
*/
#[CoversClass(InvoiceDocumentRepository::class)]
class InvoiceDocumentRepositoryTest extends TestCase
{
/**

View File

@@ -12,10 +12,9 @@ namespace App\Tests\Repository\Loader;
use App\Entity\Activity;
use App\Entity\Project;
use App\Repository\Loader\ActivityLoader;
use PHPUnit\Framework\Attributes\CoversClass;
/**
* @covers \App\Repository\Loader\ActivityLoader
*/
#[CoversClass(ActivityLoader::class)]
class ActivityLoaderTest extends AbstractLoaderTestCase
{
public function testLoadResults(): void

View File

@@ -12,10 +12,9 @@ namespace App\Tests\Repository\Loader;
use App\Entity\Customer;
use App\Repository\Loader\CustomerLoader;
use App\Repository\Query\CustomerQuery;
use PHPUnit\Framework\Attributes\CoversClass;
/**
* @covers \App\Repository\Loader\CustomerLoader
*/
#[CoversClass(CustomerLoader::class)]
class CustomerLoaderTest extends AbstractLoaderTestCase
{
public function testLoadResults(): void

View File

@@ -12,10 +12,9 @@ namespace App\Tests\Repository\Loader;
use App\Entity\Customer;
use App\Entity\Project;
use App\Repository\Loader\ProjectLoader;
use PHPUnit\Framework\Attributes\CoversClass;
/**
* @covers \App\Repository\Loader\ProjectLoader
*/
#[CoversClass(ProjectLoader::class)]
class ProjectLoaderTest extends AbstractLoaderTestCase
{
public function testLoadResults(): void

View File

@@ -11,10 +11,9 @@ namespace App\Tests\Repository\Loader;
use App\Entity\Team;
use App\Repository\Loader\TeamLoader;
use PHPUnit\Framework\Attributes\CoversClass;
/**
* @covers \App\Repository\Loader\TeamLoader
*/
#[CoversClass(TeamLoader::class)]
class TeamLoaderTest extends AbstractLoaderTestCase
{
public function testLoadResults(): void

View File

@@ -15,11 +15,11 @@ use App\Entity\Project;
use App\Entity\Team;
use App\Entity\User;
use App\Repository\Query\BaseFormTypeQuery;
use App\Repository\Query\BaseQuery;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
/**
* @covers \App\Repository\Query\BaseQuery
*/
#[CoversClass(BaseQuery::class)]
abstract class AbstractBaseFormTypeQueryTestCase extends TestCase
{
public function assertBaseQuery(BaseFormTypeQuery $sut): void

View File

@@ -11,11 +11,11 @@ namespace App\Tests\Repository\Query;
use App\Entity\Activity;
use App\Repository\Query\ActivityFormTypeQuery;
use App\Repository\Query\BaseFormTypeQuery;
use PHPUnit\Framework\Attributes\CoversClass;
/**
* @covers \App\Repository\Query\ActivityFormTypeQuery
* @covers \App\Repository\Query\BaseFormTypeQuery
*/
#[CoversClass(ActivityFormTypeQuery::class)]
#[CoversClass(BaseFormTypeQuery::class)]
class ActivityFormTypeQueryTest extends AbstractBaseFormTypeQueryTestCase
{
public function testQuery(): void

View File

@@ -10,11 +10,11 @@
namespace App\Tests\Repository\Query;
use App\Repository\Query\ActivityQuery;
use App\Repository\Query\BaseQuery;
use PHPUnit\Framework\Attributes\CoversClass;
/**
* @covers \App\Repository\Query\ActivityQuery
* @covers \App\Repository\Query\BaseQuery
*/
#[CoversClass(ActivityQuery::class)]
#[CoversClass(BaseQuery::class)]
class ActivityQueryTest extends BaseQueryTest
{
public function testQuery(): void

View File

@@ -20,6 +20,7 @@ use App\Repository\Query\BaseQuery;
use App\Repository\Query\DateRangeInterface;
use App\Repository\Query\TimesheetQuery;
use App\Utils\SearchTerm;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Form\DataMapperInterface;
@@ -27,9 +28,7 @@ use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\FormError;
use Symfony\Component\Form\FormFactoryInterface;
/**
* @covers \App\Repository\Query\BaseQuery
*/
#[CoversClass(BaseQuery::class)]
class BaseQueryTest extends TestCase
{
public function testQuery(): void

View File

@@ -10,12 +10,12 @@
namespace App\Tests\Repository\Query;
use App\Entity\Customer;
use App\Repository\Query\BaseFormTypeQuery;
use App\Repository\Query\CustomerFormTypeQuery;
use PHPUnit\Framework\Attributes\CoversClass;
/**
* @covers \App\Repository\Query\CustomerFormTypeQuery
* @covers \App\Repository\Query\BaseFormTypeQuery
*/
#[CoversClass(CustomerFormTypeQuery::class)]
#[CoversClass(BaseFormTypeQuery::class)]
class CustomerFormTypeQueryTest extends AbstractBaseFormTypeQueryTestCase
{
public function testQuery(): void

View File

@@ -10,10 +10,9 @@
namespace App\Tests\Repository\Query;
use App\Repository\Query\CustomerQuery;
use PHPUnit\Framework\Attributes\CoversClass;
/**
* @covers \App\Repository\Query\CustomerQuery
*/
#[CoversClass(CustomerQuery::class)]
class CustomerQueryTest extends BaseQueryTest
{
public function testQuery(): void

View File

@@ -10,11 +10,11 @@
namespace App\Tests\Repository\Query;
use App\Repository\Query\ExportQuery;
use App\Repository\Query\TimesheetQuery;
use PHPUnit\Framework\Attributes\CoversClass;
/**
* @covers \App\Repository\Query\ExportQuery
* @covers \App\Repository\Query\TimesheetQuery
*/
#[CoversClass(ExportQuery::class)]
#[CoversClass(TimesheetQuery::class)]
class ExportQueryTest extends TimesheetQueryTest
{
public function testQuery(): void

View File

@@ -13,10 +13,9 @@ use App\Entity\Customer;
use App\Entity\Invoice;
use App\Repository\Query\BaseQuery;
use App\Repository\Query\InvoiceArchiveQuery;
use PHPUnit\Framework\Attributes\CoversClass;
/**
* @covers \App\Repository\Query\InvoiceArchiveQuery
*/
#[CoversClass(InvoiceArchiveQuery::class)]
class InvoiceArchiveQueryTest extends BaseQueryTest
{
public function testQuery(): void

View File

@@ -10,11 +10,11 @@
namespace App\Tests\Repository\Query;
use App\Repository\Query\InvoiceQuery;
use App\Repository\Query\TimesheetQuery;
use PHPUnit\Framework\Attributes\CoversClass;
/**
* @covers \App\Repository\Query\InvoiceQuery
* @covers \App\Repository\Query\TimesheetQuery
*/
#[CoversClass(InvoiceQuery::class)]
#[CoversClass(TimesheetQuery::class)]
class InvoiceQueryTest extends TimesheetQueryTest
{
public function testQuery(): void

View File

@@ -10,12 +10,12 @@
namespace App\Tests\Repository\Query;
use App\Entity\Project;
use App\Repository\Query\BaseFormTypeQuery;
use App\Repository\Query\ProjectFormTypeQuery;
use PHPUnit\Framework\Attributes\CoversClass;
/**
* @covers \App\Repository\Query\ProjectFormTypeQuery
* @covers \App\Repository\Query\BaseFormTypeQuery
*/
#[CoversClass(ProjectFormTypeQuery::class)]
#[CoversClass(BaseFormTypeQuery::class)]
class ProjectFormTypeQueryTest extends AbstractBaseFormTypeQueryTestCase
{
public function testQuery(): void

View File

@@ -9,12 +9,12 @@
namespace App\Tests\Repository\Query;
use App\Repository\Query\BaseQuery;
use App\Repository\Query\ProjectQuery;
use PHPUnit\Framework\Attributes\CoversClass;
/**
* @covers \App\Repository\Query\ProjectQuery
* @covers \App\Repository\Query\BaseQuery
*/
#[CoversClass(ProjectQuery::class)]
#[CoversClass(BaseQuery::class)]
class ProjectQueryTest extends BaseQueryTest
{
public function testQuery(): void

View File

@@ -9,12 +9,12 @@
namespace App\Tests\Repository\Query;
use App\Repository\Query\BaseFormTypeQuery;
use App\Repository\Query\TagFormTypeQuery;
use PHPUnit\Framework\Attributes\CoversClass;
/**
* @covers \App\Repository\Query\TagFormTypeQuery
* @covers \App\Repository\Query\BaseFormTypeQuery
*/
#[CoversClass(TagFormTypeQuery::class)]
#[CoversClass(BaseFormTypeQuery::class)]
class TagFormTypeQueryTest extends AbstractBaseFormTypeQueryTestCase
{
public function testQuery(): void

View File

@@ -10,10 +10,9 @@
namespace App\Tests\Repository\Query;
use App\Repository\Query\TagQuery;
use PHPUnit\Framework\Attributes\CoversClass;
/**
* @covers \App\Repository\Query\TagQuery
*/
#[CoversClass(TagQuery::class)]
class TagQueryTest extends BaseQueryTest
{
public function testQuery(): void

View File

@@ -11,10 +11,9 @@ namespace App\Tests\Repository\Query;
use App\Entity\User;
use App\Repository\Query\TeamQuery;
use PHPUnit\Framework\Attributes\CoversClass;
/**
* @covers \App\Repository\Query\TeamQuery
*/
#[CoversClass(TeamQuery::class)]
class TeamQueryTest extends BaseQueryTest
{
public function testQuery(): void

View File

@@ -10,12 +10,12 @@
namespace App\Tests\Repository\Query;
use App\Entity\User;
use App\Repository\Query\BaseQuery;
use App\Repository\Query\TimesheetQuery;
use PHPUnit\Framework\Attributes\CoversClass;
/**
* @covers \App\Repository\Query\TimesheetQuery
* @covers \App\Repository\Query\BaseQuery
*/
#[CoversClass(TimesheetQuery::class)]
#[CoversClass(BaseQuery::class)]
class TimesheetQueryTest extends BaseQueryTest
{
public function testQuery(): void

View File

@@ -9,12 +9,12 @@
namespace App\Tests\Repository\Query;
use App\Repository\Query\BaseFormTypeQuery;
use App\Repository\Query\UserFormTypeQuery;
use PHPUnit\Framework\Attributes\CoversClass;
/**
* @covers \App\Repository\Query\UserFormTypeQuery
* @covers \App\Repository\Query\BaseFormTypeQuery
*/
#[CoversClass(UserFormTypeQuery::class)]
#[CoversClass(BaseFormTypeQuery::class)]
class UserFormTypeQueryTest extends AbstractBaseFormTypeQueryTestCase
{
public function testQuery(): void

View File

@@ -11,10 +11,9 @@ namespace App\Tests\Repository\Query;
use App\Entity\Team;
use App\Repository\Query\UserQuery;
use PHPUnit\Framework\Attributes\CoversClass;
/**
* @covers \App\Repository\Query\UserQuery
*/
#[CoversClass(UserQuery::class)]
class UserQueryTest extends BaseQueryTest
{
public function testQuery(): void

View File

@@ -10,11 +10,10 @@
namespace App\Tests\Repository\Result;
use App\Repository\Result\TimesheetResultStatistic;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
/**
* @covers \App\Repository\Result\TimesheetResultStatistic
*/
#[CoversClass(TimesheetResultStatistic::class)]
class TimesheetResultStatisticTest extends TestCase
{
public function testConstruct(): void

View File

@@ -10,11 +10,10 @@
namespace App\Tests\Repository\Search;
use App\Repository\Search\SearchConfiguration;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
/**
* @covers \App\Repository\Search\SearchConfiguration
*/
#[CoversClass(SearchConfiguration::class)]
class SearchConfigurationTest extends TestCase
{
public function testDefaultConstruct(): void

View File

@@ -17,13 +17,15 @@ use App\Repository\Search\SearchHelper;
use App\Utils\SearchTerm;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query\Expr;
use Doctrine\ORM\Query\Expr\Andx;
use Doctrine\ORM\Query\Expr\Comparison;
use Doctrine\ORM\Query\Expr\Orx;
use Doctrine\ORM\Query\Parameter;
use Doctrine\ORM\QueryBuilder;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
/**
* @covers \App\Repository\Search\SearchHelper
*/
#[CoversClass(SearchHelper::class)]
class SearchHelperTest extends TestCase
{
public function testSearchTermIsNullDoesNotModifyQueryBuilder(): void
@@ -78,70 +80,70 @@ class SearchHelperTest extends TestCase
self::assertCount(1, $parts['join']);
self::assertArrayHasKey('testFoo', $parts['join']);
self::assertArrayHasKey('where', $parts);
self::assertInstanceOf(Expr\Andx::class, $parts['where']);
self::assertInstanceOf(Andx::class, $parts['where']);
$whereParts = $parts['where'];
self::assertEquals(1, $whereParts->count());
$whereAnd = $whereParts->getParts()[0];
self::assertInstanceOf(Expr\Andx::class, $whereAnd);
self::assertInstanceOf(Andx::class, $whereAnd);
self::assertCount(4, $whereAnd->getParts());
// meta fields
$where = $whereAnd->getParts()[0];
self::assertInstanceOf(Expr\Andx::class, $where);
self::assertInstanceOf(Andx::class, $where);
$compareParts = $where->getParts();
self::assertCount(2, $compareParts);
self::assertInstanceOf(Expr\Comparison::class, $compareParts[0]);
self::assertInstanceOf(Comparison::class, $compareParts[0]);
self::assertEquals('meta0.name', $compareParts[0]->getLeftExpr());
self::assertEquals('=', $compareParts[0]->getOperator());
self::assertEquals(':metaName0', $compareParts[0]->getRightExpr());
self::assertInstanceOf(Expr\Comparison::class, $compareParts[1]);
self::assertInstanceOf(Comparison::class, $compareParts[1]);
self::assertEquals('meta0.value', $compareParts[1]->getLeftExpr());
self::assertEquals('LIKE', $compareParts[1]->getOperator());
self::assertEquals(':metaValue0', $compareParts[1]->getRightExpr());
// negated search terms
$where = $whereAnd->getParts()[1];
self::assertInstanceOf(Expr\Orx::class, $where);
self::assertInstanceOf(Orx::class, $where);
$compareParts = $where->getParts();
self::assertCount(2, $compareParts);
self::assertEquals('testFoo.bar IS NULL', $compareParts[0]);
self::assertInstanceOf(Expr\Comparison::class, $compareParts[1]);
self::assertInstanceOf(Comparison::class, $compareParts[1]);
self::assertEquals('testFoo.bar', $compareParts[1]->getLeftExpr());
self::assertEquals('NOT LIKE', $compareParts[1]->getOperator());
self::assertEquals(':searchTerm0', $compareParts[1]->getRightExpr());
$where = $whereAnd->getParts()[2];
self::assertInstanceOf(Expr\Orx::class, $where);
self::assertInstanceOf(Orx::class, $where);
$compareParts = $where->getParts();
self::assertCount(2, $compareParts);
self::assertEquals('testFoo.tmp IS NULL', $compareParts[0]);
self::assertInstanceOf(Expr\Comparison::class, $compareParts[1]);
self::assertInstanceOf(Comparison::class, $compareParts[1]);
self::assertEquals('testFoo.tmp', $compareParts[1]->getLeftExpr());
self::assertEquals('NOT LIKE', $compareParts[1]->getOperator());
self::assertEquals(':searchTerm1', $compareParts[1]->getRightExpr());
// regular search terms
$where = $whereAnd->getParts()[3];
self::assertInstanceOf(Expr\Andx::class, $where);
self::assertInstanceOf(Andx::class, $where);
$compareParts = $where->getParts();
self::assertCount(1, $compareParts);
self::assertInstanceOf(Expr\Orx::class, $compareParts[0]);
self::assertInstanceOf(Orx::class, $compareParts[0]);
$orParts = $compareParts[0]->getParts();
self::assertCount(2, $orParts);
self::assertInstanceOf(Expr\Comparison::class, $orParts[0]);
self::assertInstanceOf(Comparison::class, $orParts[0]);
self::assertEquals('testFoo.bar', $orParts[0]->getLeftExpr());
self::assertEquals('LIKE', $orParts[0]->getOperator());
self::assertEquals(':searchTerm2', $orParts[0]->getRightExpr());
self::assertInstanceOf(Expr\Comparison::class, $orParts[1]);
self::assertInstanceOf(Comparison::class, $orParts[1]);
self::assertEquals('testFoo.tmp', $orParts[1]->getLeftExpr());
self::assertEquals('LIKE', $orParts[1]->getOperator());
self::assertEquals(':searchTerm3', $orParts[1]->getRightExpr());

View File

@@ -12,11 +12,11 @@ namespace App\Tests\Repository;
use App\Entity\Tag;
use App\Repository\TagRepository;
use App\Tests\DataFixtures\TagFixtures;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
/**
* @covers \App\Repository\TagRepository
* @group integration
*/
#[CoversClass(TagRepository::class)]
#[Group('integration')]
class TagRepositoryTest extends AbstractRepositoryTestCase
{
protected function setUp(): void

View File

@@ -15,11 +15,10 @@ use App\Entity\Project;
use App\Entity\Timesheet;
use App\Repository\TimesheetInvoiceItemRepository;
use App\Repository\TimesheetRepository;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
/**
* @covers \App\Repository\TimesheetInvoiceItemRepository
*/
#[CoversClass(TimesheetInvoiceItemRepository::class)]
class TimesheetInvoiceItemRepositoryTest extends TestCase
{
public function testSetExported(): void

View File

@@ -20,11 +20,11 @@ use App\Repository\Query\TimesheetQuery;
use App\Repository\Query\TimesheetQueryHint;
use App\Repository\TimesheetRepository;
use App\Utils\Pagination;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
/**
* @covers \App\Repository\TimesheetRepository
* @group integration
*/
#[CoversClass(TimesheetRepository::class)]
#[Group('integration')]
class TimesheetRepositoryTest extends AbstractRepositoryTestCase
{
public function testResultTypeForQueryState(): void