diff --git a/src/DependencyInjection/LiipTestFixturesExtension.php b/src/DependencyInjection/LiipTestFixturesExtension.php index 687e89af..44bd5332 100644 --- a/src/DependencyInjection/LiipTestFixturesExtension.php +++ b/src/DependencyInjection/LiipTestFixturesExtension.php @@ -37,7 +37,7 @@ public function load(array $configs, ContainerBuilder $container): void // "liip_test_fixtures.cache_db.mysql" // instead of an array "liip_test_fixtures.cache_db" // with a "mysql" key. - if (is_array($value)) { + if (\is_array($value)) { foreach ($value as $key2 => $value2) { $container->setParameter($this->getAlias().'.'.$key. '.'.$key2, $value2); diff --git a/src/LiipTestFixturesEvents.php b/src/LiipTestFixturesEvents.php index ab2bfc5b..51ded442 100644 --- a/src/LiipTestFixturesEvents.php +++ b/src/LiipTestFixturesEvents.php @@ -21,17 +21,17 @@ final class LiipTestFixturesEvents { /** @see PreFixtureBackupRestoreEvent */ - const PRE_FIXTURE_BACKUP_RESTORE = 'liip_test_fixtures.pre_fixture_backup_restore'; + public const PRE_FIXTURE_BACKUP_RESTORE = 'liip_test_fixtures.pre_fixture_backup_restore'; /** @see FixtureEvent */ - const POST_FIXTURE_SETUP = 'liip_test_fixtures.post_fixture_setup'; + public const POST_FIXTURE_SETUP = 'liip_test_fixtures.post_fixture_setup'; /** @see PostFixtureBackupRestoreEvent */ - const POST_FIXTURE_BACKUP_RESTORE = 'liip_test_fixtures.post_fixture_backup_restore'; + public const POST_FIXTURE_BACKUP_RESTORE = 'liip_test_fixtures.post_fixture_backup_restore'; /** @see ReferenceSaveEvent */ - const PRE_REFERENCE_SAVE = 'liip_test_fixtures.pre_reference_save'; + public const PRE_REFERENCE_SAVE = 'liip_test_fixtures.pre_reference_save'; /** @see ReferenceSaveEvent */ - const POST_REFERENCE_SAVE = 'liip_test_fixtures.post_reference_save'; + public const POST_REFERENCE_SAVE = 'liip_test_fixtures.post_reference_save'; } diff --git a/src/Services/DatabaseBackup/AbstractDatabaseBackup.php b/src/Services/DatabaseBackup/AbstractDatabaseBackup.php index ffc9a1f6..1660e720 100644 --- a/src/Services/DatabaseBackup/AbstractDatabaseBackup.php +++ b/src/Services/DatabaseBackup/AbstractDatabaseBackup.php @@ -1,5 +1,7 @@ metadatas as $classMetadata) { $tableName = $classMetadata->table['name']; - if (!in_array($tableName, $excludedTables)) { + if (!\in_array($tableName, $excludedTables, true)) { $truncateSql[] = 'DELETE FROM '.$tableName; // in small tables it's really faster than truncate } } @@ -121,7 +123,7 @@ protected function getReferenceBackup(): string return file_get_contents($this->getReferenceBackupFilePath()); } - protected function updateSchemaIfNeed(EntityManager $em) + protected function updateSchemaIfNeed(EntityManager $em): void { if (!self::$schemaUpdatedFlag) { $schemaTool = new SchemaTool($em); diff --git a/src/Services/DatabaseBackup/SqliteDatabaseBackup.php b/src/Services/DatabaseBackup/SqliteDatabaseBackup.php index 4429bbb5..37b40418 100644 --- a/src/Services/DatabaseBackup/SqliteDatabaseBackup.php +++ b/src/Services/DatabaseBackup/SqliteDatabaseBackup.php @@ -1,5 +1,7 @@ setPurgeMode($purgeMode); @@ -134,7 +136,7 @@ public function withPurgeMode(int $purgeMode): AbstractDatabaseTool return $newTool; } - public function withDatabaseCacheEnabled(bool $databaseCacheEnabled): AbstractDatabaseTool + public function withDatabaseCacheEnabled(bool $databaseCacheEnabled): self { $newTool = clone $this; $newTool->setDatabaseCacheEnabled($databaseCacheEnabled); @@ -158,7 +160,7 @@ public function loadAllFixtures(array $groups = []): ?AbstractExecutor $loader = $this->container->get('test.service_container')->get('doctrine.fixtures.loader'); $fixtures = $loader->getFixtures($groups); foreach ($fixtures as $fixture) { - $fixtureClasses[] = get_class($fixture); + $fixtureClasses[] = \get_class($fixture); } } @@ -199,7 +201,7 @@ protected function getBackupService(): ?DatabaseBackupInterface if ($this->container->hasParameter($backupServiceParamName)) { $backupServiceName = $this->container->getParameter($backupServiceParamName); - if (is_string($backupServiceName) && $this->container->has($backupServiceName)) { + if (\is_string($backupServiceName) && $this->container->has($backupServiceName)) { $backupService = $this->container->get($backupServiceName); } else { @trigger_error("Could not find {$backupServiceName} in container. Possible misconfiguration."); diff --git a/src/Services/DatabaseTools/MongoDBDatabaseTool.php b/src/Services/DatabaseTools/MongoDBDatabaseTool.php index 5c781b2c..a5db60de 100644 --- a/src/Services/DatabaseTools/MongoDBDatabaseTool.php +++ b/src/Services/DatabaseTools/MongoDBDatabaseTool.php @@ -1,5 +1,7 @@ getKeepDatabaseAndSchemaParameter()) { $schemaTool = new SchemaTool($this->om); - if (count($this->excludedDoctrineTables) > 0 || true === $append) { + if (\count($this->excludedDoctrineTables) > 0 || true === $append) { if (!empty($this->getMetadatas())) { $schemaTool->updateSchema($this->getMetadatas()); } @@ -148,7 +150,7 @@ protected function createDatabaseIfNotExists(): void if (isset($params['master'])) { $params = $params['master']; } - $dbName = isset($params['dbname']) ? $params['dbname'] : ''; + $dbName = $params['dbname'] ?? ''; unset($params['dbname'], $params['url']); @@ -158,7 +160,7 @@ protected function createDatabaseIfNotExists(): void $tmpConnection = DriverManager::getConnection($params); $tmpConnection->connect(); - if (!in_array($dbName, $tmpConnection->getSchemaManager()->listDatabases())) { + if (!\in_array($dbName, $tmpConnection->getSchemaManager()->listDatabases(), true)) { $tmpConnection->getSchemaManager()->createDatabase($dbName); } diff --git a/src/Services/DatabaseTools/ORMSqliteDatabaseTool.php b/src/Services/DatabaseTools/ORMSqliteDatabaseTool.php index fabd3eaa..315b21fd 100644 --- a/src/Services/DatabaseTools/ORMSqliteDatabaseTool.php +++ b/src/Services/DatabaseTools/ORMSqliteDatabaseTool.php @@ -1,5 +1,7 @@ + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + namespace Liip\TestFixturesBundle\Services; use Doctrine\Bundle\FixturesBundle\Loader\SymfonyFixturesLoader; @@ -14,7 +25,7 @@ public function __construct(SymfonyFixturesLoader $symfonyFixturesLoader) $this->symfonyFixturesLoader = $symfonyFixturesLoader; } - public function loadFixturesClass($className) + public function loadFixturesClass($className): void { $this->addFixture($this->symfonyFixturesLoader->getFixture($className)); } diff --git a/tests/AppConfigEvents/EventListener/FixturesSubscriber.php b/tests/AppConfigEvents/EventListener/FixturesSubscriber.php index 1ca6e61f..ff784af7 100644 --- a/tests/AppConfigEvents/EventListener/FixturesSubscriber.php +++ b/tests/AppConfigEvents/EventListener/FixturesSubscriber.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Liip/TestFixturesBundle + * + * (c) Lukas Kahwe Smith + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + namespace Liip\Acme\Tests\AppConfigEvents\EventListener; use Liip\TestFixturesBundle\Event\FixtureEvent; diff --git a/tests/AppConfigPhpcr/DataFixtures/PHPCR/LoadTaskData.php b/tests/AppConfigPhpcr/DataFixtures/PHPCR/LoadTaskData.php index e48aa145..2399849a 100644 --- a/tests/AppConfigPhpcr/DataFixtures/PHPCR/LoadTaskData.php +++ b/tests/AppConfigPhpcr/DataFixtures/PHPCR/LoadTaskData.php @@ -25,7 +25,7 @@ class LoadTaskData implements FixtureInterface public function load(ObjectManager $manager): void { if (!$manager instanceof DocumentManager) { - $class = get_class($manager); + $class = \get_class($manager); throw new RuntimeException("Fixture requires a PHPCR ODM DocumentManager instance, instance of '{$class}' given."); } diff --git a/tests/Test/ConfigEventsTest.php b/tests/Test/ConfigEventsTest.php index 97c59e2a..8f7fe0fd 100644 --- a/tests/Test/ConfigEventsTest.php +++ b/tests/Test/ConfigEventsTest.php @@ -37,7 +37,7 @@ */ class ConfigEventsTest extends KernelTestCase { - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Test/ConfigMysqlTest.php b/tests/Test/ConfigMysqlTest.php index 4d6f77c8..fe7688c5 100644 --- a/tests/Test/ConfigMysqlTest.php +++ b/tests/Test/ConfigMysqlTest.php @@ -58,7 +58,7 @@ class ConfigMysqlTest extends KernelTestCase /** @var AbstractDatabaseTool */ protected $databaseTool; - public function setUp(): void + protected function setUp(): void { parent::setUp(); @@ -71,7 +71,7 @@ public function setUp(): void $this->databaseTool = self::$container->get(DatabaseToolCollection::class)->get(); } - public function testToolType() + public function testToolType(): void { $this->assertInstanceOf(ORMDatabaseTool::class, $this->databaseTool); } @@ -219,7 +219,7 @@ public function testLoadFixturesAndExcludeFromPurge(): void // Check that there are 2 users. $this->assertSame( 2, - count($this->userRepository->findAll()) + \count($this->userRepository->findAll()) ); $this->databaseTool->setExcludedDoctrineTables(['liip_user']); @@ -231,7 +231,7 @@ public function testLoadFixturesAndExcludeFromPurge(): void // The exclusion from purge worked, the user table is still alive and well. $this->assertSame( 2, - count($this->userRepository->findAll()) + \count($this->userRepository->findAll()) ); } @@ -296,7 +296,7 @@ public function testLoadFixturesAndPurge(): void // The purge worked: there is no user. $this->assertSame( 0, - count($this->userRepository->findAll()) + \count($this->userRepository->findAll()) ); } @@ -323,7 +323,7 @@ public function testLoadFixturesFiles(): void $this->assertSame( 10, - count($users) + \count($users) ); /** @var User $user */ diff --git a/tests/Test/ConfigPgsqlTest.php b/tests/Test/ConfigPgsqlTest.php index 6f0198bf..b7978507 100644 --- a/tests/Test/ConfigPgsqlTest.php +++ b/tests/Test/ConfigPgsqlTest.php @@ -38,7 +38,7 @@ */ class ConfigPgsqlTest extends ConfigMysqlTest { - public function testToolType() + public function testToolType(): void { $this->assertInstanceOf(ORMDatabaseTool::class, $this->databaseTool); } diff --git a/tests/Test/ConfigPhpcrTest.php b/tests/Test/ConfigPhpcrTest.php index b6799352..a4513a85 100644 --- a/tests/Test/ConfigPhpcrTest.php +++ b/tests/Test/ConfigPhpcrTest.php @@ -41,7 +41,7 @@ class ConfigPhpcrTest extends KernelTestCase /** @var AbstractDatabaseTool */ protected $databaseTool; - public function setUp(): void + protected function setUp(): void { if (!class_exists(DoctrinePHPCRBundle::class)) { $this->markTestSkipped('Need doctrine/phpcr-bundle package.'); @@ -66,7 +66,7 @@ public function setUp(): void $this->initRepository(); } - public function testToolType() + public function testToolType(): void { $this->assertInstanceOf(PHPCRDatabaseTool::class, $this->databaseTool); } diff --git a/tests/Test/ConfigSqliteTest.php b/tests/Test/ConfigSqliteTest.php index 799905a6..46322d8f 100644 --- a/tests/Test/ConfigSqliteTest.php +++ b/tests/Test/ConfigSqliteTest.php @@ -46,7 +46,7 @@ class ConfigSqliteTest extends KernelTestCase /** @var ObjectRepository */ private $userRepository; - public function setUp(): void + protected function setUp(): void { parent::setUp(); @@ -121,7 +121,7 @@ public function testLoadFixtures(): void // There are 2 users. $this->assertSame( 2, - count($users) + \count($users) ); /** @var User $user */ @@ -163,7 +163,7 @@ public function testLoadAll(): void // Using a non-existing group will result in zero users $this->assertSame( 0, - count($users) + \count($users) ); // Load the fixtures with a valid group. @@ -186,7 +186,7 @@ public function testLoadAll(): void // The fixture group myGroup contains 3 users $this->assertSame( 3, - count($users) + \count($users) ); // Load all fixtures. @@ -209,7 +209,7 @@ public function testLoadAll(): void // Loading all fixtures results in 12 users. $this->assertSame( 12, - count($users) + \count($users) ); } @@ -277,7 +277,7 @@ public function testLoadDependentFixtures(): void // The two files with fixtures have been loaded, there are 4 users. $this->assertSame( 4, - count($users) + \count($users) ); } @@ -300,7 +300,7 @@ public function testLoadDependentFixturesWithDependencyInjected(): void // The two files with fixtures have been loaded, there are 4 users. $this->assertSame( 4, - count($users) + \count($users) ); } @@ -325,7 +325,7 @@ public function testLoadFixturesFiles(): void $this->assertSame( 10, - count($users) + \count($users) ); /** @var User $user */ @@ -421,7 +421,7 @@ public function testLoadFixturesFilesPaths(): void $this->assertSame( 10, - count($users) + \count($users) ); /** @var User $user */ @@ -459,7 +459,7 @@ public function testLoadFixturesFilesPathsWithoutLocateResource(): void $this->assertSame( 10, - count($users) + \count($users) ); } diff --git a/tests/Test/ConfigTest.php b/tests/Test/ConfigTest.php index 95a4a05b..cde9da0e 100644 --- a/tests/Test/ConfigTest.php +++ b/tests/Test/ConfigTest.php @@ -55,7 +55,7 @@ class ConfigTest extends KernelTestCase /** @var string */ private $kernelCacheDir; - public function setUp(): void + protected function setUp(): void { parent::setUp();