From 02c8d28fcbfacc0c98229174a037829c2f7775f0 Mon Sep 17 00:00:00 2001 From: Jan Tvrdik Date: Sun, 20 Dec 2020 16:22:25 +0100 Subject: [PATCH] use ::class syntax --- src/Bridges/NetteDI/MigrationsExtension.php | 64 ++++++++++--------- .../NextrasMigrationsExtension.php | 39 +++++------ src/Bridges/SymfonyConsole/CreateCommand.php | 7 +- .../integration/dbal/Runner.EmptyRun.phpt | 2 - .../integration/dbal/Runner.FirstRun.phpt | 1 - .../integration/dbal/Runner.SecondRun.phpt | 4 +- .../nette-di/MigrationsExtension.phpt | 14 ++-- tests/cases/unit/BaseDriverTest.phpt | 5 +- tests/cases/unit/CreateCommandTest.phpt | 3 +- tests/cases/unit/Finder.logicalName.phpt | 3 +- tests/cases/unit/OrderResolverTest.phpt | 25 ++++---- 11 files changed, 87 insertions(+), 80 deletions(-) diff --git a/src/Bridges/NetteDI/MigrationsExtension.php b/src/Bridges/NetteDI/MigrationsExtension.php index 0c2d480..931dad2 100644 --- a/src/Bridges/NetteDI/MigrationsExtension.php +++ b/src/Bridges/NetteDI/MigrationsExtension.php @@ -10,11 +10,13 @@ namespace Nextras\Migrations\Bridges\NetteDI; use Doctrine; +use Dibi; use Nette; use Nette\DI\ContainerBuilder; use Nette\Utils\Strings; use Nette\Utils\Validators; use Nextras; +use Symfony; class MigrationsExtension extends Nette\DI\CompilerExtension @@ -40,24 +42,24 @@ class MigrationsExtension extends Nette\DI\CompilerExtension /** @var array */ protected $dbals = [ - 'dibi' => 'Nextras\Migrations\Bridges\Dibi\DibiAdapter', - 'dibi3' => 'Nextras\Migrations\Bridges\Dibi\Dibi3Adapter', - 'dibi4' => 'Nextras\Migrations\Bridges\Dibi\Dibi3Adapter', - 'doctrine' => 'Nextras\Migrations\Bridges\DoctrineDbal\DoctrineAdapter', - 'nette' => 'Nextras\Migrations\Bridges\NetteDatabase\NetteAdapter', - 'nextras' => 'Nextras\Migrations\Bridges\NextrasDbal\NextrasAdapter', + 'dibi' => Nextras\Migrations\Bridges\Dibi\DibiAdapter::class, + 'dibi3' => Nextras\Migrations\Bridges\Dibi\Dibi3Adapter::class, + 'dibi4' => Nextras\Migrations\Bridges\Dibi\Dibi3Adapter::class, + 'doctrine' => Nextras\Migrations\Bridges\DoctrineDbal\DoctrineAdapter::class, + 'nette' => Nextras\Migrations\Bridges\NetteDatabase\NetteAdapter::class, + 'nextras' => Nextras\Migrations\Bridges\NextrasDbal\NextrasAdapter::class, ]; /** @var array */ protected $drivers = [ - 'mysql' => 'Nextras\Migrations\Drivers\MySqlDriver', - 'pgsql' => 'Nextras\Migrations\Drivers\PgSqlDriver', + 'mysql' => Nextras\Migrations\Drivers\MySqlDriver::class, + 'pgsql' => Nextras\Migrations\Drivers\PgSqlDriver::class, ]; /** @var array */ protected $printers = [ - 'console' => 'Nextras\Migrations\Printers\Console', - 'psrLog' => 'Nextras\Migrations\Bridges\PsrLog\PsrLogPrinter', + 'console' => Nextras\Migrations\Printers\Console::class, + 'psrLog' => Nextras\Migrations\Bridges\PsrLog\PsrLogPrinter::class, ]; @@ -101,7 +103,7 @@ public function loadConfiguration() $configuration = $this->createConfigurationDefinition(); // commands - if (class_exists('Symfony\Component\Console\Command\Command')) { + if (class_exists(Symfony\Component\Console\Command\Command::class)) { $this->createSymfonyCommandDefinitions($driver, $configuration, $printer); } } @@ -113,13 +115,13 @@ public function beforeCompile() $config = $this->validateConfig($this->defaults); // dbal - foreach ($builder->findByType('Nextras\Migrations\IDbal') as $def) { + foreach ($builder->findByType(Nextras\Migrations\IDbal::class) as $def) { $factory = $def->getFactory(); - if ($factory->getEntity() !== 'Nextras\Migrations\Bridges\Dibi\DibiAdapter') { + if ($factory->getEntity() !== Nextras\Migrations\Bridges\Dibi\DibiAdapter::class) { continue; } - $conn = $builder->getByType('Dibi\Connection'); + $conn = $builder->getByType(Dibi\Connection::class); if (!$conn) { continue; } @@ -129,7 +131,7 @@ public function beforeCompile() // diff generator if ($config['diffGenerator'] === true) { - if ($builder->findByType('Doctrine\ORM\EntityManagerInterface') && $builder->hasDefinition($this->prefix('group.structures'))) { + if ($builder->findByType(Doctrine\ORM\EntityManagerInterface::class) && $builder->hasDefinition($this->prefix('group.structures'))) { Validators::assertField($config, 'ignoredQueriesFile', 'null|string'); $diffGenerator = $this->createDoctrineStructureDiffGeneratorDefinition($config['ignoredQueriesFile']); $builder->getDefinition($this->prefix('group.structures')) @@ -165,7 +167,7 @@ private function getDbalDefinition($dbal) if ($factory) { return $this->getContainerBuilder() ->addDefinition($this->prefix('dbal')) - ->setClass('Nextras\Migrations\IDbal') + ->setClass(Nextras\Migrations\IDbal::class) ->setFactory($factory); } elseif ($dbal === null) { @@ -201,7 +203,7 @@ private function getDriverDefinition($driver, $dbal) if ($factory) { return $this->getContainerBuilder() ->addDefinition($this->prefix('driver')) - ->setClass('Nextras\Migrations\IDriver') + ->setClass(Nextras\Migrations\IDriver::class) ->setFactory($factory); } elseif ($driver === null) { @@ -234,7 +236,7 @@ private function getPrinterDefinition($printer) if ($factory) { return $this->getContainerBuilder() ->addDefinition($this->prefix('printer')) - ->setClass('Nextras\Migrations\IPrinter') + ->setClass(Nextras\Migrations\IPrinter::class) ->setFactory($factory); } elseif ($printer === null) { @@ -320,7 +322,7 @@ private function createGroupDefinitions(array $groups) $groupDefinitions[] = $builder->addDefinition($this->prefix("group.$serviceName")) ->addTag(self::TAG_GROUP, ['for' => [$this->name]]) ->setAutowired(false) - ->setClass('Nextras\Migrations\Entities\Group') + ->setClass(Nextras\Migrations\Entities\Group::class) ->addSetup('$name', [$groupName]) ->addSetup('$enabled', [$enabled]) ->addSetup('$directory', [$directory]) @@ -339,12 +341,12 @@ private function createExtensionHandlerDefinitions($driver, $phpParams) $sqlHandler = $builder->addDefinition($this->prefix('extensionHandler.sql')) ->addTag(self::TAG_EXTENSION_HANDLER, ['for' => [$this->name], 'extension' => 'sql']) ->setAutowired(false) - ->setClass('Nextras\Migrations\Extensions\SqlHandler') + ->setClass(Nextras\Migrations\Extensions\SqlHandler::class) ->setArguments([$driver]); $phpHandler = $builder->addDefinition($this->prefix('extensionHandler.php')) ->addTag(self::TAG_EXTENSION_HANDLER, ['for' => [$this->name], 'extension' => 'php']) - ->setClass('Nextras\Migrations\Extensions\PhpHandler') + ->setClass(Nextras\Migrations\Extensions\PhpHandler::class) ->setAutowired(false) ->setArguments([$phpParams]); @@ -356,8 +358,8 @@ private function createConfigurationDefinition() { return $this->getContainerBuilder() ->addDefinition($this->prefix('configuration')) - ->setClass('Nextras\Migrations\IConfiguration') - ->setFactory('Nextras\Migrations\Configurations\Configuration'); + ->setClass(Nextras\Migrations\IConfiguration::class) + ->setFactory(Nextras\Migrations\Configurations\Configuration::class); } @@ -367,8 +369,8 @@ private function createDoctrineStructureDiffGeneratorDefinition($ignoredQueriesF return $builder->addDefinition($this->prefix('diffGenerator.structures')) ->setAutowired(false) - ->setClass('Nextras\Migrations\IDiffGenerator') - ->setFactory('Nextras\Migrations\Bridges\DoctrineOrm\StructureDiffGenerator') + ->setClass(Nextras\Migrations\IDiffGenerator::class) + ->setFactory(Nextras\Migrations\Bridges\DoctrineOrm\StructureDiffGenerator::class) ->setArguments(['@Doctrine\ORM\EntityManagerInterface', $ignoredQueriesFile]); } @@ -376,20 +378,20 @@ private function createDoctrineStructureDiffGeneratorDefinition($ignoredQueriesF private function createSymfonyCommandDefinitions($driver, $configuration, $printer) { $builder = $this->getContainerBuilder(); - $builder->addExcludedClasses(['Nextras\Migrations\Bridges\SymfonyConsole\BaseCommand']); + $builder->addExcludedClasses([Nextras\Migrations\Bridges\SymfonyConsole\BaseCommand::class]); $builder->addDefinition($this->prefix('continueCommand')) - ->setClass('Nextras\Migrations\Bridges\SymfonyConsole\ContinueCommand') + ->setClass(Nextras\Migrations\Bridges\SymfonyConsole\ContinueCommand::class) ->setArguments([$driver, $configuration, $printer]) ->addTag('kdyby.console.command'); $builder->addDefinition($this->prefix('createCommand')) - ->setClass('Nextras\Migrations\Bridges\SymfonyConsole\CreateCommand') + ->setClass(Nextras\Migrations\Bridges\SymfonyConsole\CreateCommand::class) ->setArguments([$driver, $configuration, $printer]) ->addTag('kdyby.console.command'); $builder->addDefinition($this->prefix('resetCommand')) - ->setClass('Nextras\Migrations\Bridges\SymfonyConsole\ResetCommand') + ->setClass(Nextras\Migrations\Bridges\SymfonyConsole\ResetCommand::class) ->setArguments([$driver, $configuration, $printer]) ->addTag('kdyby.console.command'); } @@ -397,10 +399,10 @@ private function createSymfonyCommandDefinitions($driver, $configuration, $print private function filterArguments(array $arguments) { - if (method_exists('Nette\DI\Helpers', 'filterArguments')) { + if (method_exists(Nette\DI\Helpers::class, 'filterArguments')) { return Nette\DI\Helpers::filterArguments($arguments); - } elseif (method_exists('Nette\DI\Compiler', 'filterArguments')) { + } elseif (method_exists(Nette\DI\Compiler::class, 'filterArguments')) { return Nette\DI\Compiler::filterArguments($arguments); } else { diff --git a/src/Bridges/SymfonyBundle/DependencyInjection/NextrasMigrationsExtension.php b/src/Bridges/SymfonyBundle/DependencyInjection/NextrasMigrationsExtension.php index 3c22938..d8192c0 100644 --- a/src/Bridges/SymfonyBundle/DependencyInjection/NextrasMigrationsExtension.php +++ b/src/Bridges/SymfonyBundle/DependencyInjection/NextrasMigrationsExtension.php @@ -9,6 +9,7 @@ namespace Nextras\Migrations\Bridges\SymfonyBundle\DependencyInjection; +use Nextras; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\HttpKernel\DependencyInjection\Extension; @@ -18,24 +19,24 @@ class NextrasMigrationsExtension extends Extension { /** @var array */ protected $dbals = [ - 'dibi' => 'Nextras\Migrations\Bridges\Dibi\DibiAdapter', - 'dibi3' => 'Nextras\Migrations\Bridges\Dibi\Dibi3Adapter', - 'dibi4' => 'Nextras\Migrations\Bridges\Dibi\Dibi3Adapter', - 'doctrine' => 'Nextras\Migrations\Bridges\DoctrineDbal\DoctrineAdapter', - 'nette' => 'Nextras\Migrations\Bridges\NetteDatabase\NetteAdapter', - 'nextras' => 'Nextras\Migrations\Bridges\NextrasDbal\NextrasAdapter', + 'dibi' => Nextras\Migrations\Bridges\Dibi\DibiAdapter::class, + 'dibi3' => Nextras\Migrations\Bridges\Dibi\Dibi3Adapter::class, + 'dibi4' => Nextras\Migrations\Bridges\Dibi\Dibi3Adapter::class, + 'doctrine' => Nextras\Migrations\Bridges\DoctrineDbal\DoctrineAdapter::class, + 'nette' => Nextras\Migrations\Bridges\NetteDatabase\NetteAdapter::class, + 'nextras' => Nextras\Migrations\Bridges\NextrasDbal\NextrasAdapter::class, ]; /** @var array */ protected $drivers = [ - 'mysql' => 'Nextras\Migrations\Drivers\MySqlDriver', - 'pgsql' => 'Nextras\Migrations\Drivers\PgSqlDriver', + 'mysql' => Nextras\Migrations\Drivers\MySqlDriver::class, + 'pgsql' => Nextras\Migrations\Drivers\PgSqlDriver::class, ]; /** @var array */ protected $printers = [ - 'console' => 'Nextras\Migrations\Printers\Console', - 'psrLog' => 'Nextras\Migrations\Bridges\PsrLog\PsrLogPrinter', + 'console' => Nextras\Migrations\Printers\Console::class, + 'psrLog' => Nextras\Migrations\Bridges\PsrLog\PsrLogPrinter::class, ]; @@ -62,13 +63,13 @@ public function load(array $configs, ContainerBuilder $container) ]); $container->addAliases([ - 'Nextras\Migrations\IDbal' => 'nextras_migrations.dbal', - 'Nextras\Migrations\IDriver' => 'nextras_migrations.driver', - 'Nextras\Migrations\IPrinter' => 'nextras_migrations.printer', + Nextras\Migrations\IDbal::class => 'nextras_migrations.dbal', + Nextras\Migrations\IDriver::class => 'nextras_migrations.driver', + Nextras\Migrations\IPrinter::class => 'nextras_migrations.printer', ]); if ($config['diff_generator'] === 'doctrine') { - $structureDiffGeneratorDefinition = new Definition('Nextras\Migrations\Bridges\DoctrineOrm\StructureDiffGenerator'); + $structureDiffGeneratorDefinition = new Definition(Nextras\Migrations\Bridges\DoctrineOrm\StructureDiffGenerator::class); $structureDiffGeneratorDefinition->setAutowired(true); $structureDiffGeneratorDefinition->setArgument('$ignoredQueriesFile', $config['ignored_queries_file']); @@ -83,19 +84,19 @@ public function load(array $configs, ContainerBuilder $container) } } - $configurationDefinition = new Definition('Nextras\Migrations\Configurations\DefaultConfiguration'); + $configurationDefinition = new Definition(Nextras\Migrations\Configurations\DefaultConfiguration::class); $configurationDefinition->setArguments([$config['dir'], $driverDefinition, $config['with_dummy_data'], $config['php_params']]); $configurationDefinition->addMethodCall('setStructureDiffGenerator', [$structureDiffGeneratorDefinition]); - $continueCommandDefinition = new Definition('Nextras\Migrations\Bridges\SymfonyConsole\ContinueCommand'); + $continueCommandDefinition = new Definition(Nextras\Migrations\Bridges\SymfonyConsole\ContinueCommand::class); $continueCommandDefinition->setArguments([$driverDefinition, $configurationDefinition, $printerDefinition]); $continueCommandDefinition->addTag('console.command'); - $createCommandDefinition = new Definition('Nextras\Migrations\Bridges\SymfonyConsole\CreateCommand'); + $createCommandDefinition = new Definition(Nextras\Migrations\Bridges\SymfonyConsole\CreateCommand::class); $createCommandDefinition->setArguments([$driverDefinition, $configurationDefinition, $printerDefinition]); $createCommandDefinition->addTag('console.command'); - $resetCommandDefinition = new Definition('Nextras\Migrations\Bridges\SymfonyConsole\ResetCommand'); + $resetCommandDefinition = new Definition(Nextras\Migrations\Bridges\SymfonyConsole\ResetCommand::class); $resetCommandDefinition->setArguments([$driverDefinition, $configurationDefinition, $printerDefinition]); $resetCommandDefinition->addTag('console.command'); @@ -107,7 +108,7 @@ public function load(array $configs, ContainerBuilder $container) ]); $container->addAliases([ - 'Nextras\Migrations\IConfiguration' => 'nextras_migrations.configuration', + Nextras\Migrations\IConfiguration::class => 'nextras_migrations.configuration', ]); if ($structureDiffGeneratorDefinition) { diff --git a/src/Bridges/SymfonyConsole/CreateCommand.php b/src/Bridges/SymfonyConsole/CreateCommand.php index fe735ad..de1294d 100644 --- a/src/Bridges/SymfonyConsole/CreateCommand.php +++ b/src/Bridges/SymfonyConsole/CreateCommand.php @@ -17,6 +17,7 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\String\Slugger\AsciiSlugger; +use Symfony\Contracts\Translation\LocaleAwareInterface; class CreateCommand extends BaseCommand @@ -152,12 +153,12 @@ protected function getFileName($label, $extension) if (preg_match('#^[a-z0-9.-]++$#i', $label)) { $slug = strtolower($label); - } elseif (class_exists('Nette\Utils\Strings')) { + } elseif (class_exists(Strings::class)) { $slug = Strings::webalize($label, '.'); } elseif ( - interface_exists('Symfony\Contracts\Translation\LocaleAwareInterface') && - class_exists('Symfony\Component\String\Slugger\AsciiSlugger') + interface_exists(LocaleAwareInterface::class) && + class_exists(AsciiSlugger::class) ) { $slugger = new AsciiSlugger('en'); $slug = $slugger->slug($label)->toString(); diff --git a/tests/cases/integration/dbal/Runner.EmptyRun.phpt b/tests/cases/integration/dbal/Runner.EmptyRun.phpt index 44c89be..5bc1c7e 100644 --- a/tests/cases/integration/dbal/Runner.EmptyRun.phpt +++ b/tests/cases/integration/dbal/Runner.EmptyRun.phpt @@ -7,9 +7,7 @@ namespace NextrasTests\Migrations; -use Mockery; use Nextras\Migrations\Engine\Runner; -use Tester; use Tester\Assert; require __DIR__ . '/../../../bootstrap.php'; diff --git a/tests/cases/integration/dbal/Runner.FirstRun.phpt b/tests/cases/integration/dbal/Runner.FirstRun.phpt index e841e99..2051f11 100644 --- a/tests/cases/integration/dbal/Runner.FirstRun.phpt +++ b/tests/cases/integration/dbal/Runner.FirstRun.phpt @@ -7,7 +7,6 @@ namespace NextrasTests\Migrations; -use Mockery; use Nextras\Migrations\Engine\Runner; use Tester; use Tester\Assert; diff --git a/tests/cases/integration/dbal/Runner.SecondRun.phpt b/tests/cases/integration/dbal/Runner.SecondRun.phpt index 088f8ae..0756b62 100644 --- a/tests/cases/integration/dbal/Runner.SecondRun.phpt +++ b/tests/cases/integration/dbal/Runner.SecondRun.phpt @@ -7,7 +7,7 @@ namespace NextrasTests\Migrations; -use Mockery; +use Nextras; use Nextras\Migrations\Engine\Runner; use Tester; use Tester\Assert; @@ -65,7 +65,7 @@ class SecondRunTest extends IntegrationTestCase Assert::throws(function () { $this->runner->run(Runner::MODE_CONTINUE); - }, 'Nextras\Migrations\LogicException'); + }, Nextras\Migrations\LogicException::class); Assert::same([ 'Nextras Migrations', diff --git a/tests/cases/integration/nette-di/MigrationsExtension.phpt b/tests/cases/integration/nette-di/MigrationsExtension.phpt index de9e297..0167527 100644 --- a/tests/cases/integration/nette-di/MigrationsExtension.phpt +++ b/tests/cases/integration/nette-di/MigrationsExtension.phpt @@ -7,6 +7,8 @@ namespace NextrasTests\Migrations; use Nette; +use Nextras; +use Symfony; use Tester\Assert; use Tester\Environment; use Tester\TestCase; @@ -23,8 +25,8 @@ class MigrationsExtensionTest extends TestCase { $dic = $this->createContainer($config); - Assert::type('Nextras\Migrations\Drivers\MySqlDriver', $dic->getByType('Nextras\Migrations\IDriver')); - Assert::count(3, $dic->findByType('Symfony\Component\Console\Command\Command')); + Assert::type(Nextras\Migrations\Drivers\MySqlDriver::class, $dic->getByType(Nextras\Migrations\IDriver::class)); + Assert::count(3, $dic->findByType(Symfony\Component\Console\Command\Command::class)); Assert::count(3, $dic->findByTag('kdyby.console.command')); } @@ -49,12 +51,12 @@ class MigrationsExtensionTest extends TestCase { $dic = $this->createContainer($config); - $configuration = $dic->getByType('Nextras\Migrations\IConfiguration'); - Assert::type('Nextras\Migrations\Configurations\Configuration', $configuration); + $configuration = $dic->getByType(Nextras\Migrations\IConfiguration::class); + Assert::type(Nextras\Migrations\Configurations\Configuration::class, $configuration); $groups = $configuration->getGroups(); Assert::count(3, $groups); - Assert::type('Nextras\Migrations\Bridges\DoctrineOrm\StructureDiffGenerator', $groups[0]->generator); + Assert::type(Nextras\Migrations\Bridges\DoctrineOrm\StructureDiffGenerator::class, $groups[0]->generator); Assert::null($groups[1]->generator); Assert::null($groups[2]->generator); } @@ -71,7 +73,7 @@ class MigrationsExtensionTest extends TestCase public function testDynamicContainerParameters() { - if (!method_exists('Nette\DI\Compiler', 'setDynamicParameterNames')) { + if (!method_exists(Nette\DI\Compiler::class, 'setDynamicParameterNames')) { Environment::skip('Required Nette >= 2.4.7'); } diff --git a/tests/cases/unit/BaseDriverTest.phpt b/tests/cases/unit/BaseDriverTest.phpt index 8ed2178..3ebfa19 100644 --- a/tests/cases/unit/BaseDriverTest.phpt +++ b/tests/cases/unit/BaseDriverTest.phpt @@ -7,6 +7,7 @@ namespace NextrasTests\Migrations; use Mockery; +use Nextras; use Tester; use Tester\Assert; @@ -20,10 +21,10 @@ class BaseDriverTest extends Tester\TestCase */ public function testLoadFile($content, array $expectedQueries) { - $dbal = Mockery::mock('Nextras\Migrations\IDbal'); + $dbal = Mockery::mock(Nextras\Migrations\IDbal::class); $dbal->shouldReceive('escapeIdentifier')->with('migrations')->andReturn('migrations'); - $driver = Mockery::mock('Nextras\Migrations\Drivers\BaseDriver', array($dbal)); + $driver = Mockery::mock(Nextras\Migrations\Drivers\BaseDriver::class, array($dbal)); $driver->shouldDeferMissing(); foreach ($expectedQueries as $expectedQuery) { diff --git a/tests/cases/unit/CreateCommandTest.phpt b/tests/cases/unit/CreateCommandTest.phpt index ac998fc..cb3da98 100644 --- a/tests/cases/unit/CreateCommandTest.phpt +++ b/tests/cases/unit/CreateCommandTest.phpt @@ -6,6 +6,7 @@ namespace NextrasTests\Migrations\Bridges\SymfonyConsole; +use Nextras; use Nextras\Migrations\Bridges\SymfonyConsole\CreateCommand; use Nextras\Migrations\Configurations\DefaultConfiguration; use Mockery; @@ -19,7 +20,7 @@ class CreateCommandTest extends Tester\TestCase { public function testTypeArgDescription() { - $driver = Mockery::mock('Nextras\Migrations\IDriver'); + $driver = Mockery::mock(Nextras\Migrations\IDriver::class); $config = new DefaultConfiguration('migrations', $driver); $command = new CreateCommand($driver, $config); diff --git a/tests/cases/unit/Finder.logicalName.phpt b/tests/cases/unit/Finder.logicalName.phpt index 985a28c..fcf1c9d 100644 --- a/tests/cases/unit/Finder.logicalName.phpt +++ b/tests/cases/unit/Finder.logicalName.phpt @@ -7,6 +7,7 @@ namespace NextrasTests\Migrations; use Mockery; +use Nextras; use Nextras\Migrations\Engine\Finder; use Nextras\Migrations\Entities\Group; use Tester; @@ -28,7 +29,7 @@ class FinderLogicalNameTest extends Tester\TestCase protected function setUp() { parent::setUp(); - $this->finder = Mockery::mock('Nextras\Migrations\Engine\Finder') + $this->finder = Mockery::mock(Nextras\Migrations\Engine\Finder::class) ->shouldAllowMockingProtectedMethods() ->shouldDeferMissing() ->shouldReceive('getChecksum') diff --git a/tests/cases/unit/OrderResolverTest.phpt b/tests/cases/unit/OrderResolverTest.phpt index 764fb40..619b6b4 100644 --- a/tests/cases/unit/OrderResolverTest.phpt +++ b/tests/cases/unit/OrderResolverTest.phpt @@ -6,6 +6,7 @@ namespace NextrasTests\Migrations; +use Nextras; use Nextras\Migrations\Engine\OrderResolver; use Nextras\Migrations\Engine\Runner; use Nextras\Migrations\Entities\Group; @@ -169,7 +170,7 @@ class OrderResolverTest extends Tester\TestCase $groupB = $this->createGroup('data', false, ['structures']); $groupC = $this->createGroup('test-data', false, ['data']); - $method = new \ReflectionMethod('Nextras\Migrations\Engine\OrderResolver', 'validateGroups'); + $method = new \ReflectionMethod(Nextras\Migrations\Engine\OrderResolver::class, 'validateGroups'); $method->setAccessible(true); $method->invoke(new OrderResolver, [ 'structures' => $groupA, @@ -262,7 +263,7 @@ class OrderResolverTest extends Tester\TestCase [$fileB], Runner::MODE_CONTINUE ); - }, 'Nextras\Migrations\LogicException', 'Previously executed migration "structures/1s" is missing.'); + }, Nextras\Migrations\LogicException::class, 'Previously executed migration "structures/1s" is missing.'); } @@ -283,7 +284,7 @@ class OrderResolverTest extends Tester\TestCase [$fileB, $fileA], Runner::MODE_CONTINUE ); - }, 'Nextras\Migrations\LogicException', 'Previously executed migration "structures/1s" has been changed. File checksum is "1s.md5.Y", but executed migration had checksum "1s.md5.X".'); + }, Nextras\Migrations\LogicException::class, 'Previously executed migration "structures/1s" has been changed. File checksum is "1s.md5.Y", but executed migration had checksum "1s.md5.X".'); } @@ -304,7 +305,7 @@ class OrderResolverTest extends Tester\TestCase [$fileB, $fileA], Runner::MODE_CONTINUE ); - }, 'Nextras\Migrations\LogicException', 'Previously executed migration "structures/1s" did not succeed. Please fix this manually or reset the migrations.'); + }, Nextras\Migrations\LogicException::class, 'Previously executed migration "structures/1s" did not succeed. Please fix this manually or reset the migrations.'); } @@ -327,7 +328,7 @@ class OrderResolverTest extends Tester\TestCase [$fileA, $fileB, $fileC], Runner::MODE_CONTINUE ); - }, 'Nextras\Migrations\LogicException', 'New migration "structures/2s" must follow after the latest executed migration "structures/3s".'); + }, Nextras\Migrations\LogicException::class, 'New migration "structures/2s" must follow after the latest executed migration "structures/3s".'); } @@ -354,7 +355,7 @@ class OrderResolverTest extends Tester\TestCase [$fileA, $fileB, $fileC], Runner::MODE_CONTINUE ); - }, 'Nextras\Migrations\LogicException', 'New migration "b/2b" must follow after the latest executed migration "c/3c".'); + }, Nextras\Migrations\LogicException::class, 'New migration "b/2b" must follow after the latest executed migration "c/3c".'); } @@ -380,7 +381,7 @@ class OrderResolverTest extends Tester\TestCase [$fileA, $fileB, $fileC], Runner::MODE_CONTINUE ); - }, 'Nextras\Migrations\LogicException', 'New migration "b/2b" must follow after the latest executed migration "a/3a".'); + }, Nextras\Migrations\LogicException::class, 'New migration "b/2b" must follow after the latest executed migration "a/3a".'); } @@ -397,7 +398,7 @@ class OrderResolverTest extends Tester\TestCase [], Runner::MODE_CONTINUE ); - }, 'Nextras\Migrations\LogicException', 'Existing migrations depend on unknown group "foo".'); + }, Nextras\Migrations\LogicException::class, 'Existing migrations depend on unknown group "foo".'); } @@ -414,7 +415,7 @@ class OrderResolverTest extends Tester\TestCase [], Runner::MODE_CONTINUE ); - }, 'Nextras\Migrations\LogicException', 'Group "data" depends on unknown group "structures".'); + }, Nextras\Migrations\LogicException::class, 'Group "data" depends on unknown group "structures".'); } @@ -432,7 +433,7 @@ class OrderResolverTest extends Tester\TestCase [], Runner::MODE_CONTINUE ); - }, 'Nextras\Migrations\LogicException', 'Group "data" depends on disabled group "structures". Please enable group "structures" to continue.'); + }, Nextras\Migrations\LogicException::class, 'Group "data" depends on disabled group "structures". Please enable group "structures" to continue.'); } @@ -453,7 +454,7 @@ class OrderResolverTest extends Tester\TestCase [$fileA, $fileB], Runner::MODE_CONTINUE ); - }, 'Nextras\Migrations\LogicException', 'Unable to determine order for migrations "data/foo" and "structures/foo".'); + }, Nextras\Migrations\LogicException::class, 'Unable to determine order for migrations "data/foo" and "structures/foo".'); } @@ -474,7 +475,7 @@ class OrderResolverTest extends Tester\TestCase [$fileA, $fileB], Runner::MODE_CONTINUE ); - }, 'Nextras\Migrations\LogicException', 'Unable to determine order for migrations "data/foo" and "structures/foo".'); + }, Nextras\Migrations\LogicException::class, 'Unable to determine order for migrations "data/foo" and "structures/foo".'); }