Skip to content

Commit

Permalink
chore: remove annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
alexislefebvre committed Mar 10, 2024
1 parent d517a8f commit 927c621
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 136 deletions.
8 changes: 1 addition & 7 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
beStrictAboutOutputDuringTests="true"
processIsolation="true"
>

<php>
Expand All @@ -18,11 +19,4 @@
<directory>tests/Test</directory>
</testsuite>
</testsuites>

<groups>
<exclude>
<group>mysql</group>
<group>pgsql</group>
</exclude>
</groups>
</phpunit>
24 changes: 0 additions & 24 deletions tests/App/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,48 +16,24 @@
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity
*
* @ORM\Table(name="liip_user")
*/
#[ORM\Entity]
#[ORM\Table(name: 'liip_user')]
class User
{
/**
* @ORM\Id
*
* @ORM\Column(type="integer")
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
#[ORM\Id]
#[ORM\Column(type: Types::INTEGER)]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private ?int $id = null;

/**
* @ORM\Column
*/
#[ORM\Column]
private string $name;

/**
* @ORM\Column
*/
#[ORM\Column]
private string $salt;

/**
* @ORM\Column
*/
#[ORM\Column]
private string $email;

/**
* @ORM\Column(nullable=true)
*/
#[ORM\Column(nullable: true)]
private ?string $dummyText = null;

Expand Down
32 changes: 12 additions & 20 deletions tests/Test/ConfigEventsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@

namespace Liip\Acme\Tests\Test;

use Doctrine\Common\Annotations\Annotation\IgnoreAnnotation;
use Liip\Acme\Tests\AppConfigEvents\AppConfigEventsKernel;
use Liip\Acme\Tests\AppConfigEvents\EventListener\FixturesSubscriber;
use Liip\Acme\Tests\Traits\ContainerProvider;
use Liip\TestFixturesBundle\LiipTestFixturesEvents;
use Liip\TestFixturesBundle\Services\DatabaseToolCollection;
use Liip\TestFixturesBundle\Services\DatabaseTools\AbstractDatabaseTool;
use Liip\TestFixturesBundle\Services\DatabaseTools\ORMSqliteDatabaseTool;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\PreserveGlobalState;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;

/**
Expand All @@ -30,14 +31,9 @@
* Tests/App/AppKernel.php.
* So it must be loaded in a separate process.
*
* @runTestsInSeparateProcesses
*
* @preserveGlobalState disabled
*
* @IgnoreAnnotation("dataProvider")
*
* @internal
*/
#[PreserveGlobalState(false)]
class ConfigEventsTest extends KernelTestCase
{
use ContainerProvider;
Expand Down Expand Up @@ -88,10 +84,9 @@ public function testLoadEmptyFixturesAndCheckEvents(): void
* Check that events are called.
*
* We disable the cache to ensure that all the code is executed.
*
* @dataProvider fixturesEventsProvider
*/
public function testLoadEmptyFixturesAndCheckEventsAreCalled(string $eventName, string $methodName, int $numberOfInvocations, bool $withCache = true): void
#[DataProvider('fixturesEventsProvider')]
public function testLoadEmptyFixturesAndCheckEventsAreCalled(string $eventName, string $methodName, int $numberOfInvocations, ?bool $withCache = true): void
{
/** @var AbstractDatabaseTool $databaseTool */
$databaseTool = $this->getTestContainer()->get(DatabaseToolCollection::class)->get();
Expand Down Expand Up @@ -127,9 +122,8 @@ public function testLoadEmptyFixturesAndCheckEventsAreCalled(string $eventName,

/**
* We disable the cache to ensure that other events are called.
*
* @dataProvider fixturesEventsProvider
*/
#[DataProvider('fixturesEventsProvider')]
public function testLoadEmptyFixturesAndCheckEventsAreCalledWithoutCache(string $eventName, string $methodName, int $numberOfInvocations): void
{
// Swap 0 → 1 and 1 → 0
Expand All @@ -138,15 +132,13 @@ public function testLoadEmptyFixturesAndCheckEventsAreCalledWithoutCache(string
$this->testLoadEmptyFixturesAndCheckEventsAreCalled($eventName, $methodName, $numberOfInvocations, false);
}

public static function fixturesEventsProvider(): array
public static function fixturesEventsProvider(): iterable
{
return [
[LiipTestFixturesEvents::PRE_FIXTURE_BACKUP_RESTORE, 'preFixtureBackupRestore', 1],
[LiipTestFixturesEvents::POST_FIXTURE_SETUP, 'postFixtureSetup', 0],
[LiipTestFixturesEvents::POST_FIXTURE_BACKUP_RESTORE, 'postFixtureBackupRestore', 1],
[LiipTestFixturesEvents::PRE_REFERENCE_SAVE, 'preReferenceSave', 0],
[LiipTestFixturesEvents::POST_REFERENCE_SAVE, 'postReferenceSave', 0],
];
yield 'preFixtureBackupRestore' => [LiipTestFixturesEvents::PRE_FIXTURE_BACKUP_RESTORE, 'preFixtureBackupRestore', 1];
yield 'postFixtureSetup' => [LiipTestFixturesEvents::POST_FIXTURE_SETUP, 'postFixtureSetup', 0];
yield 'postFixtureBackupRestore' => [LiipTestFixturesEvents::POST_FIXTURE_BACKUP_RESTORE, 'postFixtureBackupRestore', 1];
yield 'preReferenceSave' => [LiipTestFixturesEvents::PRE_REFERENCE_SAVE, 'preReferenceSave', 0];
yield 'postReferenceSave' => [LiipTestFixturesEvents::POST_REFERENCE_SAVE, 'postReferenceSave', 0];
}

protected static function getKernelClass(): string
Expand Down
20 changes: 15 additions & 5 deletions tests/Test/ConfigMongodbTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

declare(strict_types=1);

/*
* This file is part of the Liip/TestFixturesBundle
*
* (c) Lukas Kahwe Smith <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Liip\Acme\Tests\Test;

/*
* This file is part of the Liip/TestFixturesBundle
*
Expand All @@ -12,6 +23,7 @@
*/

use Doctrine\Bundle\MongoDBBundle\DoctrineMongoDBBundle;
use Doctrine\Common\DataFixtures\Executor\MongoDBExecutor;
use Doctrine\Common\DataFixtures\ProxyReferenceRepository;
use Doctrine\ODM\MongoDB\Repository\DocumentRepository;
use Liip\Acme\Tests\AppConfigMongodb\AppConfigMongodbKernel;
Expand All @@ -21,6 +33,7 @@
use Liip\TestFixturesBundle\Services\DatabaseToolCollection;
use Liip\TestFixturesBundle\Services\DatabaseTools\AbstractDatabaseTool;
use Liip\TestFixturesBundle\Services\DatabaseTools\MongoDBDatabaseTool;
use PHPUnit\Framework\Attributes\PreserveGlobalState;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;

/**
Expand All @@ -30,12 +43,9 @@
* Tests/App/AppKernel.php.
* So it must be loaded in a separate process.
*
* @#runTestsInSeparateProcesses
*
* @preserveGlobalState disabled
*
* @internal
*/
#[PreserveGlobalState(false)]
class ConfigMongodbTest extends KernelTestCase
{
use ContainerProvider;
Expand Down Expand Up @@ -75,7 +85,7 @@ public function testLoadFixturesMongodb(): void
]);

$this->assertInstanceOf(
Doctrine\Common\DataFixtures\Executor\MongoDBExecutor::class,
MongoDBExecutor::class,
$fixtures
);

Expand Down
16 changes: 3 additions & 13 deletions tests/Test/ConfigMysqlCacheDbTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@

namespace Liip\Acme\Tests\Test;

use Doctrine\Common\Annotations\Annotation\IgnoreAnnotation;
use Liip\Acme\Tests\App\Entity\User;
use Liip\Acme\Tests\AppConfigMysqlCacheDb\AppConfigMysqlKernelCacheDb;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\PreserveGlobalState;

/**
* Test MySQL database with database caching enabled.
Expand All @@ -31,19 +32,11 @@
* Tests/App/AppKernel.php.
* So it must be loaded in a separate process.
*
* @runTestsInSeparateProcesses
*
* @preserveGlobalState disabled
*
* @IgnoreAnnotation("group")
*
* @internal
*/
#[PreserveGlobalState(false)]
class ConfigMysqlCacheDbTest extends ConfigMysqlTest
{
/**
* @group mysql
*/
public function testLoadFixturesAndCheckBackup(): void
{
$this->assertTrue($this->databaseTool->isDatabaseCacheEnabled());
Expand Down Expand Up @@ -114,9 +107,6 @@ public function testLoadFixturesAndCheckBackup(): void
);
}

/**
* @group mysql
*/
public function testLoadFixturesCheckReferences(): void
{
$this->markTestSkipped('This test is broken right now.');
Expand Down
9 changes: 2 additions & 7 deletions tests/Test/ConfigMysqlKeepDatabaseAndSchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

namespace Liip\Acme\Tests\Test;

use Doctrine\Common\Annotations\Annotation\IgnoreAnnotation;
use Liip\Acme\Tests\AppConfigMysqlKeepDatabaseAndSchema\AppConfigMysqlKernelKeepDatabaseAndSchema;
use PHPUnit\Framework\Attributes\PreserveGlobalState;

/**
* Test MySQL database with database caching enabled.
Expand All @@ -30,14 +30,9 @@
* Tests/App/AppKernel.php.
* So it must be loaded in a separate process.
*
* @runTestsInSeparateProcesses
*
* @preserveGlobalState disabled
*
* @IgnoreAnnotation("group")
*
* @internal
*/
#[PreserveGlobalState(false)]
class ConfigMysqlKeepDatabaseAndSchemaTest extends ConfigMysqlTest
{
protected static function getKernelClass(): string
Expand Down
26 changes: 2 additions & 24 deletions tests/Test/ConfigMysqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

namespace Liip\Acme\Tests\Test;

use Doctrine\Common\Annotations\Annotation\IgnoreAnnotation;
use Doctrine\Common\DataFixtures\Purger\ORMPurger;
use Doctrine\Persistence\ObjectRepository;
use Liip\Acme\Tests\App\Entity\User;
Expand All @@ -22,6 +21,7 @@
use Liip\TestFixturesBundle\Services\DatabaseToolCollection;
use Liip\TestFixturesBundle\Services\DatabaseTools\AbstractDatabaseTool;
use Liip\TestFixturesBundle\Services\DatabaseTools\ORMDatabaseTool;
use PHPUnit\Framework\Attributes\PreserveGlobalState;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;

// BC, needed by "theofidry/alice-data-fixtures: <1.3" not compatible with "doctrine/persistence: ^2.0"
Expand All @@ -44,14 +44,9 @@ class_alias('\Doctrine\Persistence\ObjectManager', '\Doctrine\Common\Persistence
* Tests/App/AppKernel.php.
* So it must be loaded in a separate process.
*
* @runTestsInSeparateProcesses
*
* @preserveGlobalState disabled
*
* @IgnoreAnnotation("group")
*
* @internal
*/
#[PreserveGlobalState(false)]
class ConfigMysqlTest extends KernelTestCase
{
use ContainerProvider;
Expand All @@ -77,11 +72,6 @@ protected function setUp(): void
$this->assertInstanceOf(ORMDatabaseTool::class, $this->databaseTool);
}

/**
* Data fixtures.
*
* @group mysql
*/
public function testLoadEmptyFixtures(): void
{
$fixtures = $this->databaseTool->loadFixtures([]);
Expand All @@ -92,9 +82,6 @@ public function testLoadEmptyFixtures(): void
);
}

/**
* @group mysql
*/
public function testLoadFixtures(int $firstUserId = 1): void
{
$fixtures = $this->databaseTool->loadFixtures([
Expand Down Expand Up @@ -132,9 +119,6 @@ public function testLoadFixtures(int $firstUserId = 1): void
);
}

/**
* @group mysql
*/
public function testAppendFixtures(int $firstUserId = 1, int $thirdUserId = 3): void
{
$this->databaseTool->loadFixtures([
Expand Down Expand Up @@ -189,8 +173,6 @@ public function testAppendFixtures(int $firstUserId = 1, int $thirdUserId = 3):
*
* Purge modes are defined in
* Doctrine\Common\DataFixtures\Purger\ORMPurger.
*
* @group mysql
*/
public function testLoadFixturesAndExcludeFromPurge(): void
{
Expand Down Expand Up @@ -227,8 +209,6 @@ public function testLoadFixturesAndExcludeFromPurge(): void
*
* Purge modes are defined in
* Doctrine\Common\DataFixtures\Purger\ORMPurger.
*
* @group mysql
*/
public function testLoadFixturesAndPurge(): void
{
Expand Down Expand Up @@ -289,8 +269,6 @@ public function testLoadFixturesAndPurge(): void

/**
* Use nelmio/alice.
*
* @group mysql
*/
public function testLoadFixturesFiles(): void
{
Expand Down
6 changes: 2 additions & 4 deletions tests/Test/ConfigMysqlUrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace Liip\Acme\Tests\Test;

use Liip\Acme\Tests\AppConfigMysqlUrl\AppConfigMysqlUrlKernel;
use PHPUnit\Framework\Attributes\PreserveGlobalState;

/**
* Test MySQL database with a configuration by url.
Expand All @@ -29,12 +30,9 @@
* Tests/App/AppKernel.php.
* So it must be loaded in a separate process.
*
* @runTestsInSeparateProcesses
*
* @preserveGlobalState disabled
*
* @internal
*/
#[PreserveGlobalState(false)]
class ConfigMysqlUrlTest extends ConfigMysqlTest
{
protected static function getKernelClass(): string
Expand Down
Loading

0 comments on commit 927c621

Please sign in to comment.