diff --git a/.rector.php b/.rector.php
index ef58b2e0f..e8ddc5b55 100644
--- a/.rector.php
+++ b/.rector.php
@@ -4,12 +4,14 @@
use Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector;
use Rector\Config\RectorConfig;
+use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector;
use Rector\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector;
+use Rector\Privatization\Rector\ClassMethod\PrivatizeFinalClassMethodRector;
return RectorConfig::configure()
->withPaths([
__DIR__ . '/src',
- #__DIR__ . '/tests',
+ __DIR__ . '/tests',
])
->withSkip([
MakeInheritedMethodVisibilitySameAsParentRector::class => [
@@ -18,6 +20,12 @@
RemoveAlwaysTrueIfConditionRector::class => [
__DIR__ . '/src/N98/Magento/Initializer.php',
],
+ RemoveUnusedPrivateMethodRector::class => [
+ __DIR__ . '/tests/N98/Magento/Command/System/Setup/IncrementalCommandTest.php',
+ ],
+ PrivatizeFinalClassMethodRector::class => [
+ __DIR__ . '/tests/N98/Magento/Command/System/Setup/IncrementalCommandTest.php',
+ ],
])
->withPreparedSets(
true,
@@ -34,8 +42,6 @@
true,
false,
true,
- true,
- true,
true
)
->withTypeCoverageLevel(0);
diff --git a/src/N98/Magento/Command/System/Setup/ChangeVersionCommand.php b/src/N98/Magento/Command/System/Setup/ChangeVersionCommand.php
index 9831ae2e9..0c04eabff 100644
--- a/src/N98/Magento/Command/System/Setup/ChangeVersionCommand.php
+++ b/src/N98/Magento/Command/System/Setup/ChangeVersionCommand.php
@@ -37,10 +37,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return Command::INVALID;
}
- $moduleVersion = $input->getArgument('version');
- $moduleName = $this->getModule($input);
- $setupName = $input->getArgument('setup');
- $moduleSetups = $this->getModuleSetupResources($moduleName);
+ $moduleVersion = $input->getArgument('version');
+ $moduleName = $this->getModule($input);
+ $setupName = $input->getArgument('setup');
+ $moduleSetups = $this->getModuleSetupResources($moduleName);
if ($moduleSetups === []) {
$output->writeln(sprintf('No setup resources found for module: "%s"', $moduleName));
@@ -63,7 +63,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
public function updateSetupResource(string $moduleName, string $setupResource, string $version, OutputInterface $output): void
{
/** @var Mage_Core_Model_Resource_Resource $mageCoreModelAbstract */
- $mageCoreModelAbstract = Mage::getModel('core/resource');
+ $mageCoreModelAbstract = Mage::getResourceSingleton('core/resource');
$mageCoreModelAbstract->setDbVersion($setupResource, $version);
$mageCoreModelAbstract->setDataVersion($setupResource, $version);
diff --git a/tests/N98/Magento/Application/ConfigFileTest.php b/tests/N98/Magento/Application/ConfigFileTest.php
index a5d75b335..d381d8b3c 100644
--- a/tests/N98/Magento/Application/ConfigFileTest.php
+++ b/tests/N98/Magento/Application/ConfigFileTest.php
@@ -1,5 +1,7 @@
assertInstanceOf(ConfigFile::class, $configFile);
$configFile = ConfigFile::createFromFile(__FILE__);
- self::assertInstanceOf(ConfigFile::class, $configFile);
+ $this->assertInstanceOf(ConfigFile::class, $configFile);
}
- /**
- * @test
- */
- public function applyVariables()
+ public function testApplyVariables()
{
$configFile = new ConfigFile();
$configFile->loadFile('data://,- %root%');
$configFile->applyVariables('root-folder');
- self::assertSame(['root-folder'], $configFile->toArray());
+ $this->assertSame(['root-folder'], $configFile->toArray());
}
- /**
- * @test
- */
- public function mergeArray()
+ public function testMergeArray()
{
$configFile = new ConfigFile();
$configFile->loadFile('data://,- bar');
+
$result = $configFile->mergeArray(['foo']);
- self::assertSame(['foo', 'bar'], $result);
+ $this->assertSame(['foo', 'bar'], $result);
}
- /**
- * @test
- */
- public function parseEmptyFile()
+ public function testParseEmptyFile()
{
$this->expectException(RuntimeException::class);
- $this->expectExceptionMessage('Failed to parse config-file \'data://,\'');
+ $this->expectExceptionMessage("Failed to parse config-file 'data://,'");
$configFile = new ConfigFile();
$configFile->loadFile('data://,');
$this->addToAssertionCount(1);
@@ -70,10 +61,7 @@ public function parseEmptyFile()
self::fail('An expected exception has not been thrown.');
}
- /**
- * @test
- */
- public function invalidFileThrowsException()
+ public function testInvalidFileThrowsException()
{
$this->expectException(InvalidArgumentException::class);
@ConfigFile::createFromFile(':');
diff --git a/tests/N98/Magento/Application/ConfigTest.php b/tests/N98/Magento/Application/ConfigTest.php
index 51a79c72b..bdd5296a9 100644
--- a/tests/N98/Magento/Application/ConfigTest.php
+++ b/tests/N98/Magento/Application/ConfigTest.php
@@ -1,5 +1,7 @@
*/
@@ -25,82 +27,72 @@
* @covers N98\Magento\Application\Config
* @package N98\Magento\Application
*/
-class ConfigTest extends TestCase
+final class ConfigTest extends TestCase
{
- /**
- * @test
- */
- public function creation()
+ public function testCreation()
{
$config = new Config();
- self::assertInstanceOf(__NAMESPACE__ . '\\Config', $config);
+ $this->assertInstanceOf(__NAMESPACE__ . '\\Config', $config);
}
- /**
- * @test
- */
- public function loader()
+ public function testLoader()
{
$config = new Config();
try {
$config->load();
self::fail('An expected exception was not thrown');
- } catch (ErrorException $e) {
- self::assertEquals('Configuration not yet fully loaded', $e->getMessage());
+ } catch (ErrorException $errorException) {
+ $this->assertSame('Configuration not yet fully loaded', $errorException->getMessage());
}
- self::assertEquals([], $config->getConfig());
+ $this->assertSame([], $config->getConfig());
- $loader = $config->getLoader();
- self::assertInstanceOf(__NAMESPACE__ . '\\ConfigurationLoader', $loader);
- self::assertSame($loader, $config->getLoader());
+ $configurationLoader = $config->getLoader();
+ $this->assertInstanceOf(__NAMESPACE__ . '\\ConfigurationLoader', $configurationLoader);
+ $this->assertSame($configurationLoader, $config->getLoader());
- $loader->loadStageTwo('');
+ $configurationLoader->loadStageTwo('');
$config->load();
- self::assertIsArray($config->getConfig());
- self::assertGreaterThan(4, count($config->getConfig()));
+ $this->assertIsArray($config->getConfig());
+ $this->assertGreaterThan(4, count($config->getConfig()));
- $config->setLoader($loader);
+ $config->setLoader($configurationLoader);
}
/**
* config array setter is used in some tests on @see \N98\Magento\Application::setConfig()
- *
- * @test
*/
- public function setConfig()
+ public function testSetConfig()
{
$config = new Config();
$config->setConfig([0, 1, 2]);
+
$actual = $config->getConfig();
- self::assertSame($actual[1], 1);
+ $this->assertSame(1, $actual[1]);
}
- /**
- * @test
- */
- public function configCommandAlias()
+ public function testConfigCommandAlias()
{
$config = new Config();
$input = new ArgvInput();
$actual = $config->checkConfigCommandAlias($input);
- self::assertInstanceOf(InputInterface::class, $actual);
+ $this->assertInstanceOf(InputInterface::class, $actual);
$saved = $_SERVER['argv'];
{
$config->setConfig(['commands' => ['aliases' => [['list-help' => 'list --help']]]]);
- $definition = new InputDefinition();
- $definition->addArgument(new InputArgument('command'));
+ $inputDefinition = new InputDefinition();
+ $inputDefinition->addArgument(new InputArgument('command'));
$argv = ['/path/to/command', 'list-help'];
$_SERVER['argv'] = $argv;
- $input = new ArgvInput($argv, $definition);
- self::assertSame('list-help', (string) $input);
+ $input = new ArgvInput($argv, $inputDefinition);
+ $this->assertSame('list-help', (string) $input);
$actual = $config->checkConfigCommandAlias($input);
- self::assertSame('list-help', $actual->getFirstArgument());
- self::assertSame('list-help --help', (string) $actual);
+ $this->assertSame('list-help', $actual->getFirstArgument());
+ $this->assertSame('list-help --help', (string) $actual);
}
$_SERVER['argv'] = $saved;
@@ -108,13 +100,10 @@ public function configCommandAlias()
$config->registerConfigCommandAlias($command);
- self::assertSame(['list-help'], $command->getAliases());
+ $this->assertSame(['list-help'], $command->getAliases());
}
- /**
- * @test
- */
- public function customCommands()
+ public function testCustomCommands()
{
$configArray = [
'commands' => [
@@ -125,10 +114,10 @@ public function customCommands()
],
];
- $output = new BufferedOutput();
- $output->setVerbosity($output::VERBOSITY_DEBUG);
+ $bufferedOutput = new BufferedOutput();
+ $bufferedOutput->setVerbosity($bufferedOutput::VERBOSITY_DEBUG);
- $config = new Config([], false, $output);
+ $config = new Config([], false, $bufferedOutput);
$config->setConfig($configArray);
/** @var Application|MockObject $application */
@@ -138,10 +127,7 @@ public function customCommands()
$config->registerCustomCommands($application);
}
- /**
- * @test
- */
- public function registerCustomAutoloaders()
+ public function testRegisterCustomAutoloaders()
{
$array = ['autoloaders' => ['$prefix' => '$path'], 'autoloaders_psr4' => ['$prefix\\' => '$path']];
@@ -149,30 +135,27 @@ public function registerCustomAutoloaders()
'Registered PSR-0 autoloader $prefix -> $path' . "\n" .
'Registered PSR-4 autoloader $prefix\\ -> $path' . "\n";
- $output = new BufferedOutput();
+ $bufferedOutput = new BufferedOutput();
- $config = new Config([], false, $output);
+ $config = new Config([], false, $bufferedOutput);
$config->setConfig($array);
- $autloader = new ClassLoader();
- $config->registerCustomAutoloaders($autloader);
+ $classLoader = new ClassLoader();
+ $config->registerCustomAutoloaders($classLoader);
- $output->setVerbosity($output::VERBOSITY_DEBUG);
- $config->registerCustomAutoloaders($autloader);
+ $bufferedOutput->setVerbosity($bufferedOutput::VERBOSITY_DEBUG);
+ $config->registerCustomAutoloaders($classLoader);
- self::assertSame($expected, $output->fetch());
+ $this->assertSame($expected, $bufferedOutput->fetch());
}
- /**
- * @test
- */
- public function loadPartialConfig()
+ public function testLoadPartialConfig()
{
$config = new Config();
- self::assertEquals([], $config->getDetectSubFolders());
+ $this->assertSame([], $config->getDetectSubFolders());
$config->loadPartialConfig(false);
$actual = $config->getDetectSubFolders();
- self::assertIsArray($actual);
- self::assertNotEquals([], $actual);
+ $this->assertIsArray($actual);
+ $this->assertNotSame([], $actual);
}
}
diff --git a/tests/N98/Magento/Application/ConfigurationLoaderTest.php b/tests/N98/Magento/Application/ConfigurationLoaderTest.php
index e030b26af..52a03237c 100644
--- a/tests/N98/Magento/Application/ConfigurationLoaderTest.php
+++ b/tests/N98/Magento/Application/ConfigurationLoaderTest.php
@@ -1,5 +1,7 @@
assertInstanceOf(__NAMESPACE__ . '\\ConfigurationLoader', $configurationLoader);
}
}
diff --git a/tests/N98/Magento/ApplicationTest.php b/tests/N98/Magento/ApplicationTest.php
index 36d10ba79..a7c098aa8 100644
--- a/tests/N98/Magento/ApplicationTest.php
+++ b/tests/N98/Magento/ApplicationTest.php
@@ -1,5 +1,7 @@
setMagentoRootFolder($this->getTestMagentoRoot());
- self::assertInstanceOf(Application::class, $application);
+ $this->assertInstanceOf(Application::class, $application);
$loader = $application->getAutoloader();
- self::assertInstanceOf(ClassLoader::class, $loader);
+ $this->assertInstanceOf(ClassLoader::class, $loader);
/**
* Check version
*/
- self::assertEquals(Application::APP_VERSION, trim(file_get_contents(__DIR__ . '/../../../version.txt')));
+ $this->assertSame(Application::APP_VERSION, trim(file_get_contents(__DIR__ . '/../../../version.txt')));
/* @var $loader \Composer\Autoload\ClassLoader */
$prefixes = $loader->getPrefixesPsr4();
- self::assertArrayHasKey('N98\\', $prefixes);
+ $this->assertArrayHasKey('N98\\', $prefixes);
$distConfigArray = Yaml::parse(file_get_contents(__DIR__ . '/../../../config.yaml'));
- $configArray = ['autoloaders' => ['N98MagerunTest' => __DIR__ . '/_ApplicationTestSrc'], 'commands' => ['customCommands' => [0 => 'N98MagerunTest\TestDummyCommand'], 'aliases' => [['cl' => 'cache:list']]], 'init' => ['options' => ['config_model' => 'N98MagerunTest\AlternativeConfigModel']]];
+ $configArray = ['autoloaders' => ['N98MagerunTest' => __DIR__ . '/_ApplicationTestSrc'], 'commands' => ['customCommands' => [0 => \N98MagerunTest\TestDummyCommand::class], 'aliases' => [['cl' => 'cache:list']]], 'init' => ['options' => ['config_model' => \N98MagerunTest\AlternativeConfigModel::class]]];
$application->setAutoExit(false);
$application->init(ArrayFunctions::mergeArrays($distConfigArray, $configArray));
@@ -50,27 +52,27 @@ public function testExecute()
// Check if autoloaders, commands and aliases are registered
$prefixes = $loader->getPrefixes();
- self::assertArrayHasKey('N98MagerunTest', $prefixes);
+ $this->assertArrayHasKey('N98MagerunTest', $prefixes);
$testDummyCommand = $application->find('n98mageruntest:test:dummy');
- self::assertInstanceOf('\N98MagerunTest\TestDummyCommand', $testDummyCommand);
+ $this->assertInstanceOf(\N98MagerunTest\TestDummyCommand::class, $testDummyCommand);
$commandTester = new CommandTester($testDummyCommand);
$commandTester->execute(
['command' => $testDummyCommand->getName()],
);
- self::assertStringContainsString('dummy', $commandTester->getDisplay());
- self::assertTrue($application->getDefinition()->hasOption('root-dir'));
+ $this->assertStringContainsString('dummy', $commandTester->getDisplay());
+ $this->assertTrue($application->getDefinition()->hasOption('root-dir'));
// Test alternative config model
$application->initMagento();
if (version_compare(Mage::getVersion(), '1.7.0.2', '>=')) {
// config_model option is only available in Magento CE >1.6
- self::assertInstanceOf('\N98MagerunTest\AlternativeConfigModel', Mage::getConfig());
+ $this->assertInstanceOf(\N98MagerunTest\AlternativeConfigModel::class, Mage::getConfig());
}
// check alias
- self::assertInstanceOf(ListCommand::class, $application->find('cl'));
+ $this->assertInstanceOf(ListCommand::class, $application->find('cl'));
}
public function testPlugins()
@@ -88,7 +90,7 @@ public function testPlugins()
$application->init($injectConfig);
// Check for module command
- self::assertInstanceOf('TestModule\FooCommand', $application->find('testmodule:foo'));
+ $this->assertInstanceOf(\TestModule\FooCommand::class, $application->find('testmodule:foo'));
}
public function testComposer()
@@ -115,6 +117,6 @@ public function testComposer()
$application->init();
// Check for module command
- self::assertInstanceOf('Acme\FooCommand', $application->find('acme:foo'));
+ $this->assertInstanceOf(\Acme\FooCommand::class, $application->find('acme:foo'));
}
}
diff --git a/tests/N98/Magento/Command/Admin/User/ChangePasswordCommandTest.php b/tests/N98/Magento/Command/Admin/User/ChangePasswordCommandTest.php
index 66207e9ad..8d6533122 100644
--- a/tests/N98/Magento/Command/Admin/User/ChangePasswordCommandTest.php
+++ b/tests/N98/Magento/Command/Admin/User/ChangePasswordCommandTest.php
@@ -1,5 +1,7 @@
command = $this->getMockBuilder(ChangePasswordCommand::class)
->setMethods(['getUserModel'])
@@ -33,7 +37,7 @@ public function setUp(): void
public function testCanChangePassword()
{
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('loadByUsername')
->with('aydin')
->willReturn($this->userModel);
@@ -44,15 +48,16 @@ public function testCanChangePassword()
->willReturn(2);
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('validate');
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('save');
$application = $this->getApplication();
$application->add($this->command);
+
$command = $this->getApplication()->find($this->commandName);
$commandTester = new CommandTester($command);
@@ -60,13 +65,13 @@ public function testCanChangePassword()
['command' => $command->getName(), 'username' => 'aydin', 'password' => 'password'],
);
- self::assertStringContainsString('Password successfully changed', $commandTester->getDisplay());
+ $this->assertStringContainsString('Password successfully changed', $commandTester->getDisplay());
}
public function testReturnEarlyIfUserNotFound()
{
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('loadByUsername')
->with('notauser')
->willReturn($this->userModel);
@@ -78,11 +83,12 @@ public function testReturnEarlyIfUserNotFound()
$application = $this->getApplication();
$application->add($this->command);
+
$command = $this->getApplication()->find($this->commandName);
$commandTester = new CommandTester($command);
$commandTester->execute(['command' => $command->getName(), 'username' => 'notauser']);
- self::assertStringContainsString('User was not found', $commandTester->getDisplay());
+ $this->assertStringContainsString('User was not found', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Admin/User/ChangeStatusCommandTest.php b/tests/N98/Magento/Command/Admin/User/ChangeStatusCommandTest.php
index ff48e700d..431755d83 100644
--- a/tests/N98/Magento/Command/Admin/User/ChangeStatusCommandTest.php
+++ b/tests/N98/Magento/Command/Admin/User/ChangeStatusCommandTest.php
@@ -1,5 +1,7 @@
command = $this->getMockBuilder(ChangeStatusCommand::class)
->setMethods(['getUserModel'])
@@ -35,7 +39,7 @@ public function testCanEnableByUser()
{
$username = 'aydin';
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('loadByUsername')
->with($username)
->willReturn($this->userModel);
@@ -51,7 +55,7 @@ public function testCanEnableByUser()
->willReturn(2);
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('validate');
$this->userModel
@@ -60,12 +64,12 @@ public function testCanEnableByUser()
->willReturn(0);
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('setIsActive')
->with(1);
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('save');
$this->userModel
@@ -74,12 +78,13 @@ public function testCanEnableByUser()
->willReturn(1);
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('getUsername')
->willReturn($username);
$application = $this->getApplication();
$application->add($this->command);
+
$command = $this->getApplication()->find($this->commandName);
$commandTester = new CommandTester($command);
@@ -87,14 +92,14 @@ public function testCanEnableByUser()
['command' => $command->getName(), 'id' => $username],
);
- self::assertStringContainsString("User $username is now active", $commandTester->getDisplay());
+ $this->assertStringContainsString(sprintf('User %s is now active', $username), $commandTester->getDisplay());
}
public function testCanDisableUser()
{
$username = 'aydin';
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('loadByUsername')
->with($username)
->willReturn($this->userModel);
@@ -110,7 +115,7 @@ public function testCanDisableUser()
->willReturn(2);
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('validate');
$this->userModel
@@ -119,12 +124,12 @@ public function testCanDisableUser()
->willReturn(1);
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('setIsActive')
->with(0);
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('save');
$this->userModel
@@ -133,12 +138,13 @@ public function testCanDisableUser()
->willReturn(2);
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('getUsername')
->willReturn($username);
$application = $this->getApplication();
$application->add($this->command);
+
$command = $this->getApplication()->find($this->commandName);
$commandTester = new CommandTester($command);
@@ -146,14 +152,14 @@ public function testCanDisableUser()
['command' => $command->getName(), 'id' => $username],
);
- self::assertStringContainsString("User $username is now inactive", $commandTester->getDisplay());
+ $this->assertStringContainsString(sprintf('User %s is now inactive', $username), $commandTester->getDisplay());
}
public function testCanToggleUserByEmail()
{
$username = 'aydin';
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('loadByUsername')
->with($username)
->willReturn($this->userModel);
@@ -164,7 +170,7 @@ public function testCanToggleUserByEmail()
->willReturn(0);
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('load')
->willReturn($this->userModel);
@@ -174,7 +180,7 @@ public function testCanToggleUserByEmail()
->willReturn(2);
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('validate');
$this->userModel
@@ -183,12 +189,12 @@ public function testCanToggleUserByEmail()
->willReturn(0);
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('setIsActive')
->with(1);
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('save');
$this->userModel
@@ -197,12 +203,13 @@ public function testCanToggleUserByEmail()
->willReturn(1);
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('getUsername')
->willReturn($username);
$application = $this->getApplication();
$application->add($this->command);
+
$command = $this->getApplication()->find($this->commandName);
$commandTester = new CommandTester($command);
@@ -210,13 +217,13 @@ public function testCanToggleUserByEmail()
['command' => $command->getName(), 'id' => $username],
);
- self::assertStringContainsString("User $username is now active", $commandTester->getDisplay());
+ $this->assertStringContainsString(sprintf('User %s is now active', $username), $commandTester->getDisplay());
}
public function testReturnEarlyIfUserNotFound()
{
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('loadByUsername')
->with('notauser')
->willReturn($this->userModel);
@@ -227,7 +234,7 @@ public function testReturnEarlyIfUserNotFound()
->willReturn(null);
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('load')
->with('notauser', 'email')
->willReturn($this->userModel);
@@ -239,12 +246,13 @@ public function testReturnEarlyIfUserNotFound()
$application = $this->getApplication();
$application->add($this->command);
+
$command = $this->getApplication()->find($this->commandName);
$commandTester = new CommandTester($command);
$commandTester->execute(['command' => $command->getName(), 'id' => 'notauser']);
- self::assertStringContainsString('User was not found', $commandTester->getDisplay());
+ $this->assertStringContainsString('User was not found', $commandTester->getDisplay());
}
public function testIfNoIdIsPresentItIsPromptedFor()
@@ -255,12 +263,12 @@ public function testIfNoIdIsPresentItIsPromptedFor()
->setMethods(['ask'])
->getMock();
- $dialog->expects(self::once())
+ $dialog->expects($this->once())
->method('ask')
->willReturn($userEmail);
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('loadByUsername')
->with($userEmail)
->willReturn($this->userModel);
@@ -275,6 +283,7 @@ public function testIfNoIdIsPresentItIsPromptedFor()
$application = $this->getApplication();
$application->add($this->command);
+
$command = $this->getApplication()->find($this->commandName);
// We override the standard helper with our mock
@@ -283,6 +292,6 @@ public function testIfNoIdIsPresentItIsPromptedFor()
$commandTester = new CommandTester($command);
$commandTester->execute(['command' => $command->getName()]);
- self::assertStringContainsString('User aydin is now inactive', $commandTester->getDisplay());
+ $this->assertStringContainsString('User aydin is now inactive', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Admin/User/CreateUserCommandTest.php b/tests/N98/Magento/Command/Admin/User/CreateUserCommandTest.php
index 47c827b00..b3acde662 100644
--- a/tests/N98/Magento/Command/Admin/User/CreateUserCommandTest.php
+++ b/tests/N98/Magento/Command/Admin/User/CreateUserCommandTest.php
@@ -1,5 +1,7 @@
command = $this->getMockBuilder(CreateUserCommand::class)
->setMethods(['getUserModel', 'getRoleModel', 'getRulesModel'])
@@ -82,7 +88,7 @@ public function testArgumentPromptsWhenNotPresent()
->willReturn('Hassan');
$this->roleModel
- ->expects(self::once())
+ ->expects($this->once())
->method('load')
->with('Administrators', 'role_name')
->willReturn($this->roleModel);
@@ -105,12 +111,12 @@ public function testArgumentPromptsWhenNotPresent()
->willReturn($this->userModel);
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('save')
->willReturn($this->userModel);
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('setRoleIds')
->with([9])
->willReturn($this->userModel);
@@ -121,17 +127,18 @@ public function testArgumentPromptsWhenNotPresent()
->willReturn(2);
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('setRoleUserId')
->with(2)
->willReturn($this->userModel);
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('saveRelations');
$application = $this->getApplication();
$application->add($this->command);
+
$command = $this->getApplication()->find($this->commandName);
// We override the standard helper with our mock
@@ -140,40 +147,42 @@ public function testArgumentPromptsWhenNotPresent()
$commandTester = new CommandTester($command);
$commandTester->execute(['command' => $command->getName(), 'role' => 'Administrators']);
- self::assertStringContainsString('User aydin successfully created', $commandTester->getDisplay());
+ $this->assertStringContainsString('User aydin successfully created', $commandTester->getDisplay());
}
public function testInvalidRole()
{
$application = $this->getApplication();
$application->add($this->command);
+
$command = $this->getApplication()->find($this->commandName);
$this->roleModel
- ->expects(self::once())
+ ->expects($this->once())
->method('load')
->with('invalid role', 'role_name')
->willReturn($this->roleModel);
$this->roleModel
- ->expects(self::once())
+ ->expects($this->once())
->method('getId')
->willReturn(null);
$commandTester = new CommandTester($command);
$commandTester->execute(['command' => $command->getName(), 'username' => 'aydin', 'firstname' => 'Aydin', 'lastname' => 'Hassan', 'email' => 'aydin@hotmail.co.uk', 'password' => 'p4ssw0rd', 'role' => 'invalid role']);
- self::assertStringContainsString('Role was not found', $commandTester->getDisplay());
+ $this->assertStringContainsString('Role was not found', $commandTester->getDisplay());
}
public function testCreatingDevelopmentRole()
{
$application = $this->getApplication();
$application->add($this->command);
+
$command = $this->getApplication()->find($this->commandName);
$this->roleModel
- ->expects(self::once())
+ ->expects($this->once())
->method('load')
->with('Development', 'role_name')
->willReturn($this->roleModel);
@@ -184,19 +193,19 @@ public function testCreatingDevelopmentRole()
->willReturn(null);
$this->roleModel
- ->expects(self::once())
+ ->expects($this->once())
->method('setName')
->with('Development')
->willReturn($this->roleModel);
$this->roleModel
- ->expects(self::once())
+ ->expects($this->once())
->method('setRoleType')
->with('G')
->willReturn($this->roleModel);
$this->roleModel
- ->expects(self::once())
+ ->expects($this->once())
->method('save');
$this->roleModel
@@ -205,19 +214,19 @@ public function testCreatingDevelopmentRole()
->willReturn(5);
$this->rulesModel
- ->expects(self::once())
+ ->expects($this->once())
->method('setRoleId')
->with(5)
->willReturn($this->rulesModel);
$this->rulesModel
- ->expects(self::once())
+ ->expects($this->once())
->method('setResources')
->with(['all'])
->willReturn($this->rulesModel);
$this->rulesModel
- ->expects(self::once())
+ ->expects($this->once())
->method('saveRel');
$this->userModel
@@ -234,7 +243,7 @@ public function testCreatingDevelopmentRole()
->willReturn($this->userModel);
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('save')
->willReturn($this->userModel);
@@ -244,7 +253,7 @@ public function testCreatingDevelopmentRole()
->willReturn(5);
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('setRoleIds')
->with([5])
->willReturn($this->userModel);
@@ -255,13 +264,13 @@ public function testCreatingDevelopmentRole()
->willReturn(2);
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('setRoleUserId')
->with(2)
->willReturn($this->userModel);
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('saveRelations');
$commandTester = new CommandTester($command);
@@ -274,7 +283,7 @@ public function testCreatingDevelopmentRole()
'password' => 'p4ssw0rd',
]);
- self::assertStringContainsString('The role Development was automatically created', $commandTester->getDisplay());
- self::assertStringContainsString('User aydin successfully created', $commandTester->getDisplay());
+ $this->assertStringContainsString('The role Development was automatically created', $commandTester->getDisplay());
+ $this->assertStringContainsString('User aydin successfully created', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Admin/User/DeleteUserCommandTest.php b/tests/N98/Magento/Command/Admin/User/DeleteUserCommandTest.php
index 0006fbf03..d8a233d84 100644
--- a/tests/N98/Magento/Command/Admin/User/DeleteUserCommandTest.php
+++ b/tests/N98/Magento/Command/Admin/User/DeleteUserCommandTest.php
@@ -1,5 +1,7 @@
command = $this->getMockBuilder(DeleteUserCommand::class)
->setMethods(['getUserModel'])
@@ -34,7 +37,7 @@ public function setUp(): void
public function testCanDeleteByUserName()
{
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('loadByUsername')
->with('aydin')
->willReturn($this->userModel);
@@ -50,15 +53,16 @@ public function testCanDeleteByUserName()
->willReturn(2);
$this->userModel
- ->expects(self::never())
+ ->expects($this->never())
->method('load');
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('delete');
$application = $this->getApplication();
$application->add($this->command);
+
$command = $this->getApplication()->find('admin:user:delete');
$commandTester = new CommandTester($command);
@@ -66,13 +70,13 @@ public function testCanDeleteByUserName()
['command' => $command->getName(), 'id' => 'aydin', '--force' => true],
);
- self::assertStringContainsString('User was successfully deleted', $commandTester->getDisplay());
+ $this->assertStringContainsString('User was successfully deleted', $commandTester->getDisplay());
}
public function testCanDeleteByEmail()
{
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('loadByUsername')
->with('aydin@hotmail.co.uk')
->willReturn($this->userModel);
@@ -83,7 +87,7 @@ public function testCanDeleteByEmail()
->willReturn(null);
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('load')
->with('aydin@hotmail.co.uk', 'email')
->willReturn($this->userModel);
@@ -94,11 +98,12 @@ public function testCanDeleteByEmail()
->willReturn(2);
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('delete');
$application = $this->getApplication();
$application->add($this->command);
+
$command = $this->getApplication()->find('admin:user:delete');
$commandTester = new CommandTester($command);
@@ -106,13 +111,13 @@ public function testCanDeleteByEmail()
['command' => $command->getName(), 'id' => 'aydin@hotmail.co.uk', '--force' => true],
);
- self::assertStringContainsString('User was successfully deleted', $commandTester->getDisplay());
+ $this->assertStringContainsString('User was successfully deleted', $commandTester->getDisplay());
}
public function testReturnEarlyIfUserNotFound()
{
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('loadByUsername')
->with('notauser')
->willReturn($this->userModel);
@@ -123,7 +128,7 @@ public function testReturnEarlyIfUserNotFound()
->willReturn(null);
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('load')
->with('notauser', 'email')
->willReturn($this->userModel);
@@ -135,18 +140,19 @@ public function testReturnEarlyIfUserNotFound()
$application = $this->getApplication();
$application->add($this->command);
+
$command = $this->getApplication()->find('admin:user:delete');
$commandTester = new CommandTester($command);
$commandTester->execute(['command' => $command->getName(), 'id' => 'notauser']);
- self::assertStringContainsString('User was not found', $commandTester->getDisplay());
+ $this->assertStringContainsString('User was not found', $commandTester->getDisplay());
}
public function testMessageIsPrintedIfErrorDeleting()
{
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('loadByUsername')
->with('aydin@hotmail.co.uk')
->willReturn($this->userModel);
@@ -157,7 +163,7 @@ public function testMessageIsPrintedIfErrorDeleting()
->willReturn(null);
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('load')
->with('aydin@hotmail.co.uk', 'email')
->willReturn($this->userModel);
@@ -169,12 +175,13 @@ public function testMessageIsPrintedIfErrorDeleting()
$exception = new Exception('Error!');
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('delete')
- ->will(self::throwException($exception));
+ ->willThrowException($exception);
$application = $this->getApplication();
$application->add($this->command);
+
$command = $this->getApplication()->find('admin:user:delete');
$commandTester = new CommandTester($command);
@@ -182,13 +189,13 @@ public function testMessageIsPrintedIfErrorDeleting()
['command' => $command->getName(), 'id' => 'aydin@hotmail.co.uk', '--force' => true],
);
- self::assertStringContainsString('Error!', $commandTester->getDisplay());
+ $this->assertStringContainsString('Error!', $commandTester->getDisplay());
}
public function testConfirmationTrueReplyDeletesUser()
{
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('loadByUsername')
->with('notauser')
->willReturn($this->userModel);
@@ -199,7 +206,7 @@ public function testConfirmationTrueReplyDeletesUser()
->willReturn(null);
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('load')
->with('notauser', 'email')
->willReturn($this->userModel);
@@ -210,18 +217,19 @@ public function testConfirmationTrueReplyDeletesUser()
->willReturn(2);
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('delete');
$application = $this->getApplication();
$application->add($this->command);
+
$command = $this->getApplication()->find('admin:user:delete');
$questionHelper = $this->getMockBuilder(QuestionHelper::class)
->onlyMethods(['ask'])
->getMock();
- $questionHelper->expects(self::once())
+ $questionHelper->expects($this->once())
->method('ask')
->willReturn(true);
@@ -231,13 +239,13 @@ public function testConfirmationTrueReplyDeletesUser()
$commandTester = new CommandTester($command);
$commandTester->execute(['command' => $command->getName(), 'id' => 'notauser']);
- self::assertStringContainsString('User was successfully deleted', $commandTester->getDisplay());
+ $this->assertStringContainsString('User was successfully deleted', $commandTester->getDisplay());
}
public function testConfirmationFalseReplyDoesNotDeleteUser()
{
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('loadByUsername')
->with('notauser')
->willReturn($this->userModel);
@@ -248,7 +256,7 @@ public function testConfirmationFalseReplyDoesNotDeleteUser()
->willReturn(null);
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('load')
->with('notauser', 'email')
->willReturn($this->userModel);
@@ -259,18 +267,19 @@ public function testConfirmationFalseReplyDoesNotDeleteUser()
->willReturn(2);
$this->userModel
- ->expects(self::never())
+ ->expects($this->never())
->method('delete');
$application = $this->getApplication();
$application->add($this->command);
+
$command = $this->getApplication()->find('admin:user:delete');
$questionHelper = $this->getMockBuilder(QuestionHelper::class)
->onlyMethods(['ask'])
->getMock();
- $questionHelper->expects(self::once())
+ $questionHelper->expects($this->once())
->method('ask')
->willReturn(false);
@@ -283,7 +292,7 @@ public function testConfirmationFalseReplyDoesNotDeleteUser()
'id' => 'notauser',
]);
- self::assertStringContainsString('Aborting delete', $commandTester->getDisplay());
+ $this->assertStringContainsString('Aborting delete', $commandTester->getDisplay());
}
public function testIfNoIdIsPresentItIsPromptedFor()
@@ -292,12 +301,12 @@ public function testIfNoIdIsPresentItIsPromptedFor()
->onlyMethods(['ask'])
->getMock();
- $questionHelper->expects(self::once())
+ $questionHelper->expects($this->once())
->method('ask')
->willReturn('aydin@hotmail.co.uk');
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('loadByUsername')
->with('aydin@hotmail.co.uk')
->willReturn($this->userModel);
@@ -308,7 +317,7 @@ public function testIfNoIdIsPresentItIsPromptedFor()
->willReturn(null);
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('load')
->with('aydin@hotmail.co.uk', 'email')
->willReturn($this->userModel);
@@ -319,11 +328,12 @@ public function testIfNoIdIsPresentItIsPromptedFor()
->willReturn(2);
$this->userModel
- ->expects(self::once())
+ ->expects($this->once())
->method('delete');
$application = $this->getApplication();
$application->add($this->command);
+
$command = $this->getApplication()->find('admin:user:delete');
// We override the standard helper with our mock
@@ -332,6 +342,6 @@ public function testIfNoIdIsPresentItIsPromptedFor()
$commandTester = new CommandTester($command);
$commandTester->execute(['command' => $command->getName(), '--force' => true]);
- self::assertStringContainsString('User was successfully deleted', $commandTester->getDisplay());
+ $this->assertStringContainsString('User was successfully deleted', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Admin/User/ListCommandTest.php b/tests/N98/Magento/Command/Admin/User/ListCommandTest.php
index 79562cb00..22e2bd482 100644
--- a/tests/N98/Magento/Command/Admin/User/ListCommandTest.php
+++ b/tests/N98/Magento/Command/Admin/User/ListCommandTest.php
@@ -1,24 +1,27 @@
getApplication();
$application->add(new ListCommand());
+
$command = $this->getApplication()->find('admin:user:list');
$commandTester = new CommandTester($command);
$commandTester->execute(['command' => $command->getName()]);
- self::assertStringContainsString('id', $commandTester->getDisplay());
- self::assertStringContainsString('user', $commandTester->getDisplay());
- self::assertStringContainsString('email', $commandTester->getDisplay());
- self::assertStringContainsString('status', $commandTester->getDisplay());
+ $this->assertStringContainsString('id', $commandTester->getDisplay());
+ $this->assertStringContainsString('user', $commandTester->getDisplay());
+ $this->assertStringContainsString('email', $commandTester->getDisplay());
+ $this->assertStringContainsString('status', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Cache/CleanCommandTest.php b/tests/N98/Magento/Command/Cache/CleanCommandTest.php
index ec131b0f6..9b2a31dc6 100644
--- a/tests/N98/Magento/Command/Cache/CleanCommandTest.php
+++ b/tests/N98/Magento/Command/Cache/CleanCommandTest.php
@@ -1,5 +1,7 @@
isMagentoEnterprise()) {
$against = '1.14.0.0';
}
+
if (-1 != version_compare($version, $against)) {
self::markTestSkipped(
sprintf(
@@ -42,18 +45,20 @@ public function testExecute()
{
$application = $this->getApplication();
$application->add(new CleanCommand());
+
$command = $this->getApplication()->find('cache:clean');
$commandTester = new CommandTester($command);
$commandTester->execute(['command' => $command->getName()]);
- self::assertStringContainsString('Cache config cleaned', $commandTester->getDisplay());
+ $this->assertStringContainsString('Cache config cleaned', $commandTester->getDisplay());
}
public function testItCanCleanMultipleCaches()
{
$application = $this->getApplication();
$application->add(new CleanCommand());
+
$command = $this->getApplication()->find('cache:clean');
$commandTester = new CommandTester($command);
@@ -61,7 +66,7 @@ public function testItCanCleanMultipleCaches()
$display = $commandTester->getDisplay();
- self::assertStringContainsString('Cache config cleaned', $display);
- self::assertStringContainsString('Cache layout cleaned', $display);
+ $this->assertStringContainsString('Cache config cleaned', $display);
+ $this->assertStringContainsString('Cache layout cleaned', $display);
}
}
diff --git a/tests/N98/Magento/Command/Cache/Dir/FlushCommandTest.php b/tests/N98/Magento/Command/Cache/Dir/FlushCommandTest.php
index c83e28359..0c49de88e 100644
--- a/tests/N98/Magento/Command/Cache/Dir/FlushCommandTest.php
+++ b/tests/N98/Magento/Command/Cache/Dir/FlushCommandTest.php
@@ -1,5 +1,7 @@
execute(['command' => $command->getName()]);
$display = $commandTester->getDisplay();
- self::assertStringContainsString('Flushing cache directory ', $display);
- self::assertStringContainsString('Cache directory flushed', $display);
+ $this->assertStringContainsString('Flushing cache directory ', $display);
+ $this->assertStringContainsString('Cache directory flushed', $display);
}
/**
@@ -39,8 +41,7 @@ private function prepareCommand($object)
{
$application = $this->getApplication();
$application->add($object);
- $command = $application->find($object::NAME);
- return $command;
+ return $application->find($object::NAME);
}
}
diff --git a/tests/N98/Magento/Command/Cache/DisableCommandTest.php b/tests/N98/Magento/Command/Cache/DisableCommandTest.php
index f27249ddb..fb683a745 100644
--- a/tests/N98/Magento/Command/Cache/DisableCommandTest.php
+++ b/tests/N98/Magento/Command/Cache/DisableCommandTest.php
@@ -1,12 +1,14 @@
execute(['command' => $command->getName()]);
- self::assertMatchesRegularExpression('/Caches disabled/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/Caches disabled/', $commandTester->getDisplay());
}
public function testExecuteMultipleCaches()
@@ -31,7 +33,7 @@ public function testExecuteMultipleCaches()
['command' => $command->getName(), 'code' => 'eav,config'],
);
- self::assertMatchesRegularExpression('/Cache config disabled/', $commandTester->getDisplay());
- self::assertMatchesRegularExpression('/Cache eav disabled/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/Cache config disabled/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/Cache eav disabled/', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Cache/EnableCommandTest.php b/tests/N98/Magento/Command/Cache/EnableCommandTest.php
index a8f53f060..23e40f51a 100644
--- a/tests/N98/Magento/Command/Cache/EnableCommandTest.php
+++ b/tests/N98/Magento/Command/Cache/EnableCommandTest.php
@@ -1,23 +1,26 @@
getApplication();
$application->add(new EnableCommand());
+
$command = $this->getApplication()->find('cache:enable');
$commandTester = new CommandTester($command);
$commandTester->execute(['command' => $command->getName()]);
- self::assertMatchesRegularExpression('/Caches enabled/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/Caches enabled/', $commandTester->getDisplay());
}
public function testExecuteMultipleCaches()
@@ -31,7 +34,7 @@ public function testExecuteMultipleCaches()
['command' => $command->getName(), 'code' => 'eav,config'],
);
- self::assertMatchesRegularExpression('/Cache config enabled/', $commandTester->getDisplay());
- self::assertMatchesRegularExpression('/Cache eav enabled/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/Cache config enabled/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/Cache eav enabled/', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Cache/FlushCommandTest.php b/tests/N98/Magento/Command/Cache/FlushCommandTest.php
index 236c518c1..6264fd509 100644
--- a/tests/N98/Magento/Command/Cache/FlushCommandTest.php
+++ b/tests/N98/Magento/Command/Cache/FlushCommandTest.php
@@ -1,22 +1,25 @@
getApplication();
$application->add(new FlushCommand());
+
$command = $this->getApplication()->find('cache:flush');
$commandTester = new CommandTester($command);
$commandTester->execute(['command' => $command->getName()]);
- self::assertMatchesRegularExpression('/Cache cleared/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/Cache cleared/', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Cache/ListCommandTest.php b/tests/N98/Magento/Command/Cache/ListCommandTest.php
index f636a6f27..e3f4c0052 100644
--- a/tests/N98/Magento/Command/Cache/ListCommandTest.php
+++ b/tests/N98/Magento/Command/Cache/ListCommandTest.php
@@ -1,22 +1,25 @@
getApplication();
$application->add(new ListCommand());
+
$command = $this->getApplication()->find('cache:list');
$commandTester = new CommandTester($command);
$commandTester->execute(['command' => $command->getName()]);
- self::assertMatchesRegularExpression('/config/', $commandTester->getDisplay());
- self::assertMatchesRegularExpression('/collections/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/config/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/collections/', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Cache/ReportCommandTest.php b/tests/N98/Magento/Command/Cache/ReportCommandTest.php
index a315725fe..1c0630f95 100644
--- a/tests/N98/Magento/Command/Cache/ReportCommandTest.php
+++ b/tests/N98/Magento/Command/Cache/ReportCommandTest.php
@@ -1,16 +1,19 @@
getApplication();
$application->add(new ListCommand());
+
$command = $this->getApplication()->find('cache:report');
$commandTester = new CommandTester($command);
@@ -18,9 +21,9 @@ public function testExecute()
['command' => $command->getName(), '--tags' => true, '--mtime' => true],
);
- self::assertMatchesRegularExpression('/ID/', $commandTester->getDisplay());
- self::assertMatchesRegularExpression('/EXPIRE/', $commandTester->getDisplay());
- self::assertMatchesRegularExpression('/MTIME/', $commandTester->getDisplay());
- self::assertMatchesRegularExpression('/TAGS/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/ID/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/EXPIRE/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/MTIME/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/TAGS/', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Cache/ViewCommandTest.php b/tests/N98/Magento/Command/Cache/ViewCommandTest.php
index be5379793..9e5df04b9 100644
--- a/tests/N98/Magento/Command/Cache/ViewCommandTest.php
+++ b/tests/N98/Magento/Command/Cache/ViewCommandTest.php
@@ -1,17 +1,20 @@
getApplication();
$application->add(new ListCommand());
+
$command = $this->getApplication()->find('cache:view');
Mage::app()->getCache()->save('TEST n98-magerun', 'n98-magerun-unittest');
@@ -21,13 +24,14 @@ public function testExecute()
['command' => $command->getName(), 'id' => 'n98-magerun-unittest'],
);
- self::assertMatchesRegularExpression('/TEST n98-magerun/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/TEST n98-magerun/', $commandTester->getDisplay());
}
public function testExecuteUnserialize()
{
$application = $this->getApplication();
$application->add(new ListCommand());
+
$command = $this->getApplication()->find('cache:view');
$cacheData = [1, 2, 3, 'foo' => ['bar']];
@@ -38,6 +42,6 @@ public function testExecuteUnserialize()
['command' => $command->getName(), 'id' => 'n98-magerun-unittest', '--unserialize' => true],
);
- self::assertEquals(print_r($cacheData, true) . "\n", $commandTester->getDisplay(true));
+ $this->assertSame(print_r($cacheData, true) . "\n", $commandTester->getDisplay(true));
}
}
diff --git a/tests/N98/Magento/Command/Category/Create/DummyCommandTest.php b/tests/N98/Magento/Command/Category/Create/DummyCommandTest.php
index 127095b66..840fd21ad 100644
--- a/tests/N98/Magento/Command/Category/Create/DummyCommandTest.php
+++ b/tests/N98/Magento/Command/Category/Create/DummyCommandTest.php
@@ -1,5 +1,7 @@
getApplication();
$application->add(new DummyCommand());
+
$command = $application->find('category:create:dummy');
$commandTester = new CommandTester($command);
@@ -23,30 +26,32 @@ public function testExecute()
['command' => $command->getName(), 'store-id' => 1, 'children-categories-number' => 1, 'category-name-prefix' => 'My Awesome Category', 'category-number' => 1],
);
- self::assertMatchesRegularExpression('/CATEGORY: \'My Awesome Category (.+)\' WITH ID: \'(.+)\' CREATED!/', $commandTester->getDisplay());
- self::assertMatchesRegularExpression('/CATEGORY CHILD: \'My Awesome Category (.+)\' WITH ID: \'(.+)\' CREATED!/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression("/CATEGORY: 'My Awesome Category (.+)' WITH ID: '(.+)' CREATED!/", $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression("/CATEGORY CHILD: 'My Awesome Category (.+)' WITH ID: '(.+)' CREATED!/", $commandTester->getDisplay());
// Check if the category is created correctly
$match_parent = '';
$match_child = '';
- preg_match('/CATEGORY: \'My Awesome Category (.+)\' WITH ID: \'(.+)\' CREATED!/', $commandTester->getDisplay(), $match_parent);
- self::assertTrue($this->checkifCategoryExist($match_parent[2]));
- preg_match('/CATEGORY CHILD: \'My Awesome Category (.+)\' WITH ID: \'(.+)\' CREATED!/', $commandTester->getDisplay(), $match_child);
- self::assertTrue($this->checkifCategoryExist($match_child[2]));
+ preg_match("/CATEGORY: 'My Awesome Category (.+)' WITH ID: '(.+)' CREATED!/", $commandTester->getDisplay(), $match_parent);
+ $this->assertTrue($this->checkifCategoryExist($match_parent[2]));
+ preg_match("/CATEGORY CHILD: 'My Awesome Category (.+)' WITH ID: '(.+)' CREATED!/", $commandTester->getDisplay(), $match_child);
+ $this->assertTrue($this->checkifCategoryExist($match_child[2]));
// Delete category created
$this->deleteMagentoCategory($match_parent[2]);
$this->deleteMagentoCategory($match_child[2]);
}
- protected function checkifCategoryExist($_category_id)
+ private function checkifCategoryExist($_category_id)
{
if (!is_null(Mage::getModel('catalog/category')->load($_category_id)->getName())) {
return true;
}
+
+ return null;
}
- protected function deleteMagentoCategory($_category_id)
+ private function deleteMagentoCategory($_category_id)
{
Mage::getModel('catalog/category')->load($_category_id)->delete();
}
@@ -55,6 +60,7 @@ public function testmanageArguments()
{
$application = $this->getApplication();
$application->add(new DummyCommand());
+
$command = $application->find('category:create:dummy');
$dialog = $this->getMockBuilder(QuestionHelper::class)
@@ -114,9 +120,9 @@ public function testmanageArguments()
);
$arguments = $commandTester->getInput()->getArguments();
- self::assertArrayHasKey('store-id', $arguments);
- self::assertArrayHasKey('children-categories-number', $arguments);
- self::assertArrayHasKey('category-name-prefix', $arguments);
- self::assertArrayHasKey('category-number', $arguments);
+ $this->assertArrayHasKey('store-id', $arguments);
+ $this->assertArrayHasKey('children-categories-number', $arguments);
+ $this->assertArrayHasKey('category-name-prefix', $arguments);
+ $this->assertArrayHasKey('category-number', $arguments);
}
}
diff --git a/tests/N98/Magento/Command/Cms/Block/ToggleCommandTest.php b/tests/N98/Magento/Command/Cms/Block/ToggleCommandTest.php
index b6ff684f6..508e7ffc6 100644
--- a/tests/N98/Magento/Command/Cms/Block/ToggleCommandTest.php
+++ b/tests/N98/Magento/Command/Cms/Block/ToggleCommandTest.php
@@ -1,5 +1,7 @@
getApplication();
$application->add(new ToggleCommand());
+
$command = $this->getApplication()->find('cms:block:toggle');
$commandTester = new CommandTester($command);
$victim = Mage::getModel('cms/block')->getCollection()->getFirstItem();
@@ -27,7 +30,7 @@ public function testExecute()
'block_id' => $victim->getId(),
],
);
- self::assertStringContainsString('disabled', $commandTester->getDisplay());
+ $this->assertStringContainsString('disabled', $commandTester->getDisplay());
$commandTester->execute(
[
'command' => $command->getName(),
@@ -35,6 +38,6 @@ public function testExecute()
'block_id' => $victim->getIdentifier(),
],
);
- self::assertStringContainsString('enabled', $commandTester->getDisplay());
+ $this->assertStringContainsString('enabled', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Config/DeleteCommandTest.php b/tests/N98/Magento/Command/Config/DeleteCommandTest.php
index 817359305..6b8060938 100644
--- a/tests/N98/Magento/Command/Config/DeleteCommandTest.php
+++ b/tests/N98/Magento/Command/Config/DeleteCommandTest.php
@@ -1,17 +1,20 @@
getApplication();
$application->add(new DumpCommand());
+
$setCommand = $this->getApplication()->find('config:set');
$deleteCommand = $this->getApplication()->find('config:delete');
@@ -22,13 +25,13 @@ public function testExecute()
$commandTester->execute(
['command' => $setCommand->getName(), 'path' => 'n98_magerun/foo/bar', 'value' => '1234'],
);
- self::assertStringContainsString('n98_magerun/foo/bar => 1234', $commandTester->getDisplay());
+ $this->assertStringContainsString('n98_magerun/foo/bar => 1234', $commandTester->getDisplay());
$commandTester = new CommandTester($deleteCommand);
$commandTester->execute(
['command' => $deleteCommand->getName(), 'path' => 'n98_magerun/foo/bar'],
);
- self::assertStringContainsString('| n98_magerun/foo/bar | default | 0 |', $commandTester->getDisplay());
+ $this->assertStringContainsString('| n98_magerun/foo/bar | default | 0 |', $commandTester->getDisplay());
/**
* Delete all
@@ -53,7 +56,7 @@ public function testExecute()
);
foreach (Mage::app()->getStores() as $store) {
- self::assertStringContainsString('| n98_magerun/foo/bar | stores | ' . $store->getId() . ' |', $commandTester->getDisplay());
+ $this->assertStringContainsString('| n98_magerun/foo/bar | stores | ' . $store->getId() . ' |', $commandTester->getDisplay());
}
}
}
diff --git a/tests/N98/Magento/Command/Config/DumpCommandTest.php b/tests/N98/Magento/Command/Config/DumpCommandTest.php
index 669c9dd96..4c9726b5e 100644
--- a/tests/N98/Magento/Command/Config/DumpCommandTest.php
+++ b/tests/N98/Magento/Command/Config/DumpCommandTest.php
@@ -1,22 +1,25 @@
getApplication();
$application->add(new DumpCommand());
+
$command = $this->getApplication()->find('config:dump');
$commandTester = new CommandTester($command);
$commandTester->execute(
['command' => $command->getName(), 'xpath' => 'global/install'],
);
- self::assertStringContainsString('date', $commandTester->getDisplay());
+ $this->assertStringContainsString('date', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Config/GetCommandTest.php b/tests/N98/Magento/Command/Config/GetCommandTest.php
index 4797236a4..e05d2920e 100644
--- a/tests/N98/Magento/Command/Config/GetCommandTest.php
+++ b/tests/N98/Magento/Command/Config/GetCommandTest.php
@@ -1,16 +1,15 @@
skipMagentoMinimumVersion('1.6.2.0', '1.11.2.0');
@@ -42,20 +41,22 @@ public function nullValues()
# needed to not use the previous output cache
'path' => 'n98_magerun/foo/bar',
],
- 'config:set --scope-id=0 --scope=default -- \'n98_magerun/foo/bar\' NULL',
+ "config:set --scope-id=0 --scope=default -- 'n98_magerun/foo/bar' NULL",
);
}
- public function provideFormatsWithNull()
+ public function provideFormatsWithNull(): \Iterator
{
- return [[null, '~\\Q| n98_magerun/foo/bar | default | 0 | NULL (NULL/"unknown" value) |\\E~'], ['csv', '~\\Qn98_magerun/foo/bar,default,0,NULL\\E~'], ['json', '~"Value": *null~'], ['xml', '~\\QNULL\\E~']];
+ yield [null, '~\\Q| n98_magerun/foo/bar | default | 0 | NULL (NULL/"unknown" value) |\\E~'];
+ yield ['csv', '~\\Qn98_magerun/foo/bar,default,0,NULL\\E~'];
+ yield ['json', '~"Value": *null~'];
+ yield ['xml', '~\\QNULL\\E~'];
}
/**
- * @test
* @dataProvider provideFormatsWithNull
*/
- public function nullWithFormat($format, $expected)
+ public function testNullWithFormat($format, $expected)
{
# Very old Magento versions do not support NULL values in configuration values
$this->skipMagentoMinimumVersion('1.6.2.0', '1.11.2.0');
@@ -150,6 +151,7 @@ private function skipMagentoMinimumVersion($community, $enterprise)
),
);
}
+
break;
case 'Enterprise':
if (version_compare($magentoVersion, $enterprise, '<')) {
@@ -161,6 +163,7 @@ private function skipMagentoMinimumVersion($community, $enterprise)
),
);
}
+
break;
default:
self::markTestSkipped(
diff --git a/tests/N98/Magento/Command/Config/SearchCommandTest.php b/tests/N98/Magento/Command/Config/SearchCommandTest.php
index ae3b5e4f5..e4d8cc393 100644
--- a/tests/N98/Magento/Command/Config/SearchCommandTest.php
+++ b/tests/N98/Magento/Command/Config/SearchCommandTest.php
@@ -1,28 +1,31 @@
getApplication();
$application->add(new DumpCommand());
+
$command = $this->getApplication()->find('config:search');
$commandTester = new CommandTester($command);
$commandTester->execute(
['command' => $command->getName(), 'text' => 'This message will be shown'],
);
- self::assertStringContainsString('Found a field with a match', $commandTester->getDisplay());
+ $this->assertStringContainsString('Found a field with a match', $commandTester->getDisplay());
$commandTester = new CommandTester($command);
$commandTester->execute(
['command' => $command->getName(), 'text' => 'xyz1234567890'],
);
- self::assertStringContainsString('No matches for xyz1234567890', $commandTester->getDisplay());
+ $this->assertStringContainsString('No matches for xyz1234567890', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Customer/CreateCommandTest.php b/tests/N98/Magento/Command/Customer/CreateCommandTest.php
index 3d92bd3ae..aa4fa0682 100644
--- a/tests/N98/Magento/Command/Customer/CreateCommandTest.php
+++ b/tests/N98/Magento/Command/Customer/CreateCommandTest.php
@@ -1,5 +1,7 @@
_getCommand();
+ $createCommand = $this->_getCommand();
$generatedEmail = uniqid('', true) . '@example.com';
$this->getApplication()->initMagento();
$website = Mage::app()->getWebsite();
- $commandTester = new CommandTester($command);
- $options = ['command' => $command->getName(), 'email' => $generatedEmail, 'password' => 'password123', 'firstname' => 'John', 'lastname' => 'Doe', 'website' => $website->getCode()];
+ $commandTester = new CommandTester($createCommand);
+ $options = ['command' => $createCommand->getName(), 'email' => $generatedEmail, 'password' => 'password123', 'firstname' => 'John', 'lastname' => 'Doe', 'website' => $website->getCode()];
$commandTester->execute($options);
- self::assertMatchesRegularExpression('/Customer ' . $generatedEmail . ' successfully created/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/Customer ' . $generatedEmail . ' successfully created/', $commandTester->getDisplay());
// Format option
- $commandTester = new CommandTester($command);
+ $commandTester = new CommandTester($createCommand);
$generatedEmail = uniqid('', true) . '@example.com';
$options['email'] = $generatedEmail;
$options['--format'] = 'csv';
- self::assertEquals(0, $commandTester->execute($options));
- self::assertStringContainsString('email,password,firstname,lastname', $commandTester->getDisplay());
- self::assertStringContainsString($generatedEmail . ',password123,John,Doe', $commandTester->getDisplay());
+ $this->assertSame(0, $commandTester->execute($options));
+ $this->assertStringContainsString('email,password,firstname,lastname', $commandTester->getDisplay());
+ $this->assertStringContainsString($generatedEmail . ',password123,John,Doe', $commandTester->getDisplay());
}
public function testWithWrongPassword()
@@ -60,13 +62,13 @@ public function testWithWrongPassword()
$options = ['command' => $command->getName(), 'email' => $generatedEmail, 'password' => 'pass', 'firstname' => 'John', 'lastname' => 'Doe'];
$commandTester = new CommandTester($command);
$commandTester->execute($options);
- self::assertMatchesRegularExpression('/The password must have at least 6 characters. Leading or trailing spaces will be ignored./', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/The password must have at least 6 characters. Leading or trailing spaces will be ignored./', $commandTester->getDisplay());
}
/**
* @return CreateCommand
*/
- protected function _getCommand()
+ private function _getCommand()
{
$application = $this->getApplication();
$application->add(new CreateCommand());
diff --git a/tests/N98/Magento/Command/Customer/DeleteCommandTest.php b/tests/N98/Magento/Command/Customer/DeleteCommandTest.php
index 231566f7b..94e5f688c 100644
--- a/tests/N98/Magento/Command/Customer/DeleteCommandTest.php
+++ b/tests/N98/Magento/Command/Customer/DeleteCommandTest.php
@@ -1,5 +1,7 @@
getModelClassName('customer/customer');
return $this->getMockBuilder($className)
@@ -41,7 +47,7 @@ protected function getCustomerModel(array $methods)
->getMock();
}
- protected function getCustomerCollection(array $methods)
+ private function getCustomerCollection(array $methods)
{
$className = $this->getResourceClassName('customer/customer_collection');
return $this->getMockBuilder($className)
@@ -53,8 +59,8 @@ protected function getCustomerCollection(array $methods)
protected function setUp(): void
{
$this->markTestIncomplete('This tests are not compatible with PHPUnit 9. Refactring is needed.');
- $this->application = $this->getApplication();
- $this->application->initMagento();
+ $application = $this->getApplication();
+ $application->initMagento();
$this->customerModel = $this->getCustomerModel(['loadByEmail', 'load', 'getId', 'delete', 'setWebsiteId']);
$this->customerCollection = $this->getCustomerCollection(['addAttributeToSelect', 'addAttributeToFilter']);
@@ -71,7 +77,7 @@ protected function setUp(): void
->onlyMethods(['askWebsite'])
->getMock();
- $this->website = $this->getMockBuilder('Mage_Core_Model_Website')
+ $website = $this->getMockBuilder('Mage_Core_Model_Website')
->setMethods(['getId'])
->getMock();
@@ -89,9 +95,9 @@ protected function setUp(): void
$this->parameterHelper
->method('askWebsite')
- ->willReturn($this->website);
+ ->willReturn($website);
- $this->website
+ $website
->method('getId')
->willReturn(1);
}
@@ -99,7 +105,7 @@ protected function setUp(): void
public function testCanDeleteById()
{
$this->customerModel
- ->expects(self::once())
+ ->expects($this->once())
->method('load')
->with('1')
->willReturn($this->customerModel);
@@ -115,15 +121,16 @@ public function testCanDeleteById()
->willReturn(1);
$this->customerModel
- ->expects(self::never())
+ ->expects($this->never())
->method('loadByEmail');
$this->customerModel
- ->expects(self::once())
+ ->expects($this->once())
->method('delete');
$application = $this->getApplication();
$application->add($this->command);
+
$command = $this->getApplication()->find('customer:delete');
$command->getHelperSet()->set($this->questionHelper, 'question');
@@ -132,13 +139,13 @@ public function testCanDeleteById()
['command' => $command->getName(), 'id' => '1', '--force' => true],
);
- self::assertStringContainsString('successfully deleted', $commandTester->getDisplay());
+ $this->assertStringContainsString('successfully deleted', $commandTester->getDisplay());
}
public function testCanDeleteByEmail()
{
$this->customerModel
- ->expects(self::once())
+ ->expects($this->once())
->method('load')
->with('mike@testing.com')
->willReturn($this->customerModel);
@@ -149,13 +156,13 @@ public function testCanDeleteByEmail()
->willReturn(null);
$this->customerModel
- ->expects(self::once())
+ ->expects($this->once())
->method('setWebsiteId')
->with(1)
->willReturn($this->customerModel);
$this->customerModel
- ->expects(self::once())
+ ->expects($this->once())
->method('loadByEmail')
->with('mike@testing.com')
->willReturn($this->customerModel);
@@ -166,11 +173,12 @@ public function testCanDeleteByEmail()
->willReturn(1);
$this->customerModel
- ->expects(self::once())
+ ->expects($this->once())
->method('delete');
$application = $this->getApplication();
$application->add($this->command);
+
$command = $this->getApplication()->find('customer:delete');
$command->getHelperSet()->set($this->questionHelper, 'question');
@@ -179,13 +187,13 @@ public function testCanDeleteByEmail()
['command' => $command->getName(), 'id' => 'mike@testing.com', '--force' => true],
);
- self::assertStringContainsString('successfully deleted', $commandTester->getDisplay());
+ $this->assertStringContainsString('successfully deleted', $commandTester->getDisplay());
}
public function testCustomerNotFound()
{
$this->customerModel
- ->expects(self::once())
+ ->expects($this->once())
->method('load')
->with('mike@testing.com')
->willReturn($this->customerModel);
@@ -196,19 +204,20 @@ public function testCustomerNotFound()
->willReturn(null);
$this->customerModel
- ->expects(self::once())
+ ->expects($this->once())
->method('setWebsiteId')
->with(1)
->willReturn($this->customerModel);
$this->customerModel
- ->expects(self::once())
+ ->expects($this->once())
->method('loadByEmail')
->with('mike@testing.com')
->willReturn($this->customerModel);
$application = $this->getApplication();
$application->add($this->command);
+
$command = $this->getApplication()->find('customer:delete');
$command->getHelperSet()->set($this->questionHelper, 'question');
@@ -217,13 +226,13 @@ public function testCustomerNotFound()
['command' => $command->getName(), 'id' => 'mike@testing.com', '--force' => true],
);
- self::assertStringContainsString('No customer found!', $commandTester->getDisplay());
+ $this->assertStringContainsString('No customer found!', $commandTester->getDisplay());
}
public function testDeleteFailed()
{
$this->customerModel
- ->expects(self::once())
+ ->expects($this->once())
->method('load')
->with('1')
->willReturn($this->customerModel);
@@ -239,16 +248,17 @@ public function testDeleteFailed()
->willReturn(1);
$this->customerModel
- ->expects(self::never())
+ ->expects($this->never())
->method('loadByEmail');
$this->customerModel
- ->expects(self::once())
+ ->expects($this->once())
->method('delete')
- ->will(self::throwException(new Exception('Failed to save')));
+ ->willThrowException(new Exception('Failed to save'));
$application = $this->getApplication();
$application->add($this->command);
+
$command = $this->getApplication()->find('customer:delete');
$commandTester = new CommandTester($command);
@@ -258,7 +268,7 @@ public function testDeleteFailed()
['command' => $command->getName(), 'id' => '1', '--force' => true],
);
- self::assertStringContainsString('Failed to save', $commandTester->getDisplay());
+ $this->assertStringContainsString('Failed to save', $commandTester->getDisplay());
}
public function testPromptForCustomerIdAndDelete()
@@ -274,7 +284,7 @@ public function testPromptForCustomerIdAndDelete()
->willReturn('1');
$this->customerModel
- ->expects(self::once())
+ ->expects($this->once())
->method('load')
->with('1')
->willReturn($this->customerModel);
@@ -290,15 +300,16 @@ public function testPromptForCustomerIdAndDelete()
->willReturn(1);
$this->customerModel
- ->expects(self::never())
+ ->expects($this->never())
->method('loadByEmail');
$this->customerModel
- ->expects(self::once())
+ ->expects($this->once())
->method('delete');
$application = $this->getApplication();
$application->add($this->command);
+
$command = $this->getApplication()->find('customer:delete');
$command->getHelperSet()->set($this->questionHelper, 'question');
$command->getHelperSet()->set($this->parameterHelper, 'parameter');
@@ -309,23 +320,24 @@ public function testPromptForCustomerIdAndDelete()
['command' => $command->getName(), '--force' => true],
);
- self::assertStringContainsString('successfully deleted', $commandTester->getDisplay());
+ $this->assertStringContainsString('successfully deleted', $commandTester->getDisplay());
}
public function testBatchDeleteGetsCustomerCollection()
{
$this->customerCollection
- ->expects(self::atLeastOnce())
+ ->expects($this->atLeastOnce())
->method('addAttributeToSelect')
->willReturnMap([['firstname', false, $this->customerCollection], ['lastname', false, $this->customerCollection], ['email', false, $this->customerCollection]]);
$this->questionHelper
- ->expects(self::once())
+ ->expects($this->once())
->method('ask')
->willReturn(false);
$application = $this->getApplication();
$application->add($this->command);
+
$command = $this->getApplication()->find('customer:delete');
$commandTester = new CommandTester($command);
@@ -335,13 +347,13 @@ public function testBatchDeleteGetsCustomerCollection()
['command' => $command->getName(), '--all' => true],
);
- self::assertStringContainsString('Aborting delete', $commandTester->getDisplay());
+ $this->assertStringContainsString('Aborting delete', $commandTester->getDisplay());
}
public function testRangeDeleteGetsCustomerCollection()
{
$this->customerCollection
- ->expects(self::atLeastOnce())
+ ->expects($this->atLeastOnce())
->method('addAttributeToSelect')
->willReturnMap([['firstname', false, $this->customerCollection], ['lastname', false, $this->customerCollection], ['email', false, $this->customerCollection]]);
@@ -360,7 +372,7 @@ public function testRangeDeleteGetsCustomerCollection()
->willReturn('10');
$this->customerCollection
- ->expects(self::once())
+ ->expects($this->once())
->method('addAttributeToFilter')
->willReturn($this->customerCollection);
@@ -371,6 +383,7 @@ public function testRangeDeleteGetsCustomerCollection()
$application = $this->getApplication();
$application->add($this->command);
+
$command = $this->getApplication()->find('customer:delete');
$commandTester = new CommandTester($command);
@@ -380,13 +393,13 @@ public function testRangeDeleteGetsCustomerCollection()
['command' => $command->getName(), '--range' => true],
);
- self::assertStringContainsString('Aborting delete', $commandTester->getDisplay());
+ $this->assertStringContainsString('Aborting delete', $commandTester->getDisplay());
}
public function testShouldRemoveStopsDeletion()
{
$this->customerModel
- ->expects(self::once())
+ ->expects($this->once())
->method('load')
->with('1')
->willReturn($this->customerModel);
@@ -402,20 +415,21 @@ public function testShouldRemoveStopsDeletion()
->willReturn(1);
$this->customerModel
- ->expects(self::never())
+ ->expects($this->never())
->method('loadByEmail');
$this->questionHelper
- ->expects(self::once())
+ ->expects($this->once())
->method('askConfirmation')
->willReturn(false);
$this->customerModel
- ->expects(self::never())
+ ->expects($this->never())
->method('delete');
$application = $this->getApplication();
$application->add($this->command);
+
$command = $this->getApplication()->find('customer:delete');
$commandTester = new CommandTester($command);
@@ -425,13 +439,13 @@ public function testShouldRemoveStopsDeletion()
['command' => $command->getName(), 'id' => '1'],
);
- self::assertStringContainsString('Aborting delete', $commandTester->getDisplay());
+ $this->assertStringContainsString('Aborting delete', $commandTester->getDisplay());
}
public function testShouldRemovePromptAllowsDeletion()
{
$this->customerModel
- ->expects(self::once())
+ ->expects($this->once())
->method('load')
->with('1')
->willReturn($this->customerModel);
@@ -447,20 +461,21 @@ public function testShouldRemovePromptAllowsDeletion()
->willReturn(1);
$this->customerModel
- ->expects(self::never())
+ ->expects($this->never())
->method('loadByEmail');
$this->questionHelper
- ->expects(self::once())
+ ->expects($this->once())
->method('askConfirmation')
->willReturn(true);
$this->customerModel
- ->expects(self::once())
+ ->expects($this->once())
->method('delete');
$application = $this->getApplication();
$application->add($this->command);
+
$command = $this->getApplication()->find('customer:delete');
$commandTester = new CommandTester($command);
@@ -470,18 +485,18 @@ public function testShouldRemovePromptAllowsDeletion()
['command' => $command->getName(), 'id' => '1'],
);
- self::assertStringContainsString('successfully deleted', $commandTester->getDisplay());
+ $this->assertStringContainsString('successfully deleted', $commandTester->getDisplay());
}
public function testPromptDeleteAllAndDeleteRangeAndAbort()
{
$this->questionHelper
->expects(self::exactly(3))
- ->method('askConfirmation')
- ->will(self::onConsecutiveCalls(true, false, false));
+ ->method('askConfirmation')->willReturnOnConsecutiveCalls(true, false, false);
$application = $this->getApplication();
$application->add($this->command);
+
$command = $this->getApplication()->find('customer:delete');
$commandTester = new CommandTester($command);
@@ -491,7 +506,7 @@ public function testPromptDeleteAllAndDeleteRangeAndAbort()
['command' => $command->getName()],
);
- self::assertStringContainsString('nothing to do', $commandTester->getDisplay());
+ $this->assertStringContainsString('nothing to do', $commandTester->getDisplay());
}
public function testPromptAllCanDeleteAll()
@@ -499,7 +514,7 @@ public function testPromptAllCanDeleteAll()
$this->questionHelper
->expects(self::exactly(2))
->method('askConfirmation')
- ->will(self::onConsecutiveCalls(true, true));
+ ->willReturn(true);
$this->customerCollection
->expects(self::exactly(3))
@@ -507,13 +522,14 @@ public function testPromptAllCanDeleteAll()
->willReturnMap([['firstname', false, $this->customerCollection], ['lastname', false, $this->customerCollection], ['email', false, $this->customerCollection]]);
$this->command
- ->expects(self::once())
+ ->expects($this->once())
->method('batchDelete')
->with($this->customerCollection)
->willReturn(3);
$application = $this->getApplication();
$application->add($this->command);
+
$command = $this->getApplication()->find('customer:delete');
$command->getHelperSet()->set($this->questionHelper, 'question');
@@ -522,18 +538,17 @@ public function testPromptAllCanDeleteAll()
['command' => $command->getName(), '--force' => true],
);
- self::assertStringContainsString('Successfully deleted 3 customer/s', $commandTester->getDisplay());
+ $this->assertStringContainsString('Successfully deleted 3 customer/s', $commandTester->getDisplay());
}
public function testPromptRangeCanDeleteRange()
{
$this->questionHelper
->expects(self::exactly(3))
- ->method('askConfirmation')
- ->will(self::onConsecutiveCalls(true, false, true));
+ ->method('askConfirmation')->willReturnOnConsecutiveCalls(true, false, true);
$this->customerCollection
- ->expects(self::atLeastOnce())
+ ->expects($this->atLeastOnce())
->method('addAttributeToSelect')
->willReturnMap([['firstname', false, $this->customerCollection], ['lastname', false, $this->customerCollection], ['email', false, $this->customerCollection]]);
@@ -552,18 +567,18 @@ public function testPromptRangeCanDeleteRange()
->willReturn('10');
$this->customerCollection
- ->expects(self::once())
- ->method('addAttributeToFilter')
- ->will(self::returnSelf());
+ ->expects($this->once())
+ ->method('addAttributeToFilter')->willReturnSelf();
$this->command
- ->expects(self::once())
+ ->expects($this->once())
->method('batchDelete')
->with($this->customerCollection)
->willReturn(3);
$application = $this->getApplication();
$application->add($this->command);
+
$command = $this->getApplication()->find('customer:delete');
$commandTester = new CommandTester($command);
@@ -571,7 +586,7 @@ public function testPromptRangeCanDeleteRange()
['command' => $command->getName(), '--force' => true],
);
- self::assertStringContainsString('Successfully deleted 3 customer/s', $commandTester->getDisplay());
+ $this->assertStringContainsString('Successfully deleted 3 customer/s', $commandTester->getDisplay());
}
public function testBatchDelete()
@@ -583,37 +598,36 @@ public function testBatchDelete()
$command
->expects(self::exactly(2))
- ->method('deleteCustomer')
- ->will(self::onConsecutiveCalls(true, new Exception('Failed to delete')));
+ ->method('deleteCustomer')->willReturnOnConsecutiveCalls(true, new Exception('Failed to delete'));
- $refObject = new ReflectionObject($command);
- $method = $refObject->getMethod('batchDelete');
- $method->setAccessible(true);
+ $reflectionObject = new ReflectionObject($command);
+ $reflectionMethod = $reflectionObject->getMethod('batchDelete');
+ $reflectionMethod->setAccessible(true);
$data = new ArrayIterator([$this->customerModel, $this->customerModel]);
$collection = $this->getCustomerCollection(['getIterator']);
$collection
- ->expects(self::once())
+ ->expects($this->once())
->method('getIterator')
->willReturn($data);
- $result = $method->invokeArgs($command, [$collection]);
+ $result = $reflectionMethod->invokeArgs($command, [$collection]);
- self::assertEquals(1, $result);
+ $this->assertSame(1, $result);
}
public function testValidateInt()
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('The range should be numeric and above 0 e.g. 1');
- $refObject = new ReflectionObject($this->command);
- $method = $refObject->getMethod('validateInt');
- $method->setAccessible(true);
+ $reflectionObject = new ReflectionObject($this->command);
+ $reflectionMethod = $reflectionObject->getMethod('validateInt');
+ $reflectionMethod->setAccessible(true);
- $resultValid = $method->invokeArgs($this->command, ['5']);
- self::assertEquals(5, $resultValid);
- $method->invokeArgs($this->command, ['bad input']); // Exception!
+ $resultValid = $reflectionMethod->invokeArgs($this->command, ['5']);
+ $this->assertSame(5, $resultValid);
+ $reflectionMethod->invokeArgs($this->command, ['bad input']); // Exception!
}
}
diff --git a/tests/N98/Magento/Command/Customer/ListCommandTest.php b/tests/N98/Magento/Command/Customer/ListCommandTest.php
index a6f995944..a2593703a 100644
--- a/tests/N98/Magento/Command/Customer/ListCommandTest.php
+++ b/tests/N98/Magento/Command/Customer/ListCommandTest.php
@@ -1,21 +1,24 @@
getApplication();
$application->add(new ListCommand());
+
$command = $this->getApplication()->find('customer:list');
$commandTester = new CommandTester($command);
$commandTester->execute(['command' => $command->getName()]);
- self::assertMatchesRegularExpression('/email/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/email/', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Database/DumpCommandTest.php b/tests/N98/Magento/Command/Database/DumpCommandTest.php
index f53250280..8002853e3 100644
--- a/tests/N98/Magento/Command/Database/DumpCommandTest.php
+++ b/tests/N98/Magento/Command/Database/DumpCommandTest.php
@@ -1,5 +1,7 @@
isEnabled()) {
@@ -25,9 +27,8 @@ protected function getCommand()
$application = $this->getApplication();
$application->add($dumpCommand);
- $command = $this->getApplication()->find('db:dump');
- return $command;
+ return $this->getApplication()->find('db:dump');
}
public function testExecute()
@@ -39,43 +40,39 @@ public function testExecute()
['command' => $command->getName(), '--add-time' => true, '--only-command' => true, '--force' => true, '--compression' => 'gz'],
);
- self::assertMatchesRegularExpression('/mysqldump/', $commandTester->getDisplay());
- self::assertMatchesRegularExpression('/\.sql/', $commandTester->getDisplay());
- self::assertStringContainsString('.sql.gz', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/mysqldump/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/\.sql/', $commandTester->getDisplay());
+ $this->assertStringContainsString('.sql.gz', $commandTester->getDisplay());
}
/**
* @see filenamePatterns
*/
- public function provideFilenamePatternsAndOptions()
+ public function provideFilenamePatternsAndOptions(): \Iterator
{
- return [
- # testAddTimeAutogenerated
- ['/^.*[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{6}\.sql$/', []],
- # testAddTimePrefixAutogenerated
- ['/^[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{6}.*\.sql$/', ['--add-time' => 'prefix']],
- # testAddTimeFilenameSpecified
- ['/^.*[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{6}\.sql.gz$/', ['--compression' => 'gzip']],
- # testAddTimeFilenameSpecified
- ['/^foo_[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{6}\.sql$/', ['filename' => 'foo.sql']],
- # testAddTimePrefixFilenameSpecified
- ['/^[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{6}_foo\.sql$/', ['filename' => 'foo.sql', '--add-time' => 'prefix']],
- # testAddTimeOffFilenameSpecified
- ['/^foo.sql$/', ['filename' => 'foo.sql', '--add-time' => 'no']],
- # testAddTimeFilenameSpecifiedRelative
- ['/^..\/foo_[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{6}\.sql$/', ['filename' => '../foo.sql']],
- ];
+ # testAddTimeAutogenerated
+ yield ['/^.*\d{4}-\d{2}-\d{2}_\d{6}\.sql$/', []];
+ # testAddTimePrefixAutogenerated
+ yield ['/^\d{4}-\d{2}-\d{2}_\d{6}.*\.sql$/', ['--add-time' => 'prefix']];
+ # testAddTimeFilenameSpecified
+ yield ['/^.*\d{4}-\d{2}-\d{2}_\d{6}\.sql.gz$/', ['--compression' => 'gzip']];
+ # testAddTimeFilenameSpecified
+ yield ['/^foo_\d{4}-\d{2}-\d{2}_\d{6}\.sql$/', ['filename' => 'foo.sql']];
+ # testAddTimePrefixFilenameSpecified
+ yield ['/^\d{4}-\d{2}-\d{2}_\d{6}_foo\.sql$/', ['filename' => 'foo.sql', '--add-time' => 'prefix']];
+ # testAddTimeOffFilenameSpecified
+ yield ['/^foo.sql$/', ['filename' => 'foo.sql', '--add-time' => 'no']];
+ # testAddTimeFilenameSpecifiedRelative
+ yield ['/^..\/foo_\d{4}-\d{2}-\d{2}_\d{6}\.sql$/', ['filename' => '../foo.sql']];
}
/**
- * @test
* @dataProvider provideFilenamePatternsAndOptions
*
* @param string $regex
- * @param array $options
* @return void
*/
- public function filenamePatterns($regex, array $options)
+ public function testFilenamePatterns($regex, array $options)
{
$command = $this->getCommand();
@@ -100,13 +97,13 @@ public function testWithStripOption()
$dbConfig = $this->getDatabaseConnection()->getConfig();
$db = $dbConfig['dbname'];
- self::assertMatchesRegularExpression("/--ignore-table=$db.customer_entity/", $commandTester->getDisplay());
- self::assertMatchesRegularExpression("/--ignore-table=$db.customer_address_entity/", $commandTester->getDisplay());
- self::assertMatchesRegularExpression("/--ignore-table=$db.sales_flat_order/", $commandTester->getDisplay());
- self::assertMatchesRegularExpression("/--ignore-table=$db.sales_flat_order_item/", $commandTester->getDisplay());
- self::assertMatchesRegularExpression("/--ignore-table=$db.sales_flat_order_item/", $commandTester->getDisplay());
- self::assertStringNotContainsString('not_existing_table_1', $commandTester->getDisplay());
- self::assertStringContainsString('.sql.gz', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression(sprintf('/--ignore-table=%s.customer_entity/', $db), $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression(sprintf('/--ignore-table=%s.customer_address_entity/', $db), $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression(sprintf('/--ignore-table=%s.sales_flat_order/', $db), $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression(sprintf('/--ignore-table=%s.sales_flat_order_item/', $db), $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression(sprintf('/--ignore-table=%s.sales_flat_order_item/', $db), $commandTester->getDisplay());
+ $this->assertStringNotContainsString('not_existing_table_1', $commandTester->getDisplay());
+ $this->assertStringContainsString('.sql.gz', $commandTester->getDisplay());
/**
* Uncompressed
@@ -115,7 +112,7 @@ public function testWithStripOption()
$commandTester->execute(
['command' => $command->getName(), '--add-time' => true, '--only-command' => true, '--force' => true, '--strip' => '@development'],
);
- self::assertStringNotContainsString('.sql.gz', $commandTester->getDisplay());
+ $this->assertStringNotContainsString('.sql.gz', $commandTester->getDisplay());
}
public function testWithIncludeExcludeOptions()
@@ -132,7 +129,7 @@ public function testWithIncludeExcludeOptions()
$commandTester->execute(
['command' => $command->getName(), '--add-time' => true, '--only-command' => true, '--force' => true, '--exclude' => 'core_config_data', '--compression' => 'gzip'],
);
- self::assertMatchesRegularExpression("/--ignore-table=$db\.core_config_data/", $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression(sprintf('/--ignore-table=%s\.core_config_data/', $db), $commandTester->getDisplay());
/**
* Include
@@ -141,8 +138,8 @@ public function testWithIncludeExcludeOptions()
$commandTester->execute(
['command' => $command->getName(), '--add-time' => true, '--only-command' => true, '--force' => true, '--include' => 'core_config_data', '--compression' => 'gzip'],
);
- self::assertDoesNotMatchRegularExpression("/--ignore-table=$db\.core_config_data/", $commandTester->getDisplay());
- self::assertMatchesRegularExpression("/--ignore-table=$db\.catalog_product_entity/", $commandTester->getDisplay());
+ $this->assertDoesNotMatchRegularExpression(sprintf('/--ignore-table=%s\.core_config_data/', $db), $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression(sprintf('/--ignore-table=%s\.catalog_product_entity/', $db), $commandTester->getDisplay());
}
public function testIncludeExcludeMutualExclusivity()
@@ -161,16 +158,16 @@ public function testIncludeExcludeMutualExclusivity()
}
/**
- * @test
* @link https://github.com/netz98/n98-magerun2/issues/200
*/
- public function realDump()
+ public function testRealDump()
{
$dumpFile = new SplFileInfo($this->getTestMagentoRoot() . '/test-dump.sql');
if ($dumpFile->isReadable()) {
- self::assertTrue(unlink($dumpFile), 'Precondition to unlink that the file does not exists');
+ $this->assertTrue(unlink((string) $dumpFile), 'Precondition to unlink that the file does not exists');
}
- self::assertIsNotReadable((string) $dumpFile, 'Precondition that the file does not exists');
+
+ $this->assertIsNotReadable((string) $dumpFile, 'Precondition that the file does not exists');
$command = $this->getCommand();
$commandTester = new CommandTester($command);
@@ -178,8 +175,8 @@ public function realDump()
['command' => $command->getName(), '--strip' => '@stripped', 'filename' => $dumpFile],
);
- self::assertTrue($dumpFile->isReadable(), 'File was created');
+ $this->assertTrue($dumpFile->isReadable(), 'File was created');
// dump should be larger than quarter a megabyte
- self::assertGreaterThan(250000, $dumpFile->getSize());
+ $this->assertGreaterThan(250000, $dumpFile->getSize());
}
}
diff --git a/tests/N98/Magento/Command/Database/InfoCommandTest.php b/tests/N98/Magento/Command/Database/InfoCommandTest.php
index cc9d86f2b..cf6945742 100644
--- a/tests/N98/Magento/Command/Database/InfoCommandTest.php
+++ b/tests/N98/Magento/Command/Database/InfoCommandTest.php
@@ -1,28 +1,32 @@
getApplication();
$application->add(new InfoCommand());
+
$command = $this->getApplication()->find('db:info');
$commandTester = new CommandTester($command);
$commandTester->execute(['command' => $command->getName()]);
- self::assertMatchesRegularExpression('/PDO-Connection-String/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/PDO-Connection-String/', $commandTester->getDisplay());
}
public function testExecuteWithSettingArgument()
{
$application = $this->getApplication();
$application->add(new InfoCommand());
+
$command = $this->getApplication()->find('db:info');
$commandTester = new CommandTester($command);
@@ -30,7 +34,7 @@ public function testExecuteWithSettingArgument()
['command' => $command->getName(), 'setting' => 'MySQL-Cli-String'],
);
- self::assertDoesNotMatchRegularExpression('/MySQL-Cli-String/', $commandTester->getDisplay());
- self::assertStringContainsString('mysql -h', $commandTester->getDisplay());
+ $this->assertDoesNotMatchRegularExpression('/MySQL-Cli-String/', $commandTester->getDisplay());
+ $this->assertStringContainsString('mysql -h', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Database/Maintain/CheckTablesCommandTest.php b/tests/N98/Magento/Command/Database/Maintain/CheckTablesCommandTest.php
index be68304b4..7d3261eef 100644
--- a/tests/N98/Magento/Command/Database/Maintain/CheckTablesCommandTest.php
+++ b/tests/N98/Magento/Command/Database/Maintain/CheckTablesCommandTest.php
@@ -1,5 +1,7 @@
execute(
['command' => $command->getName(), '--format' => 'csv', '--type' => 'quick', '--table' => 'catalogsearch_*'],
);
- self::assertStringContainsString('catalogsearch_fulltext,check,quick,OK', $commandTester->getDisplay());
+ $this->assertStringContainsString('catalogsearch_fulltext,check,quick,OK', $commandTester->getDisplay());
$timeRegex = '"\s+[0-9]+\srows","[0-9\.]+\ssecs"';
- self::assertMatchesRegularExpression(
- '~catalogsearch_query,"ENGINE InnoDB",' . $timeRegex . '~',
- $commandTester->getDisplay(),
- );
- self::assertMatchesRegularExpression(
- '~catalogsearch_result,"ENGINE InnoDB",' . $timeRegex . '~',
- $commandTester->getDisplay(),
- );
+ $this->assertMatchesRegularExpression('~catalogsearch_query,"ENGINE InnoDB",' . $timeRegex . '~', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('~catalogsearch_result,"ENGINE InnoDB",' . $timeRegex . '~', $commandTester->getDisplay());
}
/**
* @return Command
*/
- protected function getCommand()
+ private function getCommand()
{
$application = $this->getApplication();
$application->add(new CheckTablesCommand());
- $command = $this->getApplication()->find('db:maintain:check-tables');
- return $command;
+ return $this->getApplication()->find('db:maintain:check-tables');
}
}
diff --git a/tests/N98/Magento/Command/Database/QueryCommandTest.php b/tests/N98/Magento/Command/Database/QueryCommandTest.php
index a133c1356..42cb19517 100644
--- a/tests/N98/Magento/Command/Database/QueryCommandTest.php
+++ b/tests/N98/Magento/Command/Database/QueryCommandTest.php
@@ -1,16 +1,19 @@
getApplication();
$application->add(new QueryCommand());
+
$command = $this->getApplication()->find('db:query');
$commandTester = new CommandTester($command);
@@ -18,8 +21,8 @@ public function testExecute()
['command' => $command->getName(), 'query' => 'SHOW TABLES;'],
);
- self::assertStringContainsString('admin_user', $commandTester->getDisplay());
- self::assertStringContainsString('catalog_product_entity', $commandTester->getDisplay());
- self::assertStringContainsString('wishlist', $commandTester->getDisplay());
+ $this->assertStringContainsString('admin_user', $commandTester->getDisplay());
+ $this->assertStringContainsString('catalog_product_entity', $commandTester->getDisplay());
+ $this->assertStringContainsString('wishlist', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Database/StatusCommandTest.php b/tests/N98/Magento/Command/Database/StatusCommandTest.php
index 238767888..488780902 100644
--- a/tests/N98/Magento/Command/Database/StatusCommandTest.php
+++ b/tests/N98/Magento/Command/Database/StatusCommandTest.php
@@ -1,21 +1,22 @@
getApplication();
$application->add(new StatusCommand());
+
$command = $this->getApplication()->find('db:status');
$commandTester = new CommandTester($command);
@@ -30,10 +31,10 @@ public function testExecute()
$commandTester = $this->getCommand(['--format' => 'csv']);
$display = $commandTester->getDisplay();
- self::assertStringContainsString('Threads_connected', $display);
- self::assertStringContainsString('Innodb_buffer_pool_wait_free', $display);
- self::assertStringContainsString('InnoDB Buffer Pool hit', $display);
- self::assertStringContainsString('Full table scans', $display);
+ $this->assertStringContainsString('Threads_connected', $display);
+ $this->assertStringContainsString('Innodb_buffer_pool_wait_free', $display);
+ $this->assertStringContainsString('InnoDB Buffer Pool hit', $display);
+ $this->assertStringContainsString('Full table scans', $display);
}
public function testSearch()
@@ -42,19 +43,16 @@ public function testSearch()
$display = $commandTester->getDisplay();
- self::assertStringContainsString('Innodb_buffer_pool_read_ahead_rnd', $display);
- self::assertStringContainsString('Innodb_buffer_pool_wait_free', $display);
- self::assertStringContainsString('InnoDB Buffer Pool hit', $display);
- self::assertStringContainsString('Innodb_dblwr_pages_written', $display);
- self::assertStringContainsString('Innodb_os_log_written', $display);
+ $this->assertStringContainsString('Innodb_buffer_pool_read_ahead_rnd', $display);
+ $this->assertStringContainsString('Innodb_buffer_pool_wait_free', $display);
+ $this->assertStringContainsString('InnoDB Buffer Pool hit', $display);
+ $this->assertStringContainsString('Innodb_dblwr_pages_written', $display);
+ $this->assertStringContainsString('Innodb_os_log_written', $display);
}
public function testRounding()
{
$commandTester = $this->getCommand(['--format' => 'csv', '--rounding' => '2', 'search' => '%size%']);
- self::assertMatchesRegularExpression(
- '~Innodb_page_size,[0-9\.]+K,~',
- $commandTester->getDisplay(),
- );
+ $this->assertMatchesRegularExpression('~Innodb_page_size,[0-9\.]+K,~', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Database/VariablesCommandTest.php b/tests/N98/Magento/Command/Database/VariablesCommandTest.php
index d4ee9a3d8..83d6878bb 100644
--- a/tests/N98/Magento/Command/Database/VariablesCommandTest.php
+++ b/tests/N98/Magento/Command/Database/VariablesCommandTest.php
@@ -1,12 +1,14 @@
statusCommand = new StatusCommand();
$application = $this->getApplication();
$application->add($this->statusCommand);
+
$command = $this->getApplication()->find('db:variables');
$commandTester = new CommandTester($command);
@@ -47,10 +48,10 @@ public function testExecute()
$commandTester = $this->getCommand(['--format' => 'csv']);
$display = $commandTester->getDisplay();
- self::assertStringContainsString('have_query_cache', $display);
- self::assertStringContainsString('innodb_log_buffer_size', $display);
- self::assertStringContainsString('max_connections', $display);
- self::assertStringContainsString('thread_cache_size', $display);
+ $this->assertStringContainsString('have_query_cache', $display);
+ $this->assertStringContainsString('innodb_log_buffer_size', $display);
+ $this->assertStringContainsString('max_connections', $display);
+ $this->assertStringContainsString('thread_cache_size', $display);
}
/**
@@ -60,17 +61,18 @@ public function testSearch()
{
$commandTester = $this->getCommand(['--format' => 'csv', 'search' => 'Innodb%']);
- $dbHelper = $this->getDatabaseHelper();
+ $databaseHelper = $this->getDatabaseHelper();
$display = $commandTester->getDisplay();
- self::assertStringContainsString('innodb_concurrency_tickets', $display);
+ $this->assertStringContainsString('innodb_concurrency_tickets', $display);
// innodb_force_load_corrupted Introduced in 5.6.3
- if (-1 < version_compare($dbHelper->getMysqlVariable('version'), '5.6.3')) {
- self::assertStringContainsString('innodb_force_load_corrupted', $display);
+ if (-1 < version_compare($databaseHelper->getMysqlVariable('version'), '5.6.3')) {
+ $this->assertStringContainsString('innodb_force_load_corrupted', $display);
}
- self::assertStringContainsString('innodb_log_file_size', $display);
- self::assertMatchesRegularExpression('~innodb_(?:file|read)_io_threads~', $display);
+
+ $this->assertStringContainsString('innodb_log_file_size', $display);
+ $this->assertMatchesRegularExpression('~innodb_(?:file|read)_io_threads~', $display);
}
/**
@@ -80,15 +82,15 @@ public function testRounding()
{
$commandTester = $this->getCommand(['--format' => 'csv', '--rounding' => '2', 'search' => '%size%']);
- $dbHelper = $this->getDatabaseHelper();
+ $databaseHelper = $this->getDatabaseHelper();
$display = $commandTester->getDisplay();
- self::assertMatchesRegularExpression('~myisam_max_sort_file_size,[0-9\.]+[A-Z]~', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('~myisam_max_sort_file_size,[0-9\.]+[A-Z]~', $commandTester->getDisplay());
// max_binlog_stmt_cache_size Introduced in 5.5.9
- if (-1 < version_compare($dbHelper->getMysqlVariable('version'), '5.5.9')) {
- self::assertMatchesRegularExpression('~max_binlog_stmt_cache_size,[0-9\.]+[A-Z]~', $display);
+ if (-1 < version_compare($databaseHelper->getMysqlVariable('version'), '5.5.9')) {
+ $this->assertMatchesRegularExpression('~max_binlog_stmt_cache_size,[0-9\.]+[A-Z]~', $display);
}
}
}
diff --git a/tests/N98/Magento/Command/Design/DemoNoticeCommandTest.php b/tests/N98/Magento/Command/Design/DemoNoticeCommandTest.php
index 09b59e61d..629e04fa9 100644
--- a/tests/N98/Magento/Command/Design/DemoNoticeCommandTest.php
+++ b/tests/N98/Magento/Command/Design/DemoNoticeCommandTest.php
@@ -1,30 +1,33 @@
getApplication();
$application->add(new DemoNoticeCommand());
$application->setAutoExit(false);
+
$command = $this->getApplication()->find('design:demo-notice');
$commandTester = new CommandTester($command);
$commandTester->execute(
['command' => $command->getName(), 'store' => 'admin', '--on' => true],
);
- self::assertMatchesRegularExpression('/Demo Notice enabled/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/Demo Notice enabled/', $commandTester->getDisplay());
$commandTester = new CommandTester($command);
$commandTester->execute(
['command' => $command->getName(), 'store' => 'admin', '--off' => true],
);
- self::assertMatchesRegularExpression('/Demo Notice disabled/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/Demo Notice disabled/', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Developer/ClassLookupCommandTest.php b/tests/N98/Magento/Command/Developer/ClassLookupCommandTest.php
index 0b1f83645..b7423b5b2 100644
--- a/tests/N98/Magento/Command/Developer/ClassLookupCommandTest.php
+++ b/tests/N98/Magento/Command/Developer/ClassLookupCommandTest.php
@@ -1,11 +1,13 @@
getApplication();
$application->add(new ClassLookupCommand());
+
$command = $this->getApplication()->find('dev:class:lookup');
$commandTester = new CommandTester($command);
@@ -29,9 +32,9 @@ public function testExecute($type, $name, $expected, $exists)
);
$output = $commandTester->getDisplay();
- self::assertMatchesRegularExpression(sprintf('/%s/', $expected), $output);
+ $this->assertMatchesRegularExpression(sprintf('/%s/', $expected), $output);
- $existsAssertion = (!$exists) ? 'assertMatchesRegularExpression' : 'assertDoesNotMatchRegularExpression';
+ $existsAssertion = ($exists) ? 'assertDoesNotMatchRegularExpression' : 'assertMatchesRegularExpression';
$this->{$existsAssertion}(sprintf('/%s/', 'does not exist'), $output);
}
@@ -41,6 +44,13 @@ public function testExecute($type, $name, $expected, $exists)
*/
public function classLookupProvider()
{
- return [['type' => 'model', 'name' => 'catalog/product', 'expected' => 'Mage_Catalog_Model_Product', 'exists' => true], ['type' => 'model', 'name' => 'catalog/nothing_to_see_here', 'expected' => 'Mage_Catalog_Model_Nothing_To_See_Here', 'exists' => false], ['type' => 'helper', 'name' => 'checkout/cart', 'expected' => 'Mage_Checkout_Helper_Cart', 'exists' => true], ['type' => 'helper', 'name' => 'checkout/stolen_creditcards', 'expected' => 'Mage_Checkout_Helper_Stolen_Creditcards', 'exists' => false], ['type' => 'block', 'name' => 'customer/account_dashboard', 'expected' => 'Mage_Customer_Block_Account_Dashboard', 'exists' => true], ['type' => 'block', 'name' => 'customer/my_code_snippets', 'expected' => 'Mage_Customer_Block_My_Code_Snippets', 'exists' => false]];
+ return [
+ ['type' => 'model', 'name' => 'catalog/product', 'expected' => 'Mage_Catalog_Model_Product', 'exists' => true],
+ ['type' => 'model', 'name' => 'catalog/nothing_to_see_here', 'expected' => 'Mage_Catalog_Model_Nothing_To_See_Here', 'exists' => false],
+ ['type' => 'helper', 'name' => 'checkout/cart', 'expected' => 'Mage_Checkout_Helper_Cart', 'exists' => true],
+ ['type' => 'helper', 'name' => 'checkout/stolen_creditcards', 'expected' => 'Mage_Checkout_Helper_Stolen_Creditcards', 'exists' => false],
+ ['type' => 'block', 'name' => 'customer/account_dashboard', 'expected' => 'Mage_Customer_Block_Account_Dashboard', 'exists' => true],
+ ['type' => 'block', 'name' => 'customer/my_code_snippets', 'expected' => 'Mage_Customer_Block_My_Code_Snippets', 'exists' => false],
+ ];
}
}
diff --git a/tests/N98/Magento/Command/Developer/Ide/PhpStorm/MetaCommandTest.php b/tests/N98/Magento/Command/Developer/Ide/PhpStorm/MetaCommandTest.php
index fd94555e6..8a0fc404d 100644
--- a/tests/N98/Magento/Command/Developer/Ide/PhpStorm/MetaCommandTest.php
+++ b/tests/N98/Magento/Command/Developer/Ide/PhpStorm/MetaCommandTest.php
@@ -1,16 +1,19 @@
getApplication();
$application->add(new MetaCommand());
+
$command = $this->getApplication()->find('dev:ide:phpstorm:meta');
$commandTester = new CommandTester($command);
@@ -20,22 +23,19 @@ public function testExecute()
$fileContent = $commandTester->getDisplay(true);
- self::assertStringContainsString('\'catalog\' => \Mage_Catalog_Helper_Data', $fileContent);
- self::assertStringContainsString('\'core/config\' => \Mage_Core_Model_Config', $fileContent);
+ $this->assertStringContainsString('\'catalog\' => \Mage_Catalog_Helper_Data', $fileContent);
+ $this->assertStringContainsString('\'core/config\' => \Mage_Core_Model_Config', $fileContent);
if (class_exists('\Mage_Core_Model_Resource_Config')) { // since magento 1.7
- self::assertStringContainsString('\'core/config\' => \Mage_Core_Model_Resource_Config', $fileContent);
+ $this->assertStringContainsString('\'core/config\' => \Mage_Core_Model_Resource_Config', $fileContent);
}
- self::assertStringContainsString('\'wishlist\' => \Mage_Wishlist_Helper_Data', $fileContent);
+ $this->assertStringContainsString('\'wishlist\' => \Mage_Wishlist_Helper_Data', $fileContent);
if (class_exists('\Mage_Core_Model_Resource_Helper_Mysql4')) {
- self::assertStringContainsString('\'core\' => \Mage_Core_Model_Resource_Helper_Mysql4', $fileContent);
+ $this->assertStringContainsString('\'core\' => \Mage_Core_Model_Resource_Helper_Mysql4', $fileContent);
}
- self::assertStringNotContainsString(
- '\'payment/paygate_request\' => \Mage_Payment_Model_Paygate_Request',
- $fileContent,
- );
+ $this->assertStringNotContainsString('\'payment/paygate_request\' => \Mage_Payment_Model_Paygate_Request', $fileContent);
}
}
diff --git a/tests/N98/Magento/Command/Developer/Log/LogCommand.php b/tests/N98/Magento/Command/Developer/Log/LogCommand.php
index 96ca77dbd..2d96d114d 100644
--- a/tests/N98/Magento/Command/Developer/Log/LogCommand.php
+++ b/tests/N98/Magento/Command/Developer/Log/LogCommand.php
@@ -1,5 +1,7 @@
getApplication();
$application->add(new LogCommand());
$application->setAutoExit(false);
+
$command = $this->getApplication()->find('dev:log');
$commandTester = new CommandTester($command);
diff --git a/tests/N98/Magento/Command/Developer/MergeCssCommandTest.php b/tests/N98/Magento/Command/Developer/MergeCssCommandTest.php
index ccc3e5a31..9db57a0fa 100644
--- a/tests/N98/Magento/Command/Developer/MergeCssCommandTest.php
+++ b/tests/N98/Magento/Command/Developer/MergeCssCommandTest.php
@@ -1,30 +1,33 @@
getApplication();
$application->add(new MergeCssCommand());
$application->setAutoExit(false);
+
$command = $this->getApplication()->find('dev:merge-css');
$commandTester = new CommandTester($command);
$commandTester->execute(
['command' => $command->getName(), '--on' => true, 'store' => 'admin'],
);
- self::assertMatchesRegularExpression('/CSS Merging enabled/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/CSS Merging enabled/', $commandTester->getDisplay());
$commandTester = new CommandTester($command);
$commandTester->execute(
['command' => $command->getName(), '--off' => true, 'store' => 'admin'],
);
- self::assertMatchesRegularExpression('/CSS Merging disabled/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/CSS Merging disabled/', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Developer/MergeJsCommandTest.php b/tests/N98/Magento/Command/Developer/MergeJsCommandTest.php
index d71a624cd..87add7a47 100644
--- a/tests/N98/Magento/Command/Developer/MergeJsCommandTest.php
+++ b/tests/N98/Magento/Command/Developer/MergeJsCommandTest.php
@@ -1,30 +1,33 @@
getApplication();
$application->add(new MergeJsCommand());
$application->setAutoExit(false);
+
$command = $this->getApplication()->find('dev:merge-js');
$commandTester = new CommandTester($command);
$commandTester->execute(
['command' => $command->getName(), '--on' => true, 'store' => 'admin'],
);
- self::assertMatchesRegularExpression('/JS Merging enabled/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/JS Merging enabled/', $commandTester->getDisplay());
$commandTester = new CommandTester($command);
$commandTester->execute(
['command' => $command->getName(), '--off' => true, 'store' => 'admin'],
);
- self::assertMatchesRegularExpression('/JS Merging disabled/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/JS Merging disabled/', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Developer/Module/CreateCommandTest.php b/tests/N98/Magento/Command/Developer/Module/CreateCommandTest.php
index 950a03c42..3eb6d2170 100644
--- a/tests/N98/Magento/Command/Developer/Module/CreateCommandTest.php
+++ b/tests/N98/Magento/Command/Developer/Module/CreateCommandTest.php
@@ -1,17 +1,20 @@
getApplication();
$application->add(new ListCommand());
+
$command = $this->getApplication()->find('dev:module:create');
$root = getcwd();
@@ -28,16 +31,16 @@ public function testExecute()
['command' => $command->getName(), '--add-all' => true, '--add-setup' => true, '--add-readme' => true, '--add-composer' => true, '--modman' => true, '--description' => 'Unit Test Description', '--author-name' => 'Unit Test', '--author-email' => 'n98-magerun@example.com', 'vendorNamespace' => 'N98Magerun', 'moduleName' => 'UnitTest'],
);
- self::assertFileExists($root . '/N98Magerun_UnitTest/composer.json');
- self::assertFileExists($root . '/N98Magerun_UnitTest/readme.md');
+ $this->assertFileExists($root . '/N98Magerun_UnitTest/composer.json');
+ $this->assertFileExists($root . '/N98Magerun_UnitTest/readme.md');
$moduleBaseFolder = $root . '/N98Magerun_UnitTest/src/app/code/local/N98Magerun/UnitTest/';
- self::assertFileExists($moduleBaseFolder . 'etc/config.xml');
- self::assertFileExists($moduleBaseFolder . 'controllers');
- self::assertFileExists($moduleBaseFolder . 'Block');
- self::assertFileExists($moduleBaseFolder . 'Model');
- self::assertFileExists($moduleBaseFolder . 'Helper');
- self::assertFileExists($moduleBaseFolder . 'data/n98magerun_unittest_setup');
- self::assertFileExists($moduleBaseFolder . 'sql/n98magerun_unittest_setup');
+ $this->assertFileExists($moduleBaseFolder . 'etc/config.xml');
+ $this->assertFileExists($moduleBaseFolder . 'controllers');
+ $this->assertFileExists($moduleBaseFolder . 'Block');
+ $this->assertFileExists($moduleBaseFolder . 'Model');
+ $this->assertFileExists($moduleBaseFolder . 'Helper');
+ $this->assertFileExists($moduleBaseFolder . 'data/n98magerun_unittest_setup');
+ $this->assertFileExists($moduleBaseFolder . 'sql/n98magerun_unittest_setup');
// delete old module
if (is_dir($root . '/N98Magerun_UnitTest')) {
diff --git a/tests/N98/Magento/Command/Developer/Module/Dependencies/FromCommandTest.php b/tests/N98/Magento/Command/Developer/Module/Dependencies/FromCommandTest.php
index 36788a55e..92bb3b4db 100644
--- a/tests/N98/Magento/Command/Developer/Module/Dependencies/FromCommandTest.php
+++ b/tests/N98/Magento/Command/Developer/Module/Dependencies/FromCommandTest.php
@@ -1,5 +1,7 @@
['$moduleName' => 'NotExistentModule', '$all' => 0, '$expectations' => ['Module NotExistentModule was not found'], '$notContains' => []], 'Not existing module, with --all' => ['$moduleName' => 'NotExistentModule', '$all' => 1, '$expectations' => ['Module NotExistentModule was not found'], '$notContains' => []], 'Not existing module, with -a' => ['$moduleName' => 'NotExistentModule', '$all' => 2, '$expectations' => ['Module NotExistentModule was not found'], '$notContains' => []], 'Mage_Admin module, no --all' => ['$moduleName' => 'Mage_Admin', '$all' => 0, '$expectations' => ['Mage_Adminhtml'], '$notContains' => ['Mage_AdminNotification']], 'Mage_Admin module, with --all' => ['$moduleName' => 'Mage_Admin', '$all' => 1, '$expectations' => ['Mage_AdminNotification', 'Mage_Adminhtml'], '$notContains' => ['Mage_Compiler', 'Mage_Customer']], 'Mage_Admin module, with -a' => ['$moduleName' => 'Mage_Admin', '$all' => 2, '$expectations' => ['Mage_AdminNotification', 'Mage_Adminhtml'], '$notContains' => ['Mage_Compiler', 'Mage_Customer']]];
+ yield 'Not existing module, no --all' => ['$moduleName' => 'NotExistentModule', '$all' => 0, '$expectations' => ['Module NotExistentModule was not found'], '$notContains' => []];
+ yield 'Not existing module, with --all' => ['$moduleName' => 'NotExistentModule', '$all' => 1, '$expectations' => ['Module NotExistentModule was not found'], '$notContains' => []];
+ yield 'Not existing module, with -a' => ['$moduleName' => 'NotExistentModule', '$all' => 2, '$expectations' => ['Module NotExistentModule was not found'], '$notContains' => []];
+ yield 'Mage_Admin module, no --all' => ['$moduleName' => 'Mage_Admin', '$all' => 0, '$expectations' => ['Mage_Adminhtml'], '$notContains' => ['Mage_AdminNotification']];
+ yield 'Mage_Admin module, with --all' => ['$moduleName' => 'Mage_Admin', '$all' => 1, '$expectations' => ['Mage_AdminNotification', 'Mage_Adminhtml'], '$notContains' => ['Mage_Compiler', 'Mage_Customer']];
+ yield 'Mage_Admin module, with -a' => ['$moduleName' => 'Mage_Admin', '$all' => 2, '$expectations' => ['Mage_AdminNotification', 'Mage_Adminhtml'], '$notContains' => ['Mage_Compiler', 'Mage_Customer']];
}
/**
* @dataProvider dataProviderTestExecute
* @param string $moduleName
* @param int $all
- * @param array $contains
- * @param array $notContains
*/
public function testExecute($moduleName, $all, array $contains, array $notContains)
{
$application = $this->getApplication();
$application->add(new FromCommand());
+
$command = $this->getApplication()->find('dev:module:dependencies:from');
$commandTester = new CommandTester($command);
@@ -45,11 +51,12 @@ public function testExecute($moduleName, $all, array $contains, array $notContai
}
$commandTester->execute($input);
- foreach ($contains as $expectation) {
- self::assertStringContainsString($expectation, $commandTester->getDisplay());
+ foreach ($contains as $contain) {
+ $this->assertStringContainsString($contain, $commandTester->getDisplay());
}
- foreach ($notContains as $expectation) {
- self::assertStringNotContainsString($expectation, $commandTester->getDisplay());
+
+ foreach ($notContains as $notContain) {
+ $this->assertStringNotContainsString($notContain, $commandTester->getDisplay());
}
}
}
diff --git a/tests/N98/Magento/Command/Developer/Module/Dependencies/OnCommandTest.php b/tests/N98/Magento/Command/Developer/Module/Dependencies/OnCommandTest.php
index 953360d8c..4491e59b9 100644
--- a/tests/N98/Magento/Command/Developer/Module/Dependencies/OnCommandTest.php
+++ b/tests/N98/Magento/Command/Developer/Module/Dependencies/OnCommandTest.php
@@ -1,5 +1,7 @@
['$moduleName' => 'NotExistentModule', '$all' => 0, '$expectations' => ['Module NotExistentModule was not found'], '$notContains' => []], 'Not existing module, with --all' => ['$moduleName' => 'NotExistentModule', '$all' => 1, '$expectations' => ['Module NotExistentModule was not found'], '$notContains' => []], 'Not existing module, with -a' => ['$moduleName' => 'NotExistentModule', '$all' => 2, '$expectations' => ['Module NotExistentModule was not found'], '$notContains' => []], 'Mage_Core module, no --all' => ['$moduleName' => 'Mage_Core', '$all' => 0, '$expectations' => ["Module Mage_Core doesn't have dependencies"], '$notContains' => []], 'Mage_Core module, with --all' => ['$moduleName' => 'Mage_Core', '$all' => 1, '$expectations' => ["Module Mage_Core doesn't have dependencies"], '$notContains' => []], 'Mage_Core module, with -a' => ['$moduleName' => 'Mage_Core', '$all' => 2, '$expectations' => ["Module Mage_Core doesn't have dependencies"], '$notContains' => []], 'Mage_Customer module, no --all' => ['$moduleName' => 'Mage_Customer', '$all' => 0, '$expectations' => [
+ yield 'Not existing module, no --all' => ['$moduleName' => 'NotExistentModule', '$all' => 0, '$expectations' => ['Module NotExistentModule was not found'], '$notContains' => []];
+ yield 'Not existing module, with --all' => ['$moduleName' => 'NotExistentModule', '$all' => 1, '$expectations' => ['Module NotExistentModule was not found'], '$notContains' => []];
+ yield 'Not existing module, with -a' => ['$moduleName' => 'NotExistentModule', '$all' => 2, '$expectations' => ['Module NotExistentModule was not found'], '$notContains' => []];
+ yield 'Mage_Core module, no --all' => ['$moduleName' => 'Mage_Core', '$all' => 0, '$expectations' => ["Module Mage_Core doesn't have dependencies"], '$notContains' => []];
+ yield 'Mage_Core module, with --all' => ['$moduleName' => 'Mage_Core', '$all' => 1, '$expectations' => ["Module Mage_Core doesn't have dependencies"], '$notContains' => []];
+ yield 'Mage_Core module, with -a' => ['$moduleName' => 'Mage_Core', '$all' => 2, '$expectations' => ["Module Mage_Core doesn't have dependencies"], '$notContains' => []];
+ yield 'Mage_Customer module, no --all' => ['$moduleName' => 'Mage_Customer', '$all' => 0, '$expectations' => [
'Mage_Dataflow',
/*'Mage_Directory',*/
'Mage_Eav',
- ], '$notContains' => ['Mage_Core']], 'Mage_Customer module, with --all' => ['$moduleName' => 'Mage_Customer', '$all' => 1, '$expectations' => [
+ ], '$notContains' => ['Mage_Core']];
+ yield 'Mage_Customer module, with --all' => ['$moduleName' => 'Mage_Customer', '$all' => 1, '$expectations' => [
'Mage_Core',
'Mage_Dataflow',
/*'Mage_Directory',*/
'Mage_Eav',
- ], '$notContains' => []], 'Mage_Customer module, with -a' => ['$moduleName' => 'Mage_Customer', '$all' => 2, '$expectations' => [
+ ], '$notContains' => []];
+ yield 'Mage_Customer module, with -a' => ['$moduleName' => 'Mage_Customer', '$all' => 2, '$expectations' => [
'Mage_Core',
'Mage_Dataflow',
/*'Mage_Directory',*/
'Mage_Eav',
- ], '$notContains' => []]];
+ ], '$notContains' => []];
}
/**
* @dataProvider dataProviderTestExecute
* @param string $moduleName
* @param int $all
- * @param array $contains
- * @param array $notContains
*/
public function testExecute($moduleName, $all, array $contains, array $notContains)
{
$application = $this->getApplication();
$application->add(new OnCommand());
+
$command = $this->getApplication()->find('dev:module:dependencies:on');
$commandTester = new CommandTester($command);
@@ -59,11 +68,12 @@ public function testExecute($moduleName, $all, array $contains, array $notContai
}
$commandTester->execute($input);
- foreach ($contains as $expectation) {
- self::assertStringContainsString($expectation, $commandTester->getDisplay());
+ foreach ($contains as $contain) {
+ $this->assertStringContainsString($contain, $commandTester->getDisplay());
}
- foreach ($notContains as $expectation) {
- self::assertStringNotContainsString($expectation, $commandTester->getDisplay());
+
+ foreach ($notContains as $notContain) {
+ $this->assertStringNotContainsString($notContain, $commandTester->getDisplay());
}
}
}
diff --git a/tests/N98/Magento/Command/Developer/Module/ListCommandTest.php b/tests/N98/Magento/Command/Developer/Module/ListCommandTest.php
index 81c9c5a5f..04f5e7f3d 100644
--- a/tests/N98/Magento/Command/Developer/Module/ListCommandTest.php
+++ b/tests/N98/Magento/Command/Developer/Module/ListCommandTest.php
@@ -1,16 +1,19 @@
getApplication();
$application->add(new ListCommand());
+
$command = $this->getApplication()->find('dev:module:list');
$commandTester = new CommandTester($command);
@@ -18,6 +21,6 @@ public function testExecute()
['command' => $command->getName()],
);
- self::assertMatchesRegularExpression('/Mage_Core/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/Mage_Core/', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Developer/Module/Observer/ListCommandTest.php b/tests/N98/Magento/Command/Developer/Module/Observer/ListCommandTest.php
index ce8e9f684..7ed8c01e1 100644
--- a/tests/N98/Magento/Command/Developer/Module/Observer/ListCommandTest.php
+++ b/tests/N98/Magento/Command/Developer/Module/Observer/ListCommandTest.php
@@ -1,16 +1,19 @@
getApplication();
$application->add(new ListCommand());
+
$command = $this->getApplication()->find('dev:module:observer:list');
$commandTester = new CommandTester($command);
@@ -18,6 +21,6 @@ public function testExecute()
['command' => $command->getName(), 'type' => 'global'],
);
- self::assertStringContainsString('controller_front_init_routers', $commandTester->getDisplay());
+ $this->assertStringContainsString('controller_front_init_routers', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Developer/Module/Rewrite/ClassExistsCheckerTest.php b/tests/N98/Magento/Command/Developer/Module/Rewrite/ClassExistsCheckerTest.php
index 60dd57b67..34eeacc22 100644
--- a/tests/N98/Magento/Command/Developer/Module/Rewrite/ClassExistsCheckerTest.php
+++ b/tests/N98/Magento/Command/Developer/Module/Rewrite/ClassExistsCheckerTest.php
@@ -1,5 +1,7 @@
assertInstanceOf(__NAMESPACE__ . '\ClassExistsChecker', $checker);
$checker = ClassExistsChecker::create('Le_Foo_Le_Bar_Nexiste_Pas');
- self::assertInstanceOf(__NAMESPACE__ . '\ClassExistsChecker', $checker);
+ $this->assertInstanceOf(__NAMESPACE__ . '\ClassExistsChecker', $checker);
}
- /**
- * @test
- */
- public function existingClass()
+ public function testExistingClass()
{
- self::assertTrue(ClassExistsChecker::create(IteratorIterator::class)->existsExtendsSafe());
+ $this->assertTrue(ClassExistsChecker::create(IteratorIterator::class)->existsExtendsSafe());
}
- /**
- * @test
- */
- public function nonExistingClass()
+ public function testNonExistingClass()
{
- self::assertFalse(ClassExistsChecker::create('asdfu8jq23nklr08asASDF0oaosdufhoanl')->existsExtendsSafe());
+ $this->assertFalse(ClassExistsChecker::create('asdfu8jq23nklr08asASDF0oaosdufhoanl')->existsExtendsSafe());
}
- /**
- * @test
- */
- public function throwingAnExceptionWhileIncluding()
+ public function testThrowingAnExceptionWhileIncluding()
{
// similar to Varien_Autoload
$innerException = null;
- $autoload = $this->create(function ($className) use (&$innerException) {
+ $autoloadHandler = $this->create(function ($className) use (&$innerException): void {
$innerException = new BadMethodCallException('exception in include simulation for ' . $className);
throw $innerException;
});
@@ -77,54 +67,51 @@ public function throwingAnExceptionWhileIncluding()
try {
$className = 'Le_Foo_Le_Bar_Nexiste_Pas';
ClassExistsChecker::create($className)->existsExtendsSafe();
- $autoload->reset();
+ $autoloadHandler->reset();
self::fail('An expected Exception has not been thrown');
- } catch (Exception $ex) {
- $autoload->reset();
- self::assertInstanceOf(__NAMESPACE__ . '\ClassExistsThrownException', $ex);
- isset($innerException) && self::assertInstanceOf(get_class($innerException), $ex->getPrevious());
- self::assertSame($innerException, $ex->getPrevious());
+ } catch (Exception $exception) {
+ $autoloadHandler->reset();
+ $this->assertInstanceOf(__NAMESPACE__ . '\ClassExistsThrownException', $exception);
+ if (isset($innerException)) {
+ $this->assertInstanceOf(get_class($innerException), $exception->getPrevious());
+ }
+
+ $this->assertSame($innerException, $exception->getPrevious());
}
}
/**
- * @return array
+ * @return \Iterator<(int | string), mixed>
* @see preventingFatalOnNonExistingBaseClass
*/
- public function provideClassNames()
+ public function provideClassNames(): \Iterator
{
- return [
- ['Le_Foo_Le_Bar'],
- # extends from a non-existing file of that base-class
- ['Le_Foo_Le_Bar_R1'],
- ];
+ yield ['Le_Foo_Le_Bar'];
+ # extends from a non-existing file of that base-class
+ yield ['Le_Foo_Le_Bar_R1'];
}
/**
- * @test
* @dataProvider provideClassNames
* @param string $className
*/
- public function preventingFatalOnNonExistingBaseClass($className)
+ public function testPreventingFatalOnNonExistingBaseClass($className)
{
- $autoload = $this->create($this->getAutoloader());
+ $autoloadHandler = $this->create($this->getAutoloader());
$restore = $this->noErrorExceptions();
try {
$actual = ClassExistsChecker::create($className)->existsExtendsSafe();
$restore();
- $autoload->reset();
- self::assertFalse($actual);
- } catch (Exception $ex) {
+ $autoloadHandler->reset();
+ $this->assertFalse($actual);
+ } catch (Exception $exception) {
$restore();
- $autoload->reset();
+ $autoloadHandler->reset();
self::fail('An exception has been thrown');
}
}
- /**
- * @test
- */
- public function warningTriggeringExpectedBehaviour()
+ public function testWarningTriggeringExpectedBehaviour()
{
$this->markTestSkipped('Maybe not compatible with PHP 8.1 anymore. Has to be checked again.');
$undef_var = null;
@@ -136,43 +123,43 @@ public function warningTriggeringExpectedBehaviour()
$canary = error_get_last();
// precondition is that there was no error yet
- self::assertNotNull($canary, 'precondition not met');
+ $this->assertNotNull($canary, 'precondition not met');
// precondition of the error reporting level
$reporting = error_reporting();
// 22527 - E_ALL & ~E_DEPRECATED & ~E_STRICT (PHP 5.6)
// 32767 - E_ALL (Travis PHP 5.3, PHP 5.4)
$knownErrorLevels = ['E_ALL & ~E_DEPRECATED & ~E_STRICT (Deb Sury 5.6)' => 22527, 'E_ALL (Travis PHP 5.3, 5.4, 5.5)' => 32767];
- self::assertContains($reporting, $knownErrorLevels, "error reporting as of $reporting");
+ $this->assertContains($reporting, $knownErrorLevels, 'error reporting as of ' . $reporting);
// by default the class must be loaded with a different autoloader
- self::assertFalse(class_exists('Le_Foo_Le_Bar_Fine'));
+ $this->assertFalse(class_exists('Le_Foo_Le_Bar_Fine'));
// post-condition is that there was no error yet
- self::assertSame($canary, error_get_last());
+ $this->assertSame($canary, error_get_last());
// should not trigger an error if the class exists
- $autoload = $this->create($this->getAutoloader());
- self::assertTrue(class_exists('Le_Foo_Le_Bar_Fine'));
- self::assertSame($canary, error_get_last());
+ $this->create($this->getAutoloader());
+ $this->assertTrue(class_exists('Le_Foo_Le_Bar_Fine'));
+ $this->assertSame($canary, error_get_last());
// should trigger a warning if the class does not exists as file on disk per auto-loading
$restore = $this->noErrorExceptions();
$actual = class_exists('Le_Foo_Le_Bar_Nexiste_Pas');
$restore();
- self::assertFalse($actual);
+ $this->assertFalse($actual);
$lastError = error_get_last();
if ($canary === $lastError) {
self::markTestIncomplete('System does not triggers the expected warning on include');
}
- self::assertNotSame($canary, $lastError);
- self::assertArrayHasKey('type', $lastError);
- self::assertSame(2, $lastError['type']);
- self::assertArrayHasKey('message', $lastError);
+ $this->assertNotSame($canary, $lastError);
+ $this->assertArrayHasKey('type', $lastError);
+ $this->assertSame(2, $lastError['type']);
+ $this->assertArrayHasKey('message', $lastError);
$pattern = '~include\(\): Failed opening \'.*Rewrite/fixture/Le_Foo_Le_Bar_Nexiste_Pas\.php\' for inclusion ~';
- self::assertMatchesRegularExpression($pattern, $lastError['message']);
+ $this->assertMatchesRegularExpression($pattern, $lastError['message']);
}
/**
@@ -183,9 +170,10 @@ public function warningTriggeringExpectedBehaviour()
private function getAutoloader()
{
return function ($className) {
- if (!preg_match('~^(Le_Foo_Le_Bar)~', $className)) {
+ if (in_array(preg_match('~^(Le_Foo_Le_Bar)~', $className), [0, false], true)) {
return false;
}
+
$file = __DIR__ . '/fixture/' . $className . '.php';
return include $file;
@@ -207,7 +195,7 @@ private function noErrorExceptions($includeIni = true)
$logErrorsOrig = ini_get('log_errors');
$includeIni && ini_set('log_errors', false);
- $restore = function () use ($displayErrorsOrig, $logErrorsOrig) {
+ $restore = function () use ($displayErrorsOrig, $logErrorsOrig): void {
ini_set('display_errors', $displayErrorsOrig);
ini_set('log_errors', $logErrorsOrig);
};
@@ -222,14 +210,13 @@ private function noErrorExceptions($includeIni = true)
* after test is over
*
* @param $callback
- * @param null $flags
* @return AutoloadHandler
*/
private function create($callback, $flags = null)
{
- $handler = AutoloadHandler::create($callback, $flags);
- $this->cleanup[] = $handler->getCleanupCallback();
- return $handler;
+ $autoloadHandler = AutoloadHandler::create($callback, $flags);
+ $this->cleanup[] = $autoloadHandler->getCleanupCallback();
+ return $autoloadHandler;
}
private function cleanup()
diff --git a/tests/N98/Magento/Command/Developer/Module/Rewrite/ConflictsCommandTest.php b/tests/N98/Magento/Command/Developer/Module/Rewrite/ConflictsCommandTest.php
index 4e359714d..311a5a802 100644
--- a/tests/N98/Magento/Command/Developer/Module/Rewrite/ConflictsCommandTest.php
+++ b/tests/N98/Magento/Command/Developer/Module/Rewrite/ConflictsCommandTest.php
@@ -1,5 +1,7 @@
getApplication();
$application->add(new ConflictsCommand());
+
$command = $this->getApplication()->find('dev:module:rewrite:conflicts');
/**
@@ -26,7 +29,7 @@ public function testExecute()
$commandTester->execute(
['command' => $command->getName()],
);
- self::assertStringContainsString('No rewrite conflicts were found', $commandTester->getDisplay());
+ $this->assertStringContainsString('No rewrite conflicts were found', $commandTester->getDisplay());
/**
* Junit Log without any output
@@ -35,9 +38,9 @@ public function testExecute()
$result = $commandTester->execute(
['command' => $command->getName(), '--log-junit' => '_output.xml'],
);
- self::assertEquals(0, $result);
- self::assertEquals('', $commandTester->getDisplay());
- self::assertFileExists('_output.xml');
+ $this->assertSame(0, $result);
+ $this->assertSame('', $commandTester->getDisplay());
+ $this->assertFileExists('_output.xml');
@unlink('_output.xml');
}
@@ -47,11 +50,11 @@ public function testExecute()
public function testExecuteConflict()
{
$rewrites = ['blocks' => ['n98/mock_conflict' => ['Mage_Customer_Block_Account', 'Mage_Tag_Block_All']]];
- $command = $this->getCommandWithMockLoadRewrites($rewrites);
- $commandTester = new CommandTester($command);
- $result = $commandTester->execute(['command' => $command->getName()]);
- self::assertNotEquals(0, $result);
- self::assertStringContainsString('1 conflict was found', $commandTester->getDisplay());
+ $conflictsCommand = $this->getCommandWithMockLoadRewrites($rewrites);
+ $commandTester = new CommandTester($conflictsCommand);
+ $result = $commandTester->execute(['command' => $conflictsCommand->getName()]);
+ $this->assertNotSame(0, $result);
+ $this->assertStringContainsString('1 conflict was found', $commandTester->getDisplay());
}
/**
@@ -62,18 +65,17 @@ public function testExecuteConflict()
public function testExecuteConflictFalsePositive()
{
$rewrites = ['blocks' => ['n98/mock_conflict' => ['Mage_Catalog_Block_Product_Price', 'Mage_Bundle_Block_Catalog_Product_Price']]];
- $command = $this->getCommandWithMockLoadRewrites($rewrites);
- $commandTester = new CommandTester($command);
- $result = $commandTester->execute(['command' => $command->getName()]);
- self::assertEquals(0, $result);
- self::assertStringContainsString('No rewrite conflicts were found', $commandTester->getDisplay());
+ $conflictsCommand = $this->getCommandWithMockLoadRewrites($rewrites);
+ $commandTester = new CommandTester($conflictsCommand);
+ $result = $commandTester->execute(['command' => $conflictsCommand->getName()]);
+ $this->assertSame(0, $result);
+ $this->assertStringContainsString('No rewrite conflicts were found', $commandTester->getDisplay());
}
/**
* Mock the ConflictsCommand and change the return value of loadRewrites()
* to the given argument
*
- * @param array $return
* @return ConflictsCommand
*/
private function getCommandWithMockLoadRewrites(array $return)
diff --git a/tests/N98/Magento/Command/Developer/Module/Rewrite/fixture/Le_Foo_Le_Bar.php b/tests/N98/Magento/Command/Developer/Module/Rewrite/fixture/Le_Foo_Le_Bar.php
index c372c57e5..d8ddc95d2 100644
--- a/tests/N98/Magento/Command/Developer/Module/Rewrite/fixture/Le_Foo_Le_Bar.php
+++ b/tests/N98/Magento/Command/Developer/Module/Rewrite/fixture/Le_Foo_Le_Bar.php
@@ -1,5 +1,7 @@
markTestIncomplete('Find a replacement for missing setInputStream of question helper');
$application = $this->getApplication();
$application->add(new ListCommand());
+
$createCommand = $this->getApplication()->find('dev:module:create');
$updateCommand = $this->getApplication()->find('dev:module:update');
$updateCommand->setTestMode(true);
+
$root = getcwd();
$this->_deleteOldModule($root);
@@ -48,7 +52,7 @@ public function testExecute()
* @param $root
* @return bool|Filesystem
*/
- protected function _deleteOldModule($root)
+ private function _deleteOldModule($root)
{
// delete old module
$filesystem = false;
@@ -58,13 +62,14 @@ protected function _deleteOldModule($root)
$filesystem->recursiveRemoveDirectory($root . '/N98Magerun_UnitTest');
clearstatcache();
}
+
return $filesystem;
}
- protected function getInputStream($input)
+ private function getInputStream($input)
{
$stream = fopen('php://memory', 'rb+', false);
- fputs($stream, $input);
+ fwrite($stream, $input);
rewind($stream);
return $stream;
@@ -74,7 +79,7 @@ protected function getInputStream($input)
* @param $moduleBaseFolder
* @return string
*/
- protected function _getConfigXmlContents($moduleBaseFolder)
+ private function _getConfigXmlContents($moduleBaseFolder)
{
return file_get_contents($moduleBaseFolder . 'etc/config.xml');
}
@@ -84,16 +89,16 @@ protected function _getConfigXmlContents($moduleBaseFolder)
* @param $updateCommand
* @param $moduleBaseFolder
*/
- protected function _setVersionOptionTest($commandTester, $updateCommand, $moduleBaseFolder)
+ private function _setVersionOptionTest($commandTester, $updateCommand, $moduleBaseFolder)
{
$commandTester->execute(
['command' => $updateCommand->getName(), '--set-version' => true, 'vendorNamespace' => 'N98Magerun', 'moduleName' => 'UnitTest'],
);
- self::assertFileExists($moduleBaseFolder . 'etc/config.xml');
+ $this->assertFileExists($moduleBaseFolder . 'etc/config.xml');
$configXmlContent = $this->_getConfigXmlContents($moduleBaseFolder);
- self::assertStringContainsString('2.0.0', $configXmlContent);
+ $this->assertStringContainsString('2.0.0', $configXmlContent);
}
/**
@@ -103,7 +108,7 @@ protected function _setVersionOptionTest($commandTester, $updateCommand, $module
* @param $moduleBaseFolder
* @return string
*/
- protected function _addResourceModelOptionTest($dialog, $commandTester, $updateCommand, $moduleBaseFolder)
+ private function _addResourceModelOptionTest($dialog, $commandTester, $updateCommand, $moduleBaseFolder)
{
$dialog->setInputStream($this->getInputStream("y\nentity1\nentity1table\nentity2\nentity2table\n\n"));
$commandTester->execute(
@@ -111,14 +116,14 @@ protected function _addResourceModelOptionTest($dialog, $commandTester, $updateC
);
$configXmlContent = $this->_getConfigXmlContents($moduleBaseFolder);
- self::assertStringContainsString('', $configXmlContent);
- self::assertStringContainsString('n98magerun_unittest_resource_eav_mysql4', $configXmlContent);
- self::assertStringContainsString('N98Magerun_UnitTest_Model_Resource', $configXmlContent);
- self::assertStringContainsString('', $configXmlContent);
- self::assertStringContainsString('', $configXmlContent);
- self::assertStringContainsString('', $configXmlContent);
- self::assertStringContainsString('', $configXmlContent);
- self::assertStringContainsString('', $configXmlContent);
+ $this->assertStringContainsString('', $configXmlContent);
+ $this->assertStringContainsString('n98magerun_unittest_resource_eav_mysql4', $configXmlContent);
+ $this->assertStringContainsString('N98Magerun_UnitTest_Model_Resource', $configXmlContent);
+ $this->assertStringContainsString('', $configXmlContent);
+ $this->assertStringContainsString('', $configXmlContent);
+ $this->assertStringContainsString('', $configXmlContent);
+ $this->assertStringContainsString('', $configXmlContent);
+ $this->assertStringContainsString('', $configXmlContent);
}
/**
@@ -127,7 +132,7 @@ protected function _addResourceModelOptionTest($dialog, $commandTester, $updateC
* @param $updateCommand
* @param $moduleBaseFolder
*/
- protected function _addRoutersOptionTest($dialog, $commandTester, $updateCommand, $moduleBaseFolder)
+ private function _addRoutersOptionTest($dialog, $commandTester, $updateCommand, $moduleBaseFolder)
{
$dialog->setInputStream($this->getInputStream("admin\nstandard\nn98magerun\n"));
$commandTester->execute(
@@ -135,13 +140,13 @@ protected function _addRoutersOptionTest($dialog, $commandTester, $updateCommand
);
$configXmlContent = $this->_getConfigXmlContents($moduleBaseFolder);
- self::assertStringContainsString('', $configXmlContent);
- self::assertStringContainsString('', $configXmlContent);
- self::assertStringContainsString('', $configXmlContent);
- self::assertStringContainsString('', $configXmlContent);
- self::assertStringContainsString('', $configXmlContent);
- self::assertStringContainsString('n98magerun_unittest', $configXmlContent);
- self::assertStringContainsString('n98magerun', $configXmlContent);
+ $this->assertStringContainsString('', $configXmlContent);
+ $this->assertStringContainsString('', $configXmlContent);
+ $this->assertStringContainsString('', $configXmlContent);
+ $this->assertStringContainsString('', $configXmlContent);
+ $this->assertStringContainsString('', $configXmlContent);
+ $this->assertStringContainsString('n98magerun_unittest', $configXmlContent);
+ $this->assertStringContainsString('n98magerun', $configXmlContent);
}
/**
@@ -150,18 +155,18 @@ protected function _addRoutersOptionTest($dialog, $commandTester, $updateCommand
* @param $updateCommand
* @param $moduleBaseFolder
*/
- protected function _addEventsOptionTest($dialog, $commandTester, $updateCommand, $moduleBaseFolder)
+ private function _addEventsOptionTest($dialog, $commandTester, $updateCommand, $moduleBaseFolder)
{
$dialog->setInputStream($this->getInputStream("frontend\ncontroller_action_postdispatch\nn98mageruntest_observer\nn98magerun_unittest/observer\ncontrollerActionPostdispatch"));
$commandTester->execute(
['command' => $updateCommand->getName(), '--add-events' => true, 'vendorNamespace' => 'N98Magerun', 'moduleName' => 'UnitTest'],
);
$configXmlContent = $this->_getConfigXmlContents($moduleBaseFolder);
- self::assertStringContainsString('', $configXmlContent);
- self::assertStringContainsString('', $configXmlContent);
- self::assertStringContainsString('', $configXmlContent);
- self::assertStringContainsString('n98magerun_unittest/observer', $configXmlContent);
- self::assertStringContainsString('controllerActionPostdispatch', $configXmlContent);
+ $this->assertStringContainsString('', $configXmlContent);
+ $this->assertStringContainsString('', $configXmlContent);
+ $this->assertStringContainsString('', $configXmlContent);
+ $this->assertStringContainsString('n98magerun_unittest/observer', $configXmlContent);
+ $this->assertStringContainsString('controllerActionPostdispatch', $configXmlContent);
}
/**
@@ -170,18 +175,18 @@ protected function _addEventsOptionTest($dialog, $commandTester, $updateCommand,
* @param $updateCommand
* @param $moduleBaseFolder
*/
- protected function _addLayoutUpdatesOptionTest($dialog, $commandTester, $updateCommand, $moduleBaseFolder)
+ private function _addLayoutUpdatesOptionTest($dialog, $commandTester, $updateCommand, $moduleBaseFolder)
{
$dialog->setInputStream($this->getInputStream("adminhtml\nn98magerun_unittest\nn98magerun_unittest.xml"));
$commandTester->execute(
['command' => $updateCommand->getName(), '--add-layout-updates' => true, 'vendorNamespace' => 'N98Magerun', 'moduleName' => 'UnitTest'],
);
$configXmlContent = $this->_getConfigXmlContents($moduleBaseFolder);
- self::assertStringContainsString('', $configXmlContent);
- self::assertStringContainsString('', $configXmlContent);
- self::assertStringContainsString('', $configXmlContent);
- self::assertStringContainsString('', $configXmlContent);
- self::assertStringContainsString('n98magerun_unittest.xml', $configXmlContent);
+ $this->assertStringContainsString('', $configXmlContent);
+ $this->assertStringContainsString('', $configXmlContent);
+ $this->assertStringContainsString('', $configXmlContent);
+ $this->assertStringContainsString('', $configXmlContent);
+ $this->assertStringContainsString('n98magerun_unittest.xml', $configXmlContent);
}
/**
@@ -190,19 +195,19 @@ protected function _addLayoutUpdatesOptionTest($dialog, $commandTester, $updateC
* @param $updateCommand
* @param $moduleBaseFolder
*/
- protected function _addTranslateOptionTest($dialog, $commandTester, $updateCommand, $moduleBaseFolder)
+ private function _addTranslateOptionTest($dialog, $commandTester, $updateCommand, $moduleBaseFolder)
{
$dialog->setInputStream($this->getInputStream("adminhtml\nN98magerun_UnitTest.csv"));
$commandTester->execute(
['command' => $updateCommand->getName(), '--add-translate' => true, 'vendorNamespace' => 'N98Magerun', 'moduleName' => 'UnitTest'],
);
$configXmlContent = $this->_getConfigXmlContents($moduleBaseFolder);
- self::assertStringContainsString('', $configXmlContent);
- self::assertStringContainsString('', $configXmlContent);
- self::assertStringContainsString('', $configXmlContent);
- self::assertStringContainsString('', $configXmlContent);
- self::assertStringContainsString('', $configXmlContent);
- self::assertStringContainsString('N98magerun_UnitTest.csv', $configXmlContent);
+ $this->assertStringContainsString('', $configXmlContent);
+ $this->assertStringContainsString('', $configXmlContent);
+ $this->assertStringContainsString('', $configXmlContent);
+ $this->assertStringContainsString('', $configXmlContent);
+ $this->assertStringContainsString('', $configXmlContent);
+ $this->assertStringContainsString('N98magerun_UnitTest.csv', $configXmlContent);
}
/**
@@ -211,16 +216,16 @@ protected function _addTranslateOptionTest($dialog, $commandTester, $updateComma
* @param $updateCommand
* @param $moduleBaseFolder
*/
- protected function _addDefaultOptionTest($dialog, $commandTester, $updateCommand, $moduleBaseFolder)
+ private function _addDefaultOptionTest($dialog, $commandTester, $updateCommand, $moduleBaseFolder)
{
$dialog->setInputStream($this->getInputStream("sectiontest\ngrouptest\nfieldname\nfieldvalue"));
$commandTester->execute(
['command' => $updateCommand->getName(), '--add-default' => true, 'vendorNamespace' => 'N98Magerun', 'moduleName' => 'UnitTest'],
);
$configXmlContent = $this->_getConfigXmlContents($moduleBaseFolder);
- self::assertStringContainsString('', $configXmlContent);
- self::assertStringContainsString('', $configXmlContent);
- self::assertStringContainsString('', $configXmlContent);
- self::assertStringContainsString('fieldvalue', $configXmlContent);
+ $this->assertStringContainsString('', $configXmlContent);
+ $this->assertStringContainsString('', $configXmlContent);
+ $this->assertStringContainsString('', $configXmlContent);
+ $this->assertStringContainsString('fieldvalue', $configXmlContent);
}
}
diff --git a/tests/N98/Magento/Command/Developer/ProfilerCommandTest.php b/tests/N98/Magento/Command/Developer/ProfilerCommandTest.php
index 2397f3c7e..d8edad711 100644
--- a/tests/N98/Magento/Command/Developer/ProfilerCommandTest.php
+++ b/tests/N98/Magento/Command/Developer/ProfilerCommandTest.php
@@ -1,30 +1,33 @@
getApplication();
$application->add(new ProfilerCommand());
$application->setAutoExit(false);
+
$command = $this->getApplication()->find('dev:profiler');
$commandTester = new CommandTester($command);
$commandTester->execute(
['command' => $command->getName(), '--global' => true, '--on' => true],
);
- self::assertMatchesRegularExpression('/Profiler enabled/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/Profiler enabled/', $commandTester->getDisplay());
$commandTester = new CommandTester($command);
$commandTester->execute(
['command' => $command->getName(), '--global' => true, '--off' => true],
);
- self::assertMatchesRegularExpression('/Profiler disabled/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/Profiler disabled/', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Developer/Setup/Script/AttributeCommandTest.php b/tests/N98/Magento/Command/Developer/Setup/Script/AttributeCommandTest.php
index d1d23513f..735b75639 100644
--- a/tests/N98/Magento/Command/Developer/Setup/Script/AttributeCommandTest.php
+++ b/tests/N98/Magento/Command/Developer/Setup/Script/AttributeCommandTest.php
@@ -1,27 +1,27 @@
getApplication();
$application->add(new AttributeCommand());
$application->setAutoExit(false);
+
$command = $this->getApplication()->find('dev:setup:script:attribute');
$commandTester = new CommandTester($command);
$commandTester->execute(
['command' => $command->getName(), 'entityType' => 'catalog_product', 'attributeCode' => 'sku'],
);
- self::assertStringContainsString("'type' => 'static',", $commandTester->getDisplay());
- self::assertStringContainsString(
- "Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product', 'sku');",
- $commandTester->getDisplay(),
- );
+ $this->assertStringContainsString("'type' => 'static',", $commandTester->getDisplay());
+ $this->assertStringContainsString("Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product', 'sku');", $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Developer/SymlinksCommandTest.php b/tests/N98/Magento/Command/Developer/SymlinksCommandTest.php
index 508320115..30e5b94a8 100644
--- a/tests/N98/Magento/Command/Developer/SymlinksCommandTest.php
+++ b/tests/N98/Magento/Command/Developer/SymlinksCommandTest.php
@@ -1,30 +1,33 @@
getApplication();
$application->add(new SymlinksCommand());
$application->setAutoExit(false);
+
$command = $this->getApplication()->find('dev:symlinks');
$commandTester = new CommandTester($command);
$commandTester->execute(
['command' => $command->getName(), '--global' => true, '--on' => true],
);
- self::assertMatchesRegularExpression('/Symlinks allowed/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/Symlinks allowed/', $commandTester->getDisplay());
$commandTester = new CommandTester($command);
$commandTester->execute(
['command' => $command->getName(), '--global' => true, '--off' => true],
);
- self::assertMatchesRegularExpression('/Symlinks denied/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/Symlinks denied/', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Developer/TemplateHintsBlocksCommandTest.php b/tests/N98/Magento/Command/Developer/TemplateHintsBlocksCommandTest.php
index 19fe682ba..8748fbdd6 100644
--- a/tests/N98/Magento/Command/Developer/TemplateHintsBlocksCommandTest.php
+++ b/tests/N98/Magento/Command/Developer/TemplateHintsBlocksCommandTest.php
@@ -1,30 +1,33 @@
getApplication();
$application->add(new TemplateHintsBlocksCommand());
$application->setAutoExit(false);
+
$command = $this->getApplication()->find('dev:template-hints-blocks');
$commandTester = new CommandTester($command);
$commandTester->execute(
['command' => $command->getName(), '--on' => true, 'store' => 'admin'],
);
- self::assertMatchesRegularExpression('/Template Hints Blocks enabled/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/Template Hints Blocks enabled/', $commandTester->getDisplay());
$commandTester = new CommandTester($command);
$commandTester->execute(
['command' => $command->getName(), '--off' => true, 'store' => 'admin'],
);
- self::assertMatchesRegularExpression('/Template Hints Blocks disabled/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/Template Hints Blocks disabled/', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Developer/TemplateHintsCommandTest.php b/tests/N98/Magento/Command/Developer/TemplateHintsCommandTest.php
index b259dcec7..666e9e69e 100644
--- a/tests/N98/Magento/Command/Developer/TemplateHintsCommandTest.php
+++ b/tests/N98/Magento/Command/Developer/TemplateHintsCommandTest.php
@@ -1,30 +1,33 @@
getApplication();
$application->add(new TemplateHintsCommand());
$application->setAutoExit(false);
+
$command = $this->getApplication()->find('dev:template-hints');
$commandTester = new CommandTester($command);
$commandTester->execute(
['command' => $command->getName(), '--on' => true, 'store' => 'admin'],
);
- self::assertMatchesRegularExpression('/Template Hints enabled/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/Template Hints enabled/', $commandTester->getDisplay());
$commandTester = new CommandTester($command);
$commandTester->execute(
['command' => $command->getName(), '--off' => true, 'store' => 'admin'],
);
- self::assertMatchesRegularExpression('/Template Hints disabled/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/Template Hints disabled/', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Developer/Theme/DuplicatesCommandTest.php b/tests/N98/Magento/Command/Developer/Theme/DuplicatesCommandTest.php
index 91c61a015..6932f5a38 100644
--- a/tests/N98/Magento/Command/Developer/Theme/DuplicatesCommandTest.php
+++ b/tests/N98/Magento/Command/Developer/Theme/DuplicatesCommandTest.php
@@ -1,16 +1,19 @@
getApplication();
$application->add(new DuplicatesCommand());
+
$command = $this->getApplication()->find('dev:theme:duplicates');
$commandTester = new CommandTester($command);
@@ -22,7 +25,7 @@ public function testExecute()
$this->assertContainsPath('template/catalog/product/price.phtml', $display);
$this->assertContainsPath('layout/catalog.xml', $display);
- self::assertStringNotContainsString('No duplicates was found', $display);
+ $this->assertStringNotContainsString('No duplicates was found', $display);
}
/**
@@ -40,12 +43,13 @@ private function assertContainsPath($path, $haystack)
$pattern = '~';
while ($segment = array_shift($segments)) {
$pattern .= preg_quote($segment, '~');
- if ($segments) {
- $pattern .= $segmentCount++ ? '\\1' : $separator;
+ if ($segments !== []) {
+ $pattern .= $segmentCount++ !== 0 ? '\\1' : $separator;
}
}
+
$pattern .= '~';
- self::assertMatchesRegularExpression($pattern, $haystack);
+ $this->assertMatchesRegularExpression($pattern, $haystack);
}
}
diff --git a/tests/N98/Magento/Command/Developer/Theme/InfoCommandTest.php b/tests/N98/Magento/Command/Developer/Theme/InfoCommandTest.php
index 70fe8fea1..a44a8ec5a 100644
--- a/tests/N98/Magento/Command/Developer/Theme/InfoCommandTest.php
+++ b/tests/N98/Magento/Command/Developer/Theme/InfoCommandTest.php
@@ -1,16 +1,19 @@
getApplication();
$application->add(new ListCommand());
+
$command = $this->getApplication()->find('dev:theme:info');
$commandTester = new CommandTester($command);
@@ -18,7 +21,7 @@ public function testExecute()
['command' => $command->getName()],
);
- self::assertStringContainsString('base/default', $commandTester->getDisplay());
- self::assertStringContainsString('Design Package Name', $commandTester->getDisplay());
+ $this->assertStringContainsString('base/default', $commandTester->getDisplay());
+ $this->assertStringContainsString('Design Package Name', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Developer/Theme/ListCommandTest.php b/tests/N98/Magento/Command/Developer/Theme/ListCommandTest.php
index 15f429276..dc08839b9 100644
--- a/tests/N98/Magento/Command/Developer/Theme/ListCommandTest.php
+++ b/tests/N98/Magento/Command/Developer/Theme/ListCommandTest.php
@@ -1,16 +1,19 @@
getApplication();
$application->add(new ListCommand());
+
$command = $this->getApplication()->find('dev:theme:list');
$commandTester = new CommandTester($command);
@@ -18,6 +21,6 @@ public function testExecute()
['command' => $command->getName()],
);
- self::assertStringContainsString('base/default', $commandTester->getDisplay());
+ $this->assertStringContainsString('base/default', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Developer/Translate/InlineAdminCommandTest.php b/tests/N98/Magento/Command/Developer/Translate/InlineAdminCommandTest.php
index f223e40e2..edfeedf7e 100644
--- a/tests/N98/Magento/Command/Developer/Translate/InlineAdminCommandTest.php
+++ b/tests/N98/Magento/Command/Developer/Translate/InlineAdminCommandTest.php
@@ -1,30 +1,33 @@
getApplication();
$application->add(new InlineAdminCommand());
$application->setAutoExit(false);
+
$command = $this->getApplication()->find('dev:translate:admin');
$commandTester = new CommandTester($command);
$commandTester->execute(
['command' => $command->getName(), '--on' => true],
);
- self::assertStringContainsString('Inline Translation (Admin) enabled', $commandTester->getDisplay());
+ $this->assertStringContainsString('Inline Translation (Admin) enabled', $commandTester->getDisplay());
$commandTester = new CommandTester($command);
$commandTester->execute(
['command' => $command->getName(), '--off' => true],
);
- self::assertStringContainsString('Inline Translation (Admin) disabled', $commandTester->getDisplay());
+ $this->assertStringContainsString('Inline Translation (Admin) disabled', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Developer/Translate/InlineShopCommandTest.php b/tests/N98/Magento/Command/Developer/Translate/InlineShopCommandTest.php
index 6fdac6857..39d6932d0 100644
--- a/tests/N98/Magento/Command/Developer/Translate/InlineShopCommandTest.php
+++ b/tests/N98/Magento/Command/Developer/Translate/InlineShopCommandTest.php
@@ -1,30 +1,33 @@
getApplication();
$application->add(new InlineAdminCommand());
$application->setAutoExit(false);
+
$command = $this->getApplication()->find('dev:translate:shop');
$commandTester = new CommandTester($command);
$commandTester->execute(
['command' => $command->getName(), 'store' => 'admin', '--on' => true],
);
- self::assertStringContainsString('Inline Translation enabled', $commandTester->getDisplay());
+ $this->assertStringContainsString('Inline Translation enabled', $commandTester->getDisplay());
$commandTester = new CommandTester($command);
$commandTester->execute(
['command' => $command->getName(), 'store' => 'admin', '--off' => true],
);
- self::assertStringContainsString('Inline Translation disabled', $commandTester->getDisplay());
+ $this->assertStringContainsString('Inline Translation disabled', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Developer/Translate/SetCommandTest.php b/tests/N98/Magento/Command/Developer/Translate/SetCommandTest.php
index 655a21c67..63de0940a 100644
--- a/tests/N98/Magento/Command/Developer/Translate/SetCommandTest.php
+++ b/tests/N98/Magento/Command/Developer/Translate/SetCommandTest.php
@@ -1,23 +1,26 @@
getApplication();
$application->add(new InlineAdminCommand());
$application->setAutoExit(false);
+
$command = $this->getApplication()->find('dev:translate:set');
$commandTester = new CommandTester($command);
$commandTester->execute(
['command' => $command->getName(), 'string' => 'foo', 'translate' => 'bar', 'store' => 'admin'],
);
- self::assertStringContainsString('foo => bar', $commandTester->getDisplay());
+ $this->assertStringContainsString('foo => bar', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Eav/Attribute/Create/DummyCommandTest.php b/tests/N98/Magento/Command/Eav/Attribute/Create/DummyCommandTest.php
index 38c602c93..5995002e1 100644
--- a/tests/N98/Magento/Command/Eav/Attribute/Create/DummyCommandTest.php
+++ b/tests/N98/Magento/Command/Eav/Attribute/Create/DummyCommandTest.php
@@ -1,5 +1,7 @@
getApplication();
$application->add(new DummyCommand());
+
$command = $application->find('eav:attribute:create-dummy-values');
$commandTester = new CommandTester($command);
@@ -22,13 +25,14 @@ public function testExecute()
['command' => $command->getName(), 'locale' => 'en_US', 'attribute-id' => 92, 'values-type' => 'int', 'values-number' => 1],
);
- self::assertMatchesRegularExpression('/ATTRIBUTE VALUE: \'(.+)\' ADDED!/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression("/ATTRIBUTE VALUE: '(.+)' ADDED!/", $commandTester->getDisplay());
}
public function testmanageArguments()
{
$application = $this->getApplication();
$application->add(new DummyCommand());
+
$command = $application->find('eav:attribute:create-dummy-values');
$dialog = $this->getMockBuilder(QuestionHelper::class)
@@ -76,8 +80,8 @@ public function testmanageArguments()
);
$arguments = $commandTester->getInput()->getArguments();
- self::assertArrayHasKey('attribute-id', $arguments);
- self::assertArrayHasKey('values-type', $arguments);
- self::assertArrayHasKey('values-number', $arguments);
+ $this->assertArrayHasKey('attribute-id', $arguments);
+ $this->assertArrayHasKey('values-type', $arguments);
+ $this->assertArrayHasKey('values-number', $arguments);
}
}
diff --git a/tests/N98/Magento/Command/Eav/Attribute/ListCommandTest.php b/tests/N98/Magento/Command/Eav/Attribute/ListCommandTest.php
index 9d8da2482..966228d4a 100644
--- a/tests/N98/Magento/Command/Eav/Attribute/ListCommandTest.php
+++ b/tests/N98/Magento/Command/Eav/Attribute/ListCommandTest.php
@@ -1,16 +1,19 @@
getApplication();
$application->add(new ListCommand());
+
$command = $this->getApplication()->find('eav:attribute:list');
$commandTester = new CommandTester($command);
@@ -18,8 +21,8 @@ public function testExecute()
['command' => $command->getName(), '--filter-type' => 'catalog_product', '--add-source' => true],
);
- self::assertStringContainsString('eav/entity_attribute_source_boolean', $commandTester->getDisplay());
- self::assertStringContainsString('sku', $commandTester->getDisplay());
- self::assertStringContainsString('catalog_product', $commandTester->getDisplay());
+ $this->assertStringContainsString('eav/entity_attribute_source_boolean', $commandTester->getDisplay());
+ $this->assertStringContainsString('sku', $commandTester->getDisplay());
+ $this->assertStringContainsString('catalog_product', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Eav/Attribute/RemoveCommandTest.php b/tests/N98/Magento/Command/Eav/Attribute/RemoveCommandTest.php
index b058bf1c6..ffbc549db 100644
--- a/tests/N98/Magento/Command/Eav/Attribute/RemoveCommandTest.php
+++ b/tests/N98/Magento/Command/Eav/Attribute/RemoveCommandTest.php
@@ -1,5 +1,7 @@
*/
-class RemoveCommandTest extends TestCase
+final class RemoveCommandTest extends TestCase
{
public function testCommandThrowsExceptionIfInvalidEntityType()
{
$application = $this->getApplication();
$application->add(new RemoveCommand());
$application->setAutoExit(false);
+
$command = $this->getApplication()->find('eav:attribute:remove');
$this->expectException(InvalidArgumentException::class);
@@ -34,6 +37,7 @@ public function testCommandPrintsErrorIfAttributeNotExists()
$application = $this->getApplication();
$application->add(new RemoveCommand());
$application->setAutoExit(false);
+
$command = $this->getApplication()->find('eav:attribute:remove');
$commandTester = new CommandTester($command);
@@ -41,10 +45,7 @@ public function testCommandPrintsErrorIfAttributeNotExists()
['command' => $command->getName(), 'entityType' => 'catalog_product', 'attributeCode' => ['not_an_attribute']],
);
- self::assertStringContainsString(
- 'Attribute: "not_an_attribute" does not exist for entity type: "catalog_product"',
- $commandTester->getDisplay(),
- );
+ $this->assertStringContainsString('Attribute: "not_an_attribute" does not exist for entity type: "catalog_product"', $commandTester->getDisplay());
}
public function testAttributeIsSuccessfullyRemoved()
@@ -52,19 +53,20 @@ public function testAttributeIsSuccessfullyRemoved()
$application = $this->getApplication();
$application->add(new RemoveCommand());
$application->setAutoExit(false);
+
$command = $this->getApplication()->find('eav:attribute:remove');
$entityType = 'catalog_product';
$attributeCode = 'crazyCoolAttribute';
$this->createAttribute($entityType, $attributeCode, ['type' => 'text', 'input' => 'text', 'label' => 'Test Attribute']);
- self::assertTrue($this->attributeExists($entityType, $attributeCode));
+ $this->assertTrue($this->attributeExists($entityType, $attributeCode));
$commandTester = new CommandTester($command);
$commandTester->execute(
['command' => $command->getName(), 'entityType' => $entityType, 'attributeCode' => [$attributeCode]],
);
- self::assertFalse($this->attributeExists($entityType, $attributeCode));
+ $this->assertFalse($this->attributeExists($entityType, $attributeCode));
}
/**
@@ -76,18 +78,19 @@ public function testOrderAttributeIsSuccessfullyRemoved($entityTypeCode)
$application = $this->getApplication();
$application->add(new RemoveCommand());
$application->setAutoExit(false);
+
$command = $this->getApplication()->find('eav:attribute:remove');
$attributeCode = 'crazyCoolAttribute';
$this->createAttribute($entityTypeCode, $attributeCode, ['type' => 'text', 'input' => 'text', 'label' => 'Test Attribute']);
- self::assertTrue($this->attributeExists($entityTypeCode, $attributeCode));
+ $this->assertTrue($this->attributeExists($entityTypeCode, $attributeCode));
$commandTester = new CommandTester($command);
$commandTester->execute(
['command' => $command->getName(), 'entityType' => $entityTypeCode, 'attributeCode' => [$attributeCode]],
);
- self::assertFalse($this->attributeExists($entityTypeCode, $attributeCode));
+ $this->assertFalse($this->attributeExists($entityTypeCode, $attributeCode));
}
public function testCanRemoveMultipleAttributes()
@@ -95,6 +98,7 @@ public function testCanRemoveMultipleAttributes()
$application = $this->getApplication();
$application->add(new RemoveCommand());
$application->setAutoExit(false);
+
$command = $this->getApplication()->find('eav:attribute:remove');
$attributeCode1 = 'crazyCoolAttribute1';
@@ -103,25 +107,19 @@ public function testCanRemoveMultipleAttributes()
$this->createAttribute('catalog_product', $attributeCode2, ['type' => 'text', 'input' => 'text', 'label' => 'Test Attribute 2']);
- self::assertTrue($this->attributeExists('catalog_product', $attributeCode1));
- self::assertTrue($this->attributeExists('catalog_product', $attributeCode2));
+ $this->assertTrue($this->attributeExists('catalog_product', $attributeCode1));
+ $this->assertTrue($this->attributeExists('catalog_product', $attributeCode2));
$commandTester = new CommandTester($command);
$commandTester->execute(
['command' => $command->getName(), 'entityType' => 'catalog_product', 'attributeCode' => [$attributeCode1, $attributeCode2]],
);
- self::assertFalse($this->attributeExists('catalog_product', $attributeCode1));
- self::assertFalse($this->attributeExists('catalog_product', $attributeCode2));
+ $this->assertFalse($this->attributeExists('catalog_product', $attributeCode1));
+ $this->assertFalse($this->attributeExists('catalog_product', $attributeCode2));
- self::assertStringContainsString(
- 'Successfully removed attribute: "crazyCoolAttribute1" from entity type: "catalog_product"',
- $commandTester->getDisplay(),
- );
+ $this->assertStringContainsString('Successfully removed attribute: "crazyCoolAttribute1" from entity type: "catalog_product"', $commandTester->getDisplay());
- self::assertStringContainsString(
- 'Successfully removed attribute: "crazyCoolAttribute2" from entity type: "catalog_product"',
- $commandTester->getDisplay(),
- );
+ $this->assertStringContainsString('Successfully removed attribute: "crazyCoolAttribute2" from entity type: "catalog_product"', $commandTester->getDisplay());
}
public function testCanRemoveMultipleAttributesIfSomeNotExist()
@@ -129,39 +127,41 @@ public function testCanRemoveMultipleAttributesIfSomeNotExist()
$application = $this->getApplication();
$application->add(new RemoveCommand());
$application->setAutoExit(false);
+
$command = $this->getApplication()->find('eav:attribute:remove');
$attributeCode1 = 'crazyCoolAttribute1';
$attributeCode2 = 'crazyCoolAttribute2';
$this->createAttribute('catalog_product', $attributeCode1, ['type' => 'text', 'input' => 'text', 'label' => 'Test Attribute 1']);
- self::assertTrue($this->attributeExists('catalog_product', $attributeCode1));
- self::assertFalse($this->attributeExists('catalog_product', $attributeCode2));
+ $this->assertTrue($this->attributeExists('catalog_product', $attributeCode1));
+ $this->assertFalse($this->attributeExists('catalog_product', $attributeCode2));
$commandTester = new CommandTester($command);
$commandTester->execute(
['command' => $command->getName(), 'entityType' => 'catalog_product', 'attributeCode' => [$attributeCode1, $attributeCode2]],
);
- self::assertFalse($this->attributeExists('catalog_product', $attributeCode1));
- self::assertFalse($this->attributeExists('catalog_product', $attributeCode2));
+ $this->assertFalse($this->attributeExists('catalog_product', $attributeCode1));
+ $this->assertFalse($this->attributeExists('catalog_product', $attributeCode2));
- self::assertStringContainsString(
- 'Attribute: "crazyCoolAttribute2" does not exist for entity type: "catalog_product"',
- $commandTester->getDisplay(),
- );
+ $this->assertStringContainsString('Attribute: "crazyCoolAttribute2" does not exist for entity type: "catalog_product"', $commandTester->getDisplay());
- self::assertStringContainsString(
- 'Successfully removed attribute: "crazyCoolAttribute1" from entity type: "catalog_product"',
- $commandTester->getDisplay(),
- );
+ $this->assertStringContainsString('Successfully removed attribute: "crazyCoolAttribute1" from entity type: "catalog_product"', $commandTester->getDisplay());
}
/**
- * @return array
+ * @return \Iterator<(int | string), mixed>
*/
- public static function entityTypeProvider()
+ public static function entityTypeProvider(): \Iterator
{
- return [['catalog_category'], ['catalog_product'], ['creditmemo'], ['customer'], ['customer_address'], ['invoice'], ['order'], ['shipment']];
+ yield ['catalog_category'];
+ yield ['catalog_product'];
+ yield ['creditmemo'];
+ yield ['customer'];
+ yield ['customer_address'];
+ yield ['invoice'];
+ yield ['order'];
+ yield ['shipment'];
}
/**
@@ -169,7 +169,7 @@ public static function entityTypeProvider()
* @param string $attributeCode
* @param array $data
*/
- protected function createAttribute($entityType, $attributeCode, $data)
+ private function createAttribute($entityType, $attributeCode, $data)
{
$setup = Mage::getModel('eav/entity_setup', 'core_setup');
$setup->addAttribute($entityType, $attributeCode, $data);
@@ -187,7 +187,7 @@ protected function createAttribute($entityType, $attributeCode, $data)
* @param string $attributeCode
* @return bool
*/
- protected function attributeExists($entityType, $attributeCode)
+ private function attributeExists($entityType, $attributeCode)
{
$codes = Mage::getModel('eav/config')->getEntityAttributeCodes($entityType);
return in_array($attributeCode, $codes);
diff --git a/tests/N98/Magento/Command/Eav/Attribute/ViewCommandTest.php b/tests/N98/Magento/Command/Eav/Attribute/ViewCommandTest.php
index bccf9cd6c..c7320a339 100644
--- a/tests/N98/Magento/Command/Eav/Attribute/ViewCommandTest.php
+++ b/tests/N98/Magento/Command/Eav/Attribute/ViewCommandTest.php
@@ -1,16 +1,19 @@
getApplication();
$application->add(new ListCommand());
+
$command = $this->getApplication()->find('eav:attribute:view');
$commandTester = new CommandTester($command);
@@ -18,9 +21,9 @@ public function testExecute()
['command' => $command->getName(), 'entityType' => 'catalog_product', 'attributeCode' => 'sku'],
);
- self::assertStringContainsString('sku', $commandTester->getDisplay());
- self::assertStringContainsString('catalog_product_entity', $commandTester->getDisplay());
- self::assertStringContainsString('Backend-Type', $commandTester->getDisplay());
- self::assertStringContainsString('static', $commandTester->getDisplay());
+ $this->assertStringContainsString('sku', $commandTester->getDisplay());
+ $this->assertStringContainsString('catalog_product_entity', $commandTester->getDisplay());
+ $this->assertStringContainsString('Backend-Type', $commandTester->getDisplay());
+ $this->assertStringContainsString('static', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/HelpCommandTest.php b/tests/N98/Magento/Command/HelpCommandTest.php
index 9fe34aa77..092520151 100644
--- a/tests/N98/Magento/Command/HelpCommandTest.php
+++ b/tests/N98/Magento/Command/HelpCommandTest.php
@@ -1,10 +1,12 @@
'help'],
);
- self::assertStringContainsString('The help command displays help for a given command', $commandTester->getDisplay());
+ $this->assertStringContainsString('The help command displays help for a given command', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Indexer/ListCommandTest.php b/tests/N98/Magento/Command/Indexer/ListCommandTest.php
index 65ef34076..3808cf0f0 100644
--- a/tests/N98/Magento/Command/Indexer/ListCommandTest.php
+++ b/tests/N98/Magento/Command/Indexer/ListCommandTest.php
@@ -1,22 +1,25 @@
getApplication();
$application->add(new ListCommand());
+
$command = $this->getApplication()->find('index:list');
$commandTester = new CommandTester($command);
$commandTester->execute(['command' => $command->getName()]);
// check if i.e. at least one index is listed
- self::assertMatchesRegularExpression('/catalog_product_flat/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/catalog_product_flat/', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Indexer/ReindexAllCommandTest.php b/tests/N98/Magento/Command/Indexer/ReindexAllCommandTest.php
index 51475dadd..cef9ca947 100644
--- a/tests/N98/Magento/Command/Indexer/ReindexAllCommandTest.php
+++ b/tests/N98/Magento/Command/Indexer/ReindexAllCommandTest.php
@@ -1,16 +1,19 @@
getApplication();
$application->add(new ReindexAllCommand());
+
$command = $this->getApplication()->find('index:reindex:all');
$application->initMagento();
@@ -20,14 +23,14 @@ public function testExecute()
['command' => $command->getName()],
);
- self::assertStringContainsString('Successfully reindexed catalog_product_attribute', $commandTester->getDisplay());
- self::assertStringContainsString('Successfully reindexed catalog_product_price', $commandTester->getDisplay());
- self::assertStringContainsString('Successfully reindexed catalog_url', $commandTester->getDisplay());
- self::assertStringContainsString('Successfully reindexed catalog_product_flat', $commandTester->getDisplay());
- self::assertStringContainsString('Successfully reindexed catalog_category_flat', $commandTester->getDisplay());
- self::assertStringContainsString('Successfully reindexed catalog_category_product', $commandTester->getDisplay());
- self::assertStringContainsString('Successfully reindexed catalogsearch_fulltext', $commandTester->getDisplay());
- self::assertStringContainsString('Successfully reindexed cataloginventory_stock', $commandTester->getDisplay());
- self::assertStringContainsString('Successfully reindexed tag_summary', $commandTester->getDisplay());
+ $this->assertStringContainsString('Successfully reindexed catalog_product_attribute', $commandTester->getDisplay());
+ $this->assertStringContainsString('Successfully reindexed catalog_product_price', $commandTester->getDisplay());
+ $this->assertStringContainsString('Successfully reindexed catalog_url', $commandTester->getDisplay());
+ $this->assertStringContainsString('Successfully reindexed catalog_product_flat', $commandTester->getDisplay());
+ $this->assertStringContainsString('Successfully reindexed catalog_category_flat', $commandTester->getDisplay());
+ $this->assertStringContainsString('Successfully reindexed catalog_category_product', $commandTester->getDisplay());
+ $this->assertStringContainsString('Successfully reindexed catalogsearch_fulltext', $commandTester->getDisplay());
+ $this->assertStringContainsString('Successfully reindexed cataloginventory_stock', $commandTester->getDisplay());
+ $this->assertStringContainsString('Successfully reindexed tag_summary', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Indexer/ReindexCommandTest.php b/tests/N98/Magento/Command/Indexer/ReindexCommandTest.php
index 3130f3aca..5d0b64b21 100644
--- a/tests/N98/Magento/Command/Indexer/ReindexCommandTest.php
+++ b/tests/N98/Magento/Command/Indexer/ReindexCommandTest.php
@@ -1,16 +1,19 @@
getApplication();
$application->add(new ReindexCommand());
+
$command = $this->getApplication()->find('index:reindex');
$commandTester = new CommandTester($command);
@@ -18,6 +21,6 @@ public function testExecute()
['command' => $command->getName(), 'index_code' => 'tag_summary,tag_summary'],
);
- self::assertStringContainsString('Successfully re-indexed tag_summary', $commandTester->getDisplay());
+ $this->assertStringContainsString('Successfully re-indexed tag_summary', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Installer/InstallCommandPackageVersionTest.php b/tests/N98/Magento/Command/Installer/InstallCommandPackageVersionTest.php
index 348f1122c..07d7b184c 100644
--- a/tests/N98/Magento/Command/Installer/InstallCommandPackageVersionTest.php
+++ b/tests/N98/Magento/Command/Installer/InstallCommandPackageVersionTest.php
@@ -1,5 +1,7 @@
getApplication();
$application->add(new InstallCommand());
/** @var InstallCommand $command */
$command = $this->getApplication()->find('install');
- $tester = new InstallCommandTester();
- $packages = $tester->getMagentoPackages($command);
+ $installCommandTester = new InstallCommandTester();
+ $packages = $installCommandTester->getMagentoPackages($command);
$this->assertOngoingPackageVersions($packages, 2, 5);
}
@@ -37,7 +36,6 @@ public function versionListing()
* helper assertion to verify that all packages with multiple versions are listet with the latest and greatest
* version first.
*
- * @param array $packages
* @param int $namespacesMinimum minimum number of package namespace (e.g. CE and mirror), normally 2
* @param int $nonVersionsMaximum maximum number of packages that will trigger an assertion
*/
@@ -49,63 +47,58 @@ private function assertOngoingPackageVersions(array $packages, $namespacesMinimu
$nameConstraint = [];
foreach ($packages as $package) {
- self::assertArrayHasKey('name', $package);
- self::assertArrayHasKey('version', $package);
+ $this->assertArrayHasKey('name', $package);
+ $this->assertArrayHasKey('version', $package);
$name = $package['name'];
$version = $package['version'];
- $nameAndVersion = "$name $version";
+ $nameAndVersion = sprintf('%s %s', $name, $version);
- self::assertArrayNotHasKey(
- $name,
- $nameConstraint,
- sprintf('duplicate package "%s"', $name),
- );
+ $this->assertArrayNotHasKey($name, $nameConstraint, sprintf('duplicate package "%s"', $name));
$nameConstraint[$name] = 1;
if (!$this->isVersionNumber($version)) {
$nonVersionsList[] = $nameAndVersion;
- $nonVersions++;
+ ++$nonVersions;
continue;
}
[$namespace, $nameVersion] = $this->splitName($name);
if ($nameVersion === null || $nameVersion !== $version) {
$nonVersionsList[] = $name;
- $nonVersions++;
+ ++$nonVersions;
continue;
}
- self::assertSame($version, $nameVersion);
+
+ $this->assertSame($version, $nameVersion);
if (isset($nameStack[$namespace])) {
$comparison = version_compare($nameStack[$namespace], $version);
$message = sprintf(
- "Check order of versions for package \"$namespace\", higher comes first, but got %s before %s",
+ sprintf('Check order of versions for package "%s", higher comes first, but got %%s before %%s', $namespace),
$nameStack[$namespace],
$version,
);
- self::assertGreaterThan(0, $comparison, $message);
+ $this->assertGreaterThan(0, $comparison, $message);
}
+
$nameStack[$namespace] = $nameVersion;
}
- self::assertGreaterThanOrEqual($namespacesMinimum, count($nameStack));
+ $this->assertGreaterThanOrEqual($namespacesMinimum, count($nameStack));
$message = sprintf('Too many non-versions (%s)', implode(', ', $nonVersionsList));
- self::assertLessThan($nonVersionsMaximum, $nonVersions, $message);
+ $this->assertLessThan($nonVersionsMaximum, $nonVersions, $message);
}
- /**
- * @test that demo-data-packages actually exist
- */
- public function demoDataPackages()
+ public function testDemoDataPackages()
{
$application = $this->getApplication();
$application->add(new InstallCommand());
/** @var InstallCommand $command */
$command = $this->getApplication()->find('install');
- $tester = new InstallCommandTester();
- $packages = $tester->getMagentoPackages($command);
- $demoDataPackages = $tester->getSampleDataPackages($command);
+ $installCommandTester = new InstallCommandTester();
+ $packages = $installCommandTester->getMagentoPackages($command);
+ $demoDataPackages = $installCommandTester->getSampleDataPackages($command);
$this->assertSampleDataPackagesExist($packages, $demoDataPackages);
}
@@ -117,13 +110,14 @@ private function assertSampleDataPackagesExist(array $packages, array $demoDataP
$map[$package['name']] = $index;
}
- foreach ($packages as $index => $package) {
+ foreach ($packages as $package) {
if (!isset($package['extra']['sample-data'])) {
continue;
}
+
$name = $package['extra']['sample-data'];
$message = sprintf('Invalid sample-data "%s" (undefined) in package "%s"', $name, $package['name']);
- self::assertArrayHasKey($name, $map, $message);
+ $this->assertArrayHasKey($name, $map, $message);
}
}
@@ -144,8 +138,11 @@ private function splitName($name)
*/
private function isVersionNumber($buffer)
{
- return $this->isQuadripartiteVersionNumber($buffer)
- || $this->isTripartiteOpenMageVersionNumber($buffer);
+ if ($this->isQuadripartiteVersionNumber($buffer)) {
+ return true;
+ }
+
+ return $this->isTripartiteOpenMageVersionNumber($buffer);
}
/**
@@ -157,7 +154,7 @@ private function isVersionNumber($buffer)
*/
private function isTripartiteOpenMageVersionNumber($buffer)
{
- if (!preg_match('~^(?:19|2\d)\.\d+\.\d+$~', $buffer)) {
+ if (in_array(preg_match('~^(?:19|2\d)\.\d+\.\d+$~', $buffer), [0, false], true)) {
return false;
}
@@ -176,7 +173,7 @@ private function isTripartiteOpenMageVersionNumber($buffer)
*/
private function isQuadripartiteVersionNumber($buffer)
{
- if (!preg_match('~^\d+\.\d+\.\d+\.\d+$~', $buffer)) {
+ if (in_array(preg_match('~^\d+\.\d+\.\d+\.\d+$~', $buffer), [0, false], true)) {
return false;
}
diff --git a/tests/N98/Magento/Command/Installer/InstallCommandTest.php b/tests/N98/Magento/Command/Installer/InstallCommandTest.php
index 8fb1de652..ecdc6fe8a 100644
--- a/tests/N98/Magento/Command/Installer/InstallCommandTest.php
+++ b/tests/N98/Magento/Command/Installer/InstallCommandTest.php
@@ -1,5 +1,7 @@
markTestIncomplete('With PHPUnit 10 the test is waiting forever. This has to be fixed.');
$application = $this->getApplication();
$application->add(new InstallCommand());
+
$command = $this->getApplication()->find('install');
$commandTester = new CommandTester($command);
@@ -58,10 +61,10 @@ public function testInstallFailsWithInvalidDbConfigWhenAllOptionsArePassedIn()
'--dbName' => 'magento',
],
);
- } catch (InvalidArgumentException $e) {
- self::assertEquals('Database configuration is invalid', $e->getMessage());
+ } catch (InvalidArgumentException $invalidArgumentException) {
+ $this->assertSame('Database configuration is invalid', $invalidArgumentException->getMessage());
$display = $commandTester->getDisplay(true);
- self::assertStringContainsString('SQLSTATE', $display);
+ $this->assertStringContainsString('SQLSTATE', $display);
return;
}
@@ -72,7 +75,7 @@ public function testInstallFailsWithInvalidDbConfigWhenAllOptionsArePassedIn()
/**
* Remove directory made by installer
*/
- public function tearDown(): void
+ protected function tearDown(): void
{
if (is_readable($this->installDir)) {
@rmdir($this->installDir);
diff --git a/tests/N98/Magento/Command/Installer/InstallCommandTester.php b/tests/N98/Magento/Command/Installer/InstallCommandTester.php
index 93299f1d6..c0154fd80 100644
--- a/tests/N98/Magento/Command/Installer/InstallCommandTester.php
+++ b/tests/N98/Magento/Command/Installer/InstallCommandTester.php
@@ -1,5 +1,7 @@
getCommandConfig($commandClass);
+ $commandConfig = $installCommand->getCommandConfig($commandClass);
return $commandConfig['magento-packages'];
}
/**
- * @param InstallCommand $command
* @return array
*/
- public function getSampleDataPackages(InstallCommand $command)
+ public function getSampleDataPackages(InstallCommand $installCommand)
{
$commandClass = self::COMMAND_CLASS;
- $commandConfig = $command->getCommandConfig($commandClass);
+ $commandConfig = $installCommand->getCommandConfig($commandClass);
return $commandConfig['demo-data-packages'];
}
}
diff --git a/tests/N98/Magento/Command/Installer/UninstallCommandTest.php b/tests/N98/Magento/Command/Installer/UninstallCommandTest.php
index 9939c90b6..53d63176e 100644
--- a/tests/N98/Magento/Command/Installer/UninstallCommandTest.php
+++ b/tests/N98/Magento/Command/Installer/UninstallCommandTest.php
@@ -1,5 +1,7 @@
*/
-class UninstallCommandTest extends TestCase
+final class UninstallCommandTest extends TestCase
{
/**
* Check that Magento is not removed if confirmation is denied
@@ -22,19 +24,21 @@ public function testUninstallDoesNotUninstallIfConfirmationDenied()
$this->markTestIncomplete('Find a replacement for setInputStream() of old DialogHelper');
$application = $this->getApplication();
$application->add(new UninstallCommand());
+
$command = $this->getApplication()->find('uninstall');
$commandTester = new CommandTester($command);
$dialog = new QuestionHelper();
$dialog->setInputStream($this->getInputStream('no\n'));
+
$command->setHelperSet(new HelperSet([$dialog]));
$commandTester->execute(['command' => $command->getName(), '--installationFolder' => $this->getTestMagentoRoot()]);
- self::assertEquals('Really uninstall ? [n]: ', $commandTester->getDisplay());
+ $this->assertSame('Really uninstall ? [n]: ', $commandTester->getDisplay());
//check magento still installed
- self::assertFileExists($this->getTestMagentoRoot() . '/app/etc/local.xml');
+ $this->assertFileExists($this->getTestMagentoRoot() . '/app/etc/local.xml');
}
/**
@@ -45,6 +49,7 @@ public function testUninstallForceActuallyRemoves()
$this->markTestIncomplete('Find a replacement for setInputStream() of old DialogHelper');
$application = $this->getApplication();
$application->add(new UninstallCommand());
+
$command = $this->getApplication()->find('uninstall');
$commandTester = new CommandTester($command);
@@ -53,20 +58,20 @@ public function testUninstallForceActuallyRemoves()
['command' => $command->getName(), '--force' => true, '--installationFolder' => $this->getTestMagentoRoot()],
);
- self::assertStringContainsString('Dropped database', $commandTester->getDisplay());
- self::assertStringContainsString('Remove directory ' . $this->getTestMagentoRoot(), $commandTester->getDisplay());
- self::assertStringContainsString('Done', $commandTester->getDisplay());
- self::assertFileDoesNotExist($this->getTestMagentoRoot() . '/app/etc/local.xml');
+ $this->assertStringContainsString('Dropped database', $commandTester->getDisplay());
+ $this->assertStringContainsString('Remove directory ' . $this->getTestMagentoRoot(), $commandTester->getDisplay());
+ $this->assertStringContainsString('Done', $commandTester->getDisplay());
+ $this->assertFileDoesNotExist($this->getTestMagentoRoot() . '/app/etc/local.xml');
}
/**
* @param $input
* @return resource
*/
- protected function getInputStream($input)
+ private function getInputStream($input)
{
$stream = fopen('php://memory', 'rb+', false);
- fputs($stream, $input);
+ fwrite($stream, $input);
rewind($stream);
return $stream;
}
diff --git a/tests/N98/Magento/Command/ListCommandTest.php b/tests/N98/Magento/Command/ListCommandTest.php
index 55d2f73d6..d32e7b6fa 100644
--- a/tests/N98/Magento/Command/ListCommandTest.php
+++ b/tests/N98/Magento/Command/ListCommandTest.php
@@ -1,10 +1,12 @@
'list'],
);
- self::assertStringContainsString(
- sprintf('n98-magerun %s by valantic CEC', $this->getApplication()->getVersion()),
- $commandTester->getDisplay(),
- );
+ $this->assertStringContainsString(sprintf('n98-magerun %s by valantic CEC', $this->getApplication()->getVersion()), $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/LocalConfig/GenerateCommandTest.php b/tests/N98/Magento/Command/LocalConfig/GenerateCommandTest.php
index 71c677170..64299dc47 100644
--- a/tests/N98/Magento/Command/LocalConfig/GenerateCommandTest.php
+++ b/tests/N98/Magento/Command/LocalConfig/GenerateCommandTest.php
@@ -1,5 +1,7 @@
configFile = sprintf('%s/%s/local.xml', sys_get_temp_dir(), $this->getName());
mkdir(dirname($this->configFile), 0777, true);
@@ -61,11 +63,8 @@ public function testErrorIsPrintedIfConfigFileExists()
],
);
- self::assertFileExists($this->configFile);
- self::assertStringContainsString(
- sprintf('local.xml file already exists in folder "%s/app/etc"', dirname($this->configFile)),
- $commandTester->getDisplay(),
- );
+ $this->assertFileExists($this->configFile);
+ $this->assertStringContainsString(sprintf('local.xml file already exists in folder "%s/app/etc"', dirname($this->configFile)), $commandTester->getDisplay());
}
public function testErrorIsPrintedIfConfigTemplateNotExists()
@@ -86,10 +85,7 @@ public function testErrorIsPrintedIfConfigTemplateNotExists()
],
);
- self::assertStringContainsString(
- sprintf('File %s/local.xml.template does not exist', dirname($this->configFile)),
- $commandTester->getDisplay(),
- );
+ $this->assertStringContainsString(sprintf('File %s/local.xml.template does not exist', dirname($this->configFile)), $commandTester->getDisplay());
}
public function testErrorIsPrintedIfAppEtcDirNotWriteable()
@@ -113,10 +109,7 @@ public function testErrorIsPrintedIfAppEtcDirNotWriteable()
],
);
- self::assertStringContainsString(
- sprintf('Folder %s is not writeable', dirname($this->configFile)),
- $commandTester->getDisplay(),
- );
+ $this->assertStringContainsString(sprintf('Folder %s is not writeable', dirname($this->configFile)), $commandTester->getDisplay());
chmod(dirname($this->configFile), $originalMode);
}
@@ -138,18 +131,18 @@ public function testRandomMd5IsUsedIfNoEncryptionKeyParamPassed()
],
);
- self::assertFileExists($this->configFile);
+ $this->assertFileExists($this->configFile);
$fileContent = \file_get_contents($this->configFile);
- self::assertStringContainsString('', $fileContent);
- self::assertStringContainsString('', $fileContent);
- self::assertStringContainsString('', $fileContent);
- self::assertStringContainsString('', $fileContent);
- self::assertStringContainsString('', $fileContent);
- self::assertStringContainsString('', $fileContent);
- self::assertMatchesRegularExpression('/<\/key>/', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
+ $this->assertMatchesRegularExpression('/<\/key>/', $fileContent);
$xml = \simplexml_load_file($this->configFile);
- self::assertIsNotBool($xml);
+ $this->assertIsNotBool($xml);
}
public function testExecuteWithCliParameters()
@@ -170,18 +163,18 @@ public function testExecuteWithCliParameters()
],
);
- self::assertFileExists($this->configFile);
+ $this->assertFileExists($this->configFile);
$fileContent = \file_get_contents($this->configFile);
- self::assertStringContainsString('', $fileContent);
- self::assertStringContainsString('', $fileContent);
- self::assertStringContainsString('', $fileContent);
- self::assertStringContainsString('', $fileContent);
- self::assertStringContainsString('', $fileContent);
- self::assertStringContainsString('', $fileContent);
- self::assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
$xml = \simplexml_load_file($this->configFile);
- self::assertIsNotBool($xml);
+ $this->assertIsNotBool($xml);
}
public function testInteractiveInputUsesDefaultValuesIfNoValueEntered()
@@ -203,18 +196,18 @@ public function testInteractiveInputUsesDefaultValuesIfNoValueEntered()
],
);
- self::assertFileExists($this->configFile);
+ $this->assertFileExists($this->configFile);
$fileContent = \file_get_contents($this->configFile);
- self::assertStringContainsString('', $fileContent);
- self::assertStringContainsString('', $fileContent);
- self::assertStringContainsString('', $fileContent);
- self::assertStringContainsString('', $fileContent);
- self::assertStringContainsString('', $fileContent);
- self::assertStringContainsString('', $fileContent);
- self::assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
$xml = \simplexml_load_file($this->configFile);
- self::assertIsNotBool($xml);
+ $this->assertIsNotBool($xml);
}
/**
@@ -245,7 +238,7 @@ public function testRequiredOptionsThrowExceptionIfNotSet($param, $prompt, $defa
->onlyMethods(['ask'])
->getMock();
- $questionHelperMock->expects(self::once())
+ $questionHelperMock->expects($this->once())
->method('ask')
->with(
self::isInstanceOf(InputInterface::class),
@@ -266,17 +259,15 @@ public function testRequiredOptionsThrowExceptionIfNotSet($param, $prompt, $defa
}
/**
- * @return array
+ * @return \Iterator<(int | string), mixed>
*/
- public function requiredFieldsProvider()
+ public function requiredFieldsProvider(): \Iterator
{
- return [
- ['db-host', 'database host', ''],
- ['db-user', 'database username', ''],
- ['db-name', 'database name', ''],
- ['session-save', 'session save', 'files'],
- ['admin-frontname', 'admin frontname', 'admin'],
- ];
+ yield ['db-host', 'database host', ''];
+ yield ['db-user', 'database username', ''];
+ yield ['db-name', 'database name', ''];
+ yield ['session-save', 'session save', 'files'];
+ yield ['admin-frontname', 'admin frontname', 'admin'];
}
public function testExecuteInteractively()
@@ -316,17 +307,17 @@ public function testExecuteInteractively()
$commandTester = new CommandTester($command);
$commandTester->execute(['command' => $command->getName()]);
- self::assertFileExists($this->configFile);
+ $this->assertFileExists($this->configFile);
$fileContent = \file_get_contents($this->configFile);
- self::assertStringContainsString('', $fileContent);
- self::assertStringContainsString('', $fileContent);
- self::assertStringContainsString('', $fileContent);
- self::assertStringContainsString('', $fileContent);
- self::assertStringContainsString('', $fileContent);
- self::assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
$xml = \simplexml_load_file($this->configFile);
- self::assertIsNotBool($xml);
+ $this->assertIsNotBool($xml);
}
public function testIfPasswordOmittedItIsWrittenBlank()
@@ -337,7 +328,7 @@ public function testIfPasswordOmittedItIsWrittenBlank()
->onlyMethods(['ask'])
->getMock();
- $questionHelperMock->expects(self::once())
+ $questionHelperMock->expects($this->once())
->method('ask')
->with(
self::isInstanceOf(InputInterface::class),
@@ -361,18 +352,18 @@ public function testIfPasswordOmittedItIsWrittenBlank()
],
);
- self::assertFileExists($this->configFile);
+ $this->assertFileExists($this->configFile);
$fileContent = \file_get_contents($this->configFile);
- self::assertStringContainsString('', $fileContent);
- self::assertStringContainsString('', $fileContent);
- self::assertStringContainsString('', $fileContent);
- self::assertStringContainsString('', $fileContent);
- self::assertStringContainsString('', $fileContent);
- self::assertStringContainsString('', $fileContent);
- self::assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
$xml = \simplexml_load_file($this->configFile);
- self::assertIsNotBool($xml);
+ $this->assertIsNotBool($xml);
}
public function testCdataTagIsNotAddedIfPresentInInput()
@@ -383,7 +374,7 @@ public function testCdataTagIsNotAddedIfPresentInInput()
->onlyMethods(['ask'])
->getMock();
- $questionHelperMock->expects(self::once())
+ $questionHelperMock->expects($this->once())
->method('ask')
->with(
self::isInstanceOf(InputInterface::class),
@@ -409,41 +400,39 @@ public function testCdataTagIsNotAddedIfPresentInInput()
],
);
- self::assertFileExists($this->configFile);
+ $this->assertFileExists($this->configFile);
$fileContent = \file_get_contents($this->configFile);
- self::assertStringContainsString('', $fileContent);
- self::assertStringContainsString('', $fileContent);
- self::assertStringContainsString('', $fileContent);
- self::assertStringContainsString('', $fileContent);
- self::assertStringContainsString('', $fileContent);
- self::assertStringContainsString('', $fileContent);
- self::assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
+ $this->assertStringContainsString('', $fileContent);
$xml = \simplexml_load_file($this->configFile);
- self::assertIsNotBool($xml);
+ $this->assertIsNotBool($xml);
}
- /**
- * @test unit utility method _wrapCdata
- */
- public function wrapCdata()
+ public function testWrapCdata()
{
- $command = new GenerateCommand();
- $refl = new ReflectionClass($command);
- $method = $refl->getMethod('_wrapCData');
- $method->setAccessible(true);
- $sujet = function ($string) use ($method, $command) {
- return $method->invoke($command, $string);
+ $generateCommand = new GenerateCommand();
+ $reflectionClass = new ReflectionClass($generateCommand);
+ $reflectionMethod = $reflectionClass->getMethod('_wrapCData');
+ $reflectionMethod->setAccessible(true);
+
+ $sujet = function ($string) use ($reflectionMethod, $generateCommand) {
+ return $reflectionMethod->invoke($generateCommand, $string);
};
- self::assertSame('', $sujet(null));
- self::assertSame('', $sujet('CDATA'));
- self::assertSame('', $sujet(']]'));
- self::assertSame(']]>', $sujet(' with terminator "]]>" inside '));
- self::assertSame(']]>', $sujet(']]> at the start '));
- self::assertSame(']]>', $sujet(' at the end ]]>'));
+ $this->assertSame('', $sujet(null));
+ $this->assertSame('', $sujet('CDATA'));
+ $this->assertSame('', $sujet(']]'));
+ $this->assertSame(']]>', $sujet(' with terminator "]]>" inside '));
+ $this->assertSame(']]>', $sujet(']]> at the start '));
+ $this->assertSame(']]>', $sujet(' at the end ]]>'));
}
- public function tearDown(): void
+ protected function tearDown(): void
{
if (file_exists($this->configFile)) {
unlink($this->configFile);
@@ -452,6 +441,7 @@ public function tearDown(): void
if (file_exists(sprintf('%s/local.xml.template', dirname($this->configFile)))) {
unlink(sprintf('%s/local.xml.template', dirname($this->configFile)));
}
+
rmdir(dirname($this->configFile));
}
}
diff --git a/tests/N98/Magento/Command/MagentoConnect/ListExtensionsCommandTest.php b/tests/N98/Magento/Command/MagentoConnect/ListExtensionsCommandTest.php
index cd053aebe..5c7beb7d4 100644
--- a/tests/N98/Magento/Command/MagentoConnect/ListExtensionsCommandTest.php
+++ b/tests/N98/Magento/Command/MagentoConnect/ListExtensionsCommandTest.php
@@ -1,12 +1,14 @@
getApplication();
$application->add(new ListExtensionsCommand());
+
$command = $this->getApplication()->find('extension:list');
$commandTester = new CommandTester($command);
@@ -29,8 +32,8 @@ public function testExecute()
['command' => $command->getName(), 'search' => 'Mage_All_Latest'],
);
- self::assertContains('Package', $commandTester->getDisplay());
- self::assertContains('Version', $commandTester->getDisplay());
- self::assertContains('Mage_All_Latest', $commandTester->getDisplay());
+ $this->assertContains('Package', $commandTester->getDisplay());
+ $this->assertContains('Version', $commandTester->getDisplay());
+ $this->assertContains('Mage_All_Latest', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/MagentoConnect/ValidateExtensionCommandTest.php b/tests/N98/Magento/Command/MagentoConnect/ValidateExtensionCommandTest.php
index 9f0fd0655..4174767c7 100644
--- a/tests/N98/Magento/Command/MagentoConnect/ValidateExtensionCommandTest.php
+++ b/tests/N98/Magento/Command/MagentoConnect/ValidateExtensionCommandTest.php
@@ -1,12 +1,14 @@
getDisplay();
- self::assertContains('Mage_All_Latest', $output);
+ $this->assertContains('Mage_All_Latest', $output);
}
}
diff --git a/tests/N98/Magento/Command/Media/DumpCommand.php b/tests/N98/Magento/Command/Media/DumpCommand.php
index de3da5900..b2d6d134d 100644
--- a/tests/N98/Magento/Command/Media/DumpCommand.php
+++ b/tests/N98/Magento/Command/Media/DumpCommand.php
@@ -1,5 +1,7 @@
getApplication();
$application->add(new DumpCommand());
+
$command = $this->getApplication()->find('media:dump');
$commandTester = new CommandTester($command);
diff --git a/tests/N98/Magento/Command/Script/Repository/ListCommandTest.php b/tests/N98/Magento/Command/Script/Repository/ListCommandTest.php
index a78170a96..ae2944b41 100644
--- a/tests/N98/Magento/Command/Script/Repository/ListCommandTest.php
+++ b/tests/N98/Magento/Command/Script/Repository/ListCommandTest.php
@@ -1,11 +1,13 @@
setConfig($config);
$application->add(new RunCommand());
+
$command = $this->getApplication()->find('script:repo:list');
$commandTester = new CommandTester($command);
@@ -22,8 +25,8 @@ public function testExecute()
['command' => $command->getName()],
);
- self::assertStringContainsString('Cache Flush Command Test (Hello World)', $commandTester->getDisplay());
- self::assertStringContainsString('Foo command', $commandTester->getDisplay());
- self::assertStringContainsString('Bar command', $commandTester->getDisplay());
+ $this->assertStringContainsString('Cache Flush Command Test (Hello World)', $commandTester->getDisplay());
+ $this->assertStringContainsString('Foo command', $commandTester->getDisplay());
+ $this->assertStringContainsString('Bar command', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/Script/Repository/RunCommandTest.php b/tests/N98/Magento/Command/Script/Repository/RunCommandTest.php
index 033ef10b9..cf48c7251 100644
--- a/tests/N98/Magento/Command/Script/Repository/RunCommandTest.php
+++ b/tests/N98/Magento/Command/Script/Repository/RunCommandTest.php
@@ -1,11 +1,13 @@
setConfig($config);
$application->add(new RunCommand());
+
$command = $this->getApplication()->find('script:repo:run');
$commandTester = new CommandTester($command);
@@ -26,12 +29,9 @@ public function testExecute()
);
// Runs sys:info -> Check for any output
- self::assertStringContainsString('Vendors (core)', $commandTester->getDisplay());
+ $this->assertStringContainsString('Vendors (core)', $commandTester->getDisplay());
- self::assertStringContainsString(
- $testDir . '/hello-world.magerun',
- $this->normalizePathSeparators($commandTester->getDisplay()),
- );
+ $this->assertStringContainsString($testDir . '/hello-world.magerun', $this->normalizePathSeparators($commandTester->getDisplay()));
}
/**
diff --git a/tests/N98/Magento/Command/ScriptCommandTest.php b/tests/N98/Magento/Command/ScriptCommandTest.php
index cfb4a9baa..34859f059 100644
--- a/tests/N98/Magento/Command/ScriptCommandTest.php
+++ b/tests/N98/Magento/Command/ScriptCommandTest.php
@@ -1,17 +1,20 @@
getApplication();
$application->add(new ScriptCommand());
$application->setAutoExit(false);
+
$command = $this->getApplication()->find('script');
$commandTester = new CommandTester($command);
@@ -21,17 +24,17 @@ public function testExecute()
// Check pre defined vars
$edition = is_callable(['\Mage', 'getEdition']) ? Mage::getEdition() : 'Community';
- self::assertStringContainsString('magento.edition: ' . $edition, $commandTester->getDisplay());
-
- self::assertStringContainsString('magento.root: ' . $this->getApplication()->getMagentoRootFolder(), $commandTester->getDisplay());
- self::assertStringContainsString('magento.version: ' . Mage::getVersion(), $commandTester->getDisplay());
- self::assertStringContainsString('magerun.version: ' . $this->getApplication()->getVersion(), $commandTester->getDisplay());
-
- self::assertStringContainsString('code', $commandTester->getDisplay());
- self::assertStringContainsString('foo.sql', $commandTester->getDisplay());
- self::assertStringContainsString('BAR: foo.sql.gz', $commandTester->getDisplay());
- self::assertStringContainsString('Magento Websites', $commandTester->getDisplay());
- self::assertStringContainsString('web/secure/base_url', $commandTester->getDisplay());
- self::assertStringContainsString('web/seo/use_rewrites => 1', $commandTester->getDisplay());
+ $this->assertStringContainsString('magento.edition: ' . $edition, $commandTester->getDisplay());
+
+ $this->assertStringContainsString('magento.root: ' . $this->getApplication()->getMagentoRootFolder(), $commandTester->getDisplay());
+ $this->assertStringContainsString('magento.version: ' . Mage::getVersion(), $commandTester->getDisplay());
+ $this->assertStringContainsString('magerun.version: ' . $this->getApplication()->getVersion(), $commandTester->getDisplay());
+
+ $this->assertStringContainsString('code', $commandTester->getDisplay());
+ $this->assertStringContainsString('foo.sql', $commandTester->getDisplay());
+ $this->assertStringContainsString('BAR: foo.sql.gz', $commandTester->getDisplay());
+ $this->assertStringContainsString('Magento Websites', $commandTester->getDisplay());
+ $this->assertStringContainsString('web/secure/base_url', $commandTester->getDisplay());
+ $this->assertStringContainsString('web/seo/use_rewrites => 1', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/System/Check/Settings/CookieDomainCheckAbstractTest.php b/tests/N98/Magento/Command/System/Check/Settings/CookieDomainCheckAbstractTest.php
index 3fe1f04e2..ecc4d174d 100644
--- a/tests/N98/Magento/Command/System/Check/Settings/CookieDomainCheckAbstractTest.php
+++ b/tests/N98/Magento/Command/System/Check/Settings/CookieDomainCheckAbstractTest.php
@@ -1,5 +1,7 @@
- ['http://go/', 'go', false],
- ['http://go/', '.go', false],
- ['http://go.go/', 'go', false],
- ['http://go.go/', '.go', false],
- # ... some edge-cases left out
- ['http://www.good.go/', '.good.go', true],
- ['http://www.good.go/', 'www.good.go', true],
- ['http://good.go/', 'www.good.go', false],
- ['http://also.good.go/', 'www.good.go', false],
- ];
+ yield ['', '', false];
+ yield ['https://www.example.com/', '', false];
+ yield ['', '.example.com', false];
+ yield ['https://www.example.com/', '.example.com', true];
+ yield ['https://www.example.com/', 'www.example.com', true];
+ yield ['https://images.example.com/', 'www.example.com', false];
+ yield ['https://images.example.com/', 'example.com', true];
+ yield ['https://images.example.com/', '.example.com', true];
+ yield ['https://example.com/', '.example.com', false];
+ yield ['https://www.example.com/', '.www.example.com', false];
+ yield ['https://www.example.com/', 'wwww.example.com', false];
+ yield ['https://www.example.com/', 'ww.example.com', false];
+ yield ['https://www.example.com/', '.ww.example.com', false];
+ yield ['https://www.example.com/', '.w.example.com', false];
+ yield ['https://www.example.com/', '..example.com', false];
+ // false-positives we know about, there is no check against public suffix list (the co.uk check)
+ yield ['https://www.example.com/', '.com', false];
+ yield ['https://www.example.co.uk/', '.co.uk', true];
+ yield ['https://www.example.co.uk/', 'co.uk', true];
+ // go cases
+ yield ['http://go/', 'go', false];
+ yield ['http://go/', '.go', false];
+ yield ['http://go.go/', 'go', false];
+ yield ['http://go.go/', '.go', false];
+ # ... some edge-cases left out
+ yield ['http://www.good.go/', '.good.go', true];
+ yield ['http://www.good.go/', 'www.good.go', true];
+ yield ['http://good.go/', 'www.good.go', false];
+ yield ['http://also.good.go/', 'www.good.go', false];
}
/**
- * @test
* @dataProvider provideCookieDomainsAndBaseUrls
*/
- public function validateCookieDomainAgainstUrl($baseUrl, $cookieDomain, $expected)
+ public function testValidateCookieDomainAgainstUrl($baseUrl, $cookieDomain, $expected)
{
/** @var CookieDomainCheckAbstract $stub */
$stub = $this->getMockForAbstractClass(__NAMESPACE__ . '\CookieDomainCheckAbstract');
@@ -68,6 +67,6 @@ public function validateCookieDomainAgainstUrl($baseUrl, $cookieDomain, $expecte
$message = sprintf('%s for %s', $cookieDomain, $baseUrl);
- self::assertSame($expected, $actual, $message);
+ $this->assertSame($expected, $actual, $message);
}
}
diff --git a/tests/N98/Magento/Command/System/CheckCommandTest.php b/tests/N98/Magento/Command/System/CheckCommandTest.php
index 614cc360d..7ec36142c 100644
--- a/tests/N98/Magento/Command/System/CheckCommandTest.php
+++ b/tests/N98/Magento/Command/System/CheckCommandTest.php
@@ -1,25 +1,28 @@
getApplication();
$application->add(new InfoCommand());
+
$command = $this->getApplication()->find('sys:check');
$commandTester = new CommandTester($command);
$commandTester->execute(['command' => $command->getName()]);
- self::assertMatchesRegularExpression('/SETTINGS/', $commandTester->getDisplay());
- self::assertMatchesRegularExpression('/FILESYSTEM/', $commandTester->getDisplay());
- self::assertMatchesRegularExpression('/PHP/', $commandTester->getDisplay());
- self::assertMatchesRegularExpression('/SECURITY/', $commandTester->getDisplay());
- self::assertMatchesRegularExpression('/MYSQL/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/SETTINGS/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/FILESYSTEM/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/PHP/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/SECURITY/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/MYSQL/', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/System/Cron/HistoryCommandTest.php b/tests/N98/Magento/Command/System/Cron/HistoryCommandTest.php
index 943ec4c3f..ddc2d9eea 100644
--- a/tests/N98/Magento/Command/System/Cron/HistoryCommandTest.php
+++ b/tests/N98/Magento/Command/System/Cron/HistoryCommandTest.php
@@ -1,16 +1,19 @@
getApplication();
$application->add(new ListCommand());
+
$command = $this->getApplication()->find('sys:cron:history');
$commandTester = new CommandTester($command);
@@ -18,6 +21,6 @@ public function testExecute()
['command' => $command->getName()],
);
- self::assertMatchesRegularExpression('/Last executed jobs/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/Last executed jobs/', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/System/Cron/ListCommandTest.php b/tests/N98/Magento/Command/System/Cron/ListCommandTest.php
index 82f80c1d2..d0f7f47f4 100644
--- a/tests/N98/Magento/Command/System/Cron/ListCommandTest.php
+++ b/tests/N98/Magento/Command/System/Cron/ListCommandTest.php
@@ -1,21 +1,24 @@
getApplication();
$application->add(new ListCommand());
+
$command = $this->getApplication()->find('sys:cron:list');
$commandTester = new CommandTester($command);
$commandTester->execute(['command' => $command->getName()]);
- self::assertMatchesRegularExpression('/Cronjob List/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/Cronjob List/', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/System/Cron/RunCommandTest.php b/tests/N98/Magento/Command/System/Cron/RunCommandTest.php
index 024f7be23..1d7efbbf5 100644
--- a/tests/N98/Magento/Command/System/Cron/RunCommandTest.php
+++ b/tests/N98/Magento/Command/System/Cron/RunCommandTest.php
@@ -1,16 +1,19 @@
getApplication();
$application->add(new ListCommand());
+
$command = $this->getApplication()->find('sys:cron:run');
$commandTester = new CommandTester($command);
@@ -18,16 +21,14 @@ public function testExecute()
['command' => $command->getName(), 'job' => 'log_clean'],
);
- self::assertMatchesRegularExpression('/Run Mage_Log_Model_Cron::logClean done/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/Run Mage_Log_Model_Cron::logClean done/', $commandTester->getDisplay());
}
- /**
- * @test
- */
- public function urlBuildingWhileCron()
+ public function testUrlBuildingWhileCron()
{
$application = $this->getApplication();
$application->add(new RunCommand());
+
$command = $this->getApplication()->find('sys:cron:run');
$commandTester = new CommandTester($command);
@@ -35,6 +36,6 @@ public function urlBuildingWhileCron()
['command' => $command->getName(), 'job' => 'log_clean'],
);
- self::assertMatchesRegularExpression('/Run Mage_Log_Model_Cron::logClean done/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/Run Mage_Log_Model_Cron::logClean done/', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/System/Cron/ServerEnvironmentTest.php b/tests/N98/Magento/Command/System/Cron/ServerEnvironmentTest.php
index ff7cb3a96..01bc2a9ec 100644
--- a/tests/N98/Magento/Command/System/Cron/ServerEnvironmentTest.php
+++ b/tests/N98/Magento/Command/System/Cron/ServerEnvironmentTest.php
@@ -1,5 +1,7 @@
getApplication();
- self::assertInstanceOf(Application::class, $application);
+ $this->assertInstanceOf(Application::class, $application);
}
- /**
- * @test that getBaseUrl contains the script-name (here: Phpunit runner)
- */
- public function regression()
+ public function testRegression()
{
$store = Mage::app()->getStore(null);
$actual = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
- self::assertIsString($actual);
- self::assertMatchesRegularExpression('~/(ide-phpunit.php|phpunit)/$~', $actual);
+ $this->assertIsString($actual);
+ $this->assertMatchesRegularExpression('~/(ide-phpunit.php|phpunit)/$~', $actual);
}
- /**
- * @test
- */
- public function environmentFix()
+ public function testEnvironmentFix()
{
$store = Mage::app()->getStore(null);
$store->resetConfig();
- $environment = new ServerEnvironment();
- $environment->initalize();
+ $serverEnvironment = new ServerEnvironment();
+ $serverEnvironment->initalize();
$actual = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
- self::assertIsString($actual);
- self::assertStringEndsWith('/index.php/', $actual);
+ $this->assertIsString($actual);
+ $this->assertStringEndsWith('/index.php/', $actual);
$store->resetConfig();
- $environment->reset();
+ $serverEnvironment->reset();
$actual = Mage::app()->getStore(null)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
- self::assertIsString($actual);
- self::assertMatchesRegularExpression('~/(ide-phpunit.php|phpunit)/$~', $actual);
+ $this->assertIsString($actual);
+ $this->assertMatchesRegularExpression('~/(ide-phpunit.php|phpunit)/$~', $actual);
}
}
diff --git a/tests/N98/Magento/Command/System/InfoCommandTest.php b/tests/N98/Magento/Command/System/InfoCommandTest.php
index 9586bd5d8..17807476e 100644
--- a/tests/N98/Magento/Command/System/InfoCommandTest.php
+++ b/tests/N98/Magento/Command/System/InfoCommandTest.php
@@ -1,24 +1,27 @@
getApplication();
$application->add(new InfoCommand());
+
$command = $this->getApplication()->find('sys:info');
$commandTester = new CommandTester($command);
$commandTester->execute(['command' => $command->getName()]);
- self::assertMatchesRegularExpression('/Magento System Information/', $commandTester->getDisplay());
- self::assertMatchesRegularExpression('/Install Date/', $commandTester->getDisplay());
- self::assertMatchesRegularExpression('/Crypt Key/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/Magento System Information/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/Install Date/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/Crypt Key/', $commandTester->getDisplay());
// Settings argument
$commandTester->execute(
@@ -26,6 +29,6 @@ public function testExecute()
);
$commandResult = $commandTester->getDisplay();
- self::assertMatchesRegularExpression('/\d+\.\d+\.\d+/', $commandResult);
+ $this->assertMatchesRegularExpression('/\d+\.\d+\.\d+/', $commandResult);
}
}
diff --git a/tests/N98/Magento/Command/System/MaintenanceCommandTest.php b/tests/N98/Magento/Command/System/MaintenanceCommandTest.php
index e8fea36bf..10047f40d 100644
--- a/tests/N98/Magento/Command/System/MaintenanceCommandTest.php
+++ b/tests/N98/Magento/Command/System/MaintenanceCommandTest.php
@@ -1,16 +1,19 @@
getApplication();
$application->add(new MaintenanceCommand());
+
$command = $application->find('sys:maintenance');
$magentoRootFolder = $application->getMagentoRootFolder();
@@ -22,13 +25,13 @@ public function testExecute()
$commandTester->execute(
['command' => $command->getName(), '--on' => ''],
);
- self::assertMatchesRegularExpression('/Maintenance mode on/', $commandTester->getDisplay());
- self::assertFileExists($magentoRootFolder . '/maintenance.flag');
+ $this->assertMatchesRegularExpression('/Maintenance mode on/', $commandTester->getDisplay());
+ $this->assertFileExists($magentoRootFolder . '/maintenance.flag');
$commandTester->execute(
['command' => $command->getName(), '--off' => ''],
);
- self::assertMatchesRegularExpression('/Maintenance mode off/', $commandTester->getDisplay());
- self::assertFileDoesNotExist($magentoRootFolder . '/maintenance.flag');
+ $this->assertMatchesRegularExpression('/Maintenance mode off/', $commandTester->getDisplay());
+ $this->assertFileDoesNotExist($magentoRootFolder . '/maintenance.flag');
}
}
diff --git a/tests/N98/Magento/Command/System/Setup/ChangeVersionCommandTest.php b/tests/N98/Magento/Command/System/Setup/ChangeVersionCommandTest.php
index 7bbe15253..e2fd29c1d 100644
--- a/tests/N98/Magento/Command/System/Setup/ChangeVersionCommandTest.php
+++ b/tests/N98/Magento/Command/System/Setup/ChangeVersionCommandTest.php
@@ -1,5 +1,7 @@
getMock();
$resourceModel
- ->expects(self::once())
+ ->expects($this->once())
->method('setDbVersion')
->with('weee_setup', '1.6.0.0');
$resourceModel
- ->expects(self::once())
+ ->expects($this->once())
->method('setDataVersion')
->with('weee_setup', '1.6.0.0');
$application = $this->getApplication();
$application->add($command);
+
$command = $this->getApplication()->find('sys:setup:change-version');
$commandTester = new CommandTester($command);
$commandTester->execute(['command' => $command->getName(), 'module' => 'Mage_Weee', 'version' => '1.6.0.0']);
- self::assertStringContainsString(
- 'Successfully updated: "Mage_Weee" - "weee_setup" to version: "1.6.0.0"',
- $commandTester->getDisplay(),
- );
+ $this->assertStringContainsString('Successfully updated: "Mage_Weee" - "weee_setup" to version: "1.6.0.0"', $commandTester->getDisplay());
}
public function testUpdateBySetupName()
@@ -53,37 +53,36 @@ public function testUpdateBySetupName()
->getMock();
$command
- ->expects(self::once())
+ ->expects($this->once())
->method('_getResourceSingleton')
->willReturn($resourceModel);
$resourceModel
- ->expects(self::once())
+ ->expects($this->once())
->method('setDbVersion')
->with('weee_setup', '1.6.0.0');
$resourceModel
- ->expects(self::once())
+ ->expects($this->once())
->method('setDataVersion')
->with('weee_setup', '1.6.0.0');
$application = $this->getApplication();
$application->add($command);
+
$command = $this->getApplication()->find('sys:setup:change-version');
$commandTester = new CommandTester($command);
$commandTester->execute(['command' => $command->getName(), 'module' => 'Mage_Weee', 'version' => '1.6.0.0', 'setup' => 'weee_setup']);
- self::assertStringContainsString(
- 'Successfully updated: "Mage_Weee" - "weee_setup" to version: "1.6.0.0"',
- $commandTester->getDisplay(),
- );
+ $this->assertStringContainsString('Successfully updated: "Mage_Weee" - "weee_setup" to version: "1.6.0.0"', $commandTester->getDisplay());
}
public function testSetupNameNotFound()
{
$application = $this->getApplication();
$application->add(new ChangeVersionCommand());
+
$command = $this->getApplication()->find('sys:setup:change-version');
$commandTester = new CommandTester($command);
@@ -99,6 +98,7 @@ public function testModuleDoesNotExist()
{
$application = $this->getApplication();
$application->add(new ChangeVersionCommand());
+
$command = $this->getApplication()->find('sys:setup:change-version');
$commandTester = new CommandTester($command);
@@ -113,21 +113,19 @@ public function testCommandReturnsEarlyIfNoSetupResourcesForModule()
->setMethods(['getModuleSetupResources'])
->getMock();
- $command->expects(self::once())
+ $command->expects($this->once())
->method('getModuleSetupResources')
->with('Mage_Weee')
->willReturn([]);
$application = $this->getApplication();
$application->add($command);
+
$command = $this->getApplication()->find('sys:setup:change-version');
$commandTester = new CommandTester($command);
$commandTester->execute(['command' => $command->getName(), 'module' => 'Mage_Weee', 'version' => '1.0.0.0', 'setup' => 'weee_setup']);
- self::assertStringContainsString(
- 'No setup resources found for module: "Mage_Weee"',
- $commandTester->getDisplay(),
- );
+ $this->assertStringContainsString('No setup resources found for module: "Mage_Weee"', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/System/Setup/CompareVersionsCommandTest.php b/tests/N98/Magento/Command/System/Setup/CompareVersionsCommandTest.php
index d13d86499..bf03d64e9 100644
--- a/tests/N98/Magento/Command/System/Setup/CompareVersionsCommandTest.php
+++ b/tests/N98/Magento/Command/System/Setup/CompareVersionsCommandTest.php
@@ -1,17 +1,20 @@
getApplication();
$application->add(new CompareVersionsCommand());
+
$command = $this->getApplication()->find('sys:setup:compare-versions');
$commandTester = new CommandTester($command);
@@ -19,11 +22,11 @@ public function testExecute()
['command' => $command->getName()],
);
- self::assertMatchesRegularExpression('/Setup/', $commandTester->getDisplay());
- self::assertMatchesRegularExpression('/Module/', $commandTester->getDisplay());
- self::assertMatchesRegularExpression('/DB/', $commandTester->getDisplay());
- self::assertMatchesRegularExpression('/Data/', $commandTester->getDisplay());
- self::assertMatchesRegularExpression('/Status/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/Setup/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/Module/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/DB/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/Data/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/Status/', $commandTester->getDisplay());
}
public function testJunit()
@@ -31,6 +34,7 @@ public function testJunit()
vfsStream::setup();
$application = $this->getApplication();
$application->add(new CompareVersionsCommand());
+
$command = $this->getApplication()->find('sys:setup:compare-versions');
$commandTester = new CommandTester($command);
@@ -38,6 +42,6 @@ public function testJunit()
['command' => $command->getName(), '--log-junit' => vfsStream::url('root/junit.xml')],
);
- self::assertFileExists(vfsStream::url('root/junit.xml'));
+ $this->assertFileExists(vfsStream::url('root/junit.xml'));
}
}
diff --git a/tests/N98/Magento/Command/System/Setup/IncrementalCommandStub.php b/tests/N98/Magento/Command/System/Setup/IncrementalCommandStub.php
index 66edb7616..0f416e70d 100644
--- a/tests/N98/Magento/Command/System/Setup/IncrementalCommandStub.php
+++ b/tests/N98/Magento/Command/System/Setup/IncrementalCommandStub.php
@@ -1,5 +1,7 @@
callProtectedMethodFromObject('protectedMethod', $this, ['fooBar']);
- self::assertSame('barBaz', $actual);
+ $actual = $incrementalCommandStub->callProtectedMethodFromObject('protectedMethod', $this, ['fooBar']);
+ $this->assertSame('barBaz', $actual);
}
- protected function protectedMethod($arg)
+ protected function protectedMethod($arg): string
{
- self::assertSame('fooBar', $arg);
+ $this->assertSame('fooBar', $arg);
$this->addToAssertionCount(1);
return 'barBaz';
diff --git a/tests/N98/Magento/Command/System/Setup/RemoveCommandTest.php b/tests/N98/Magento/Command/System/Setup/RemoveCommandTest.php
index 650ad36e4..0e0ffdf73 100644
--- a/tests/N98/Magento/Command/System/Setup/RemoveCommandTest.php
+++ b/tests/N98/Magento/Command/System/Setup/RemoveCommandTest.php
@@ -1,5 +1,7 @@
*/
-class RemoveCommandTest extends TestCase
+final class RemoveCommandTest extends TestCase
{
public function testRemoveModule()
{
@@ -22,14 +24,14 @@ public function testRemoveModule()
->setMethods(['delete'])
->getMock();
- $mockAdapter->expects(self::once())
+ $mockAdapter->expects($this->once())
->method('delete')
->willReturn(1);
$coreResource = $this->getMockBuilder(Mage_Core_Model_Resource::class)
->getMock();
- $coreResource->expects(self::once())
+ $coreResource->expects($this->once())
->method('getConnection')
->willReturn($mockAdapter);
@@ -37,21 +39,19 @@ public function testRemoveModule()
->setMethods(['getMageCoreResource'])
->getMock();
- $command->expects(self::once())
+ $command->expects($this->once())
->method('getMageCoreResource')
->willReturn($coreResource);
$application = $this->getApplication();
$application->add($command);
+
$command = $this->getApplication()->find('sys:setup:remove');
$commandTester = new CommandTester($command);
$commandTester->execute(['command' => $command->getName(), 'module' => 'Mage_Weee']);
- self::assertStringContainsString(
- 'Successfully removed setup resource: "weee_setup" from module: "Mage_Weee"',
- $commandTester->getDisplay(),
- );
+ $this->assertStringContainsString('Successfully removed setup resource: "weee_setup" from module: "Mage_Weee"', $commandTester->getDisplay());
}
public function testRemoveBySetupName()
@@ -61,14 +61,14 @@ public function testRemoveBySetupName()
->setMethods(['delete'])
->getMock();
- $mockAdapter->expects(self::once())
+ $mockAdapter->expects($this->once())
->method('delete')
->willReturn(1);
$coreResource = $this->getMockBuilder(Mage_Core_Model_Resource::class)
->getMock();
- $coreResource->expects(self::once())
+ $coreResource->expects($this->once())
->method('getConnection')
->willReturn($mockAdapter);
@@ -76,12 +76,13 @@ public function testRemoveBySetupName()
->setMethods(['getMageCoreResource'])
->getMock();
- $command->expects(self::once())
+ $command->expects($this->once())
->method('getMageCoreResource')
->willReturn($coreResource);
$application = $this->getApplication();
$application->add($command);
+
$command = $this->getApplication()->find('sys:setup:remove');
$commandTester = new CommandTester($command);
@@ -91,10 +92,7 @@ public function testRemoveBySetupName()
'setup' => 'weee_setup',
]);
- self::assertStringContainsString(
- 'Successfully removed setup resource: "weee_setup" from module: "Mage_Weee"',
- $commandTester->getDisplay(),
- );
+ $this->assertStringContainsString('Successfully removed setup resource: "weee_setup" from module: "Mage_Weee"', $commandTester->getDisplay());
}
public function testRemoveBySetupNameFailure()
@@ -104,7 +102,7 @@ public function testRemoveBySetupNameFailure()
->setMethods(['delete'])
->getMock();
- $mockAdapter->expects(self::once())
+ $mockAdapter->expects($this->once())
->method('delete')
->willReturn(0);
@@ -112,11 +110,11 @@ public function testRemoveBySetupNameFailure()
->getMock();
;
- $coreResource->expects(self::once())
+ $coreResource->expects($this->once())
->method('getConnection')
->willReturn($mockAdapter);
- $coreResource->expects(self::once())
+ $coreResource->expects($this->once())
->method('getTableName')
->with('core_resource')
->willReturn('core_resource');
@@ -125,27 +123,26 @@ public function testRemoveBySetupNameFailure()
->setMethods(['getMageCoreResource'])
->getMock();
- $command->expects(self::once())
+ $command->expects($this->once())
->method('getMageCoreResource')
->willReturn($coreResource);
$application = $this->getApplication();
$application->add($command);
+
$command = $this->getApplication()->find('sys:setup:remove');
$commandTester = new CommandTester($command);
$commandTester->execute(['command' => $command->getName(), 'module' => 'Mage_Weee', 'setup' => 'weee_setup']);
- self::assertStringContainsString(
- 'No entry was found for setup resource: "weee_setup" in module: "Mage_Weee"',
- $commandTester->getDisplay(),
- );
+ $this->assertStringContainsString('No entry was found for setup resource: "weee_setup" in module: "Mage_Weee"', $commandTester->getDisplay());
}
public function testSetupNameNotFound()
{
$application = $this->getApplication();
$application->add(new RemoveCommand());
+
$command = $this->getApplication()->find('sys:setup:remove');
$commandTester = new CommandTester($command);
@@ -161,6 +158,7 @@ public function testModuleDoesNotExist()
{
$application = $this->getApplication();
$application->add(new RemoveCommand());
+
$command = $this->getApplication()->find('sys:setup:remove');
$commandTester = new CommandTester($command);
@@ -175,13 +173,14 @@ public function testCommandReturnsEarlyIfNoSetupResourcesForModule()
->setMethods(['getModuleSetupResources'])
->getMock();
- $command->expects(self::once())
+ $command->expects($this->once())
->method('getModuleSetupResources')
->with('Mage_Weee')
->willReturn([]);
$application = $this->getApplication();
$application->add($command);
+
$command = $this->getApplication()->find('sys:setup:remove');
$commandTester = new CommandTester($command);
@@ -191,9 +190,6 @@ public function testCommandReturnsEarlyIfNoSetupResourcesForModule()
'setup' => 'weee_setup',
]);
- self::assertStringContainsString(
- 'No setup resources found for module: "Mage_Weee"',
- $commandTester->getDisplay(),
- );
+ $this->assertStringContainsString('No setup resources found for module: "Mage_Weee"', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/System/Setup/RunCommandTest.php b/tests/N98/Magento/Command/System/Setup/RunCommandTest.php
index c27a45c3e..8fc711047 100644
--- a/tests/N98/Magento/Command/System/Setup/RunCommandTest.php
+++ b/tests/N98/Magento/Command/System/Setup/RunCommandTest.php
@@ -1,16 +1,19 @@
getApplication();
$application->add(new CompareVersionsCommand());
+
$command = $this->getApplication()->find('sys:setup:run');
$commandTester = new CommandTester($command);
@@ -18,6 +21,6 @@ public function testExecute()
['command' => $command->getName()],
);
- self::assertMatchesRegularExpression('/done/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/done/', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/System/Store/Config/BaseUrlListCommandTest.php b/tests/N98/Magento/Command/System/Store/Config/BaseUrlListCommandTest.php
index b392e043c..bbf95a68d 100644
--- a/tests/N98/Magento/Command/System/Store/Config/BaseUrlListCommandTest.php
+++ b/tests/N98/Magento/Command/System/Store/Config/BaseUrlListCommandTest.php
@@ -1,16 +1,19 @@
getApplication();
$application->add(new BaseUrlListCommand());
+
$command = $this->getApplication()->find('sys:store:config:base-url:list');
$commandTester = new CommandTester($command);
@@ -18,7 +21,7 @@ public function testExecute()
['command' => $command->getName()],
);
- self::assertMatchesRegularExpression('/secure_baseurl/', $commandTester->getDisplay());
- self::assertMatchesRegularExpression('/unsecure_baseurl/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/secure_baseurl/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/unsecure_baseurl/', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/System/Store/ListCommandTest.php b/tests/N98/Magento/Command/System/Store/ListCommandTest.php
index baf953137..baee7938b 100644
--- a/tests/N98/Magento/Command/System/Store/ListCommandTest.php
+++ b/tests/N98/Magento/Command/System/Store/ListCommandTest.php
@@ -1,22 +1,25 @@
getApplication();
$application->add(new ListCommand());
+
$command = $this->getApplication()->find('sys:store:list');
$commandTester = new CommandTester($command);
$commandTester->execute(['command' => $command->getName()]);
- self::assertMatchesRegularExpression('/id/', $commandTester->getDisplay());
- self::assertMatchesRegularExpression('/code/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/id/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/code/', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/System/Url/ListCommandTest.php b/tests/N98/Magento/Command/System/Url/ListCommandTest.php
index 98f0f5d93..a05f6b44d 100644
--- a/tests/N98/Magento/Command/System/Url/ListCommandTest.php
+++ b/tests/N98/Magento/Command/System/Url/ListCommandTest.php
@@ -1,16 +1,19 @@
getApplication();
$application->add(new ListCommand());
+
$command = $this->getApplication()->find('sys:url:list');
$commandTester = new CommandTester($command);
@@ -26,8 +29,8 @@ public function testExecute()
],
);
- self::assertMatchesRegularExpression('/prefix/', $commandTester->getDisplay());
- self::assertMatchesRegularExpression('/http/', $commandTester->getDisplay());
- self::assertMatchesRegularExpression('/suffix/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/prefix/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/http/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/suffix/', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/System/Website/ListCommandTest.php b/tests/N98/Magento/Command/System/Website/ListCommandTest.php
index 3027e9341..9ad2c5a86 100644
--- a/tests/N98/Magento/Command/System/Website/ListCommandTest.php
+++ b/tests/N98/Magento/Command/System/Website/ListCommandTest.php
@@ -1,23 +1,26 @@
getApplication();
$application->add(new ListCommand());
+
$command = $this->getApplication()->find('sys:website:list');
$commandTester = new CommandTester($command);
$commandTester->execute(['command' => $command->getName()]);
- self::assertMatchesRegularExpression('/Magento Websites/', $commandTester->getDisplay());
- self::assertMatchesRegularExpression('/id/', $commandTester->getDisplay());
- self::assertMatchesRegularExpression('/code/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/Magento Websites/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/id/', $commandTester->getDisplay());
+ $this->assertMatchesRegularExpression('/code/', $commandTester->getDisplay());
}
}
diff --git a/tests/N98/Magento/Command/TestCase.php b/tests/N98/Magento/Command/TestCase.php
index 7bed51752..a04cd171b 100644
--- a/tests/N98/Magento/Command/TestCase.php
+++ b/tests/N98/Magento/Command/TestCase.php
@@ -1,5 +1,7 @@
$command];
- } else {
- $input = $command;
- }
+ $input = is_string($command) ? ['command' => $command] : $command;
$hash = md5(json_encode($input, JSON_THROW_ON_ERROR));
if (!isset($this->testers[$hash])) {
@@ -97,7 +95,7 @@ protected function assertDisplayContains($command, $needle, $message = '')
{
$display = $this->getMagerunTester($command)->getDisplay();
- self::assertStringContainsString($needle, $display, $message);
+ $this->assertStringContainsString($needle, $display, $message);
}
/**
@@ -109,7 +107,7 @@ protected function assertDisplayNotContains($command, $needle, $message = '')
{
$display = $this->getMagerunTester($command)->getDisplay();
- self::assertStringNotContainsString($needle, $display, $message);
+ $this->assertStringNotContainsString($needle, $display, $message);
}
/**
@@ -121,7 +119,7 @@ protected function assertDisplayRegExp($command, $pattern, $message = '')
{
$display = $this->getMagerunTester($command)->getDisplay();
- self::assertMatchesRegularExpression($pattern, $display, $message);
+ $this->assertMatchesRegularExpression($pattern, $display, $message);
}
/**
@@ -133,17 +131,17 @@ protected function assertDisplayRegExp($command, $pattern, $message = '')
*/
protected function assertExecute($command, $message = '')
{
- $tester = $this->getMagerunTester($command);
- $status = $tester->getStatus();
+ $magerunCommandTester = $this->getMagerunTester($command);
+ $status = $magerunCommandTester->getStatus();
- if (strlen($message)) {
+ if (strlen($message) !== 0) {
$message .= "\n";
}
$message .= 'Command executes with a status code of zero';
- self::assertSame(0, $status, $message);
+ $this->assertSame(0, $status, $message);
- return $tester;
+ return $magerunCommandTester;
}
}
diff --git a/tests/N98/Magento/DbSettingsTest.php b/tests/N98/Magento/DbSettingsTest.php
index 550f3b4d1..4c990157f 100644
--- a/tests/N98/Magento/DbSettingsTest.php
+++ b/tests/N98/Magento/DbSettingsTest.php
@@ -1,5 +1,7 @@
getTestMagentoRoot() . '/app/etc/local.xml';
- $settings = new DbSettings($file);
- self::assertInstanceOf(__NAMESPACE__ . '\\DbSettings', $settings);
+ $dbSettings = new DbSettings($file);
+ $this->assertInstanceOf(__NAMESPACE__ . '\\DbSettings', $dbSettings);
}
- /**
- * @test
- */
- public function settings()
+ public function testSettings()
{
$file = __DIR__ . '/local.xml';
- $settings = new DbSettings($file);
+ $dbSettings = new DbSettings($file);
- self::assertSame('', $settings->getTablePrefix());
+ $this->assertSame('', $dbSettings->getTablePrefix());
- self::assertSame('localhost', $settings->getHost());
- self::assertNull($settings->getPort());
+ $this->assertSame('localhost', $dbSettings->getHost());
+ $this->assertNull($dbSettings->getPort());
- self::assertNull($settings->getUnixSocket());
+ $this->assertNull($dbSettings->getUnixSocket());
- self::assertSame('user', $settings->getUsername());
- self::assertSame('pass', $settings->getPassword());
+ $this->assertSame('user', $dbSettings->getUsername());
+ $this->assertSame('pass', $dbSettings->getPassword());
// DbSettings is more strict here, only using known DSN settings, see @link http://php.net/ref.pdo-mysql.connection
// minus those settings that are black-listed: dbname, charset
// "mysql:host=localhost;initStatements=SET NAMES utf8;model=mysql4;type=pdo_mysql;pdoType=;active=1;prefix="
- self::assertEquals('mysql:host=localhost', $settings->getDsn());
+ $this->assertSame('mysql:host=localhost', $dbSettings->getDsn());
}
- /**
- * @test
- */
- public function arrayAccess()
+ public function testArrayAccess()
{
$file = __DIR__ . '/local.xml';
- $settings = new DbSettings($file);
+ $dbSettings = new DbSettings($file);
- self::assertSame('user', $settings['username']);
- self::assertSame('pass', $settings['password']);
+ $this->assertSame('user', $dbSettings['username']);
+ $this->assertSame('pass', $dbSettings['password']);
// unix_socket should be NULL
- self::assertNull($settings['unix_socket']);
+ $this->assertNull($dbSettings['unix_socket']);
// it's still leaky:
// self::assertInstanceOf(SimpleXMLElement::class, $settings['pdoType']);
diff --git a/tests/N98/Magento/MagerunCommandTester.php b/tests/N98/Magento/MagerunCommandTester.php
index 2a0582bf4..4717d3065 100644
--- a/tests/N98/Magento/MagerunCommandTester.php
+++ b/tests/N98/Magento/MagerunCommandTester.php
@@ -1,5 +1,7 @@
assertArrayHasKey('command', $input);
$testCase->assertIsString($input['command']);
+
$this->commandName = $input['command'];
$this->input = $input;
}
@@ -86,7 +88,7 @@ public function getStatus()
private function getExecutedCommandTester()
{
$commandTester = $this->getCommandTester();
- if (!isset($this->status)) {
+ if ($this->status === null) {
$this->status = $commandTester->execute($this->input);
}
@@ -99,7 +101,7 @@ private function getExecutedCommandTester()
private function getCommandTester()
{
$command = null;
- if (isset($this->commandTester)) {
+ if ($this->commandTester !== null) {
return $this->commandTester;
}
diff --git a/tests/N98/Magento/ModulesTest.php b/tests/N98/Magento/ModulesTest.php
index 17b2c2492..94b7fb082 100644
--- a/tests/N98/Magento/ModulesTest.php
+++ b/tests/N98/Magento/ModulesTest.php
@@ -1,5 +1,7 @@
assertInstanceOf(__NAMESPACE__ . '\Modules', $modules);
}
- /**
- * @test
- */
- public function filteringCountAndIterating()
+ public function testFilteringCountAndIterating()
{
$modules = new Modules();
$result = $modules->filterModules(
$this->filter(),
);
- self::assertInstanceOf(__NAMESPACE__ . '\Modules', $result);
- self::assertCount(0, $result);
- self::assertCount(0, iterator_to_array($result));
+ $this->assertInstanceOf(__NAMESPACE__ . '\Modules', $result);
+ $this->assertCount(0, $result);
+ $this->assertCount(0, iterator_to_array($result));
}
- /**
- * @test
- */
- public function findInstalledModulesAndFilterThem()
+ public function testFindInstalledModulesAndFilterThem()
{
$this->getApplication()->initMagento();
$modules = new Modules();
- self::assertCount(0, $modules);
+ $this->assertCount(0, $modules);
$total = count($modules->findInstalledModules());
- self::assertGreaterThan(10, $total);
+ $this->assertGreaterThan(10, $total);
$filtered = $modules->filterModules($this->filter('codepool', 'core'));
- self::assertLessThan($total, count($filtered));
+ $this->assertLessThan($total, count($filtered));
$filtered = $modules->filterModules($this->filter('status', 'active'));
- self::assertLessThan($total, count($filtered));
+ $this->assertLessThan($total, count($filtered));
$filtered = $modules->filterModules($this->filter('vendor', 'Mage_'));
- self::assertLessThan($total, count($filtered));
+ $this->assertLessThan($total, count($filtered));
}
/**
@@ -83,6 +76,7 @@ private function filter($option = null, $value = null)
if (!array_key_exists($option, $defaultOptions)) {
throw new InvalidArgumentException(sprintf('Invalid option "%s"', $option));
}
+
$options[$option] = $value;
}
diff --git a/tests/N98/Magento/TestApplication.php b/tests/N98/Magento/TestApplication.php
index 3f4caa2ee..07bd40cb1 100644
--- a/tests/N98/Magento/TestApplication.php
+++ b/tests/N98/Magento/TestApplication.php
@@ -1,5 +1,7 @@
testCase = $testCase;
$this->varname = $varname;
$this->basename = $basename;
@@ -133,7 +136,7 @@ public function getTestMagentoRoot()
if (null === $root) {
throw new SkippedTestError(
- "Please specify environment variable $varname with path to your test magento installation!",
+ sprintf('Please specify environment variable %s with path to your test magento installation!', $varname),
);
}
diff --git a/tests/N98/Magento/TestApplicationTest.php b/tests/N98/Magento/TestApplicationTest.php
index 36943812d..5a7f89795 100644
--- a/tests/N98/Magento/TestApplicationTest.php
+++ b/tests/N98/Magento/TestApplicationTest.php
@@ -1,5 +1,7 @@
assertInstanceOf(__NAMESPACE__ . '\TestApplication', $testApplication);
}
- /**
- * @test
- */
- public function magentoTestRoot()
+ public function testMagentoTestRoot()
{
- $application = new TestApplication($this);
- $actual = $application->getTestMagentoRoot();
- self::assertIsString($actual);
- self::assertGreaterThan(10, strlen($actual));
- self::assertDirectoryExists($actual);
+ $testApplication = new TestApplication($this);
+ $actual = $testApplication->getTestMagentoRoot();
+ $this->assertIsString($actual);
+ $this->assertGreaterThan(10, strlen($actual));
+ $this->assertDirectoryExists($actual);
}
- /**
- * @test
- */
- public function getApplication()
+ public function testGetApplication()
{
- $application = new TestApplication($this);
- $actual = $application->getApplication();
- self::assertInstanceOf(__NAMESPACE__ . '\Application', $actual);
+ $testApplication = new TestApplication($this);
+ $actual = $testApplication->getApplication();
+ $this->assertInstanceOf(__NAMESPACE__ . '\Application', $actual);
}
}
diff --git a/tests/N98/Magento/_ApplicationTestComposer/FooCommand.php b/tests/N98/Magento/_ApplicationTestComposer/FooCommand.php
index d75e794ba..32243ea19 100644
--- a/tests/N98/Magento/_ApplicationTestComposer/FooCommand.php
+++ b/tests/N98/Magento/_ApplicationTestComposer/FooCommand.php
@@ -1,5 +1,7 @@
initMagento()) {
return 0;
}
+
return 0;
}
}
diff --git a/tests/N98/Magento/_ApplicationTestSrc/N98MagerunTest/AlternativeConfigModel.php b/tests/N98/Magento/_ApplicationTestSrc/N98MagerunTest/AlternativeConfigModel.php
index c3044efba..f86e20360 100644
--- a/tests/N98/Magento/_ApplicationTestSrc/N98MagerunTest/AlternativeConfigModel.php
+++ b/tests/N98/Magento/_ApplicationTestSrc/N98MagerunTest/AlternativeConfigModel.php
@@ -1,5 +1,7 @@
assertEquals($expected, ArrayFunctions::mergeArrays($a, $b));
}
/**
- * @return array
+ * @return \Iterator<(int | string), mixed>
*/
- public function mergeArraysProvider()
+ public function mergeArraysProvider(): \Iterator
{
- return [
- [[], ['Foo', 'Bar'], ['Foo', 'Bar']],
- [['Foo', 'Bar'], [], ['Foo', 'Bar']],
- [['Foo'], ['Bar'], ['Foo', 'Bar']],
- [['Foo', ['Bar']], ['Bar'], ['Foo', ['Bar'], 'Bar']],
- /**
- * Override Bar->Bar
- */
- [['Foo', 'Bar' => ['Bar' => 1]], ['Bar' => ['Bar' => 2]], ['Foo', 'Bar' => ['Bar' => 2]]],
- ];
+ yield [[], ['Foo', 'Bar'], ['Foo', 'Bar']];
+ yield [['Foo', 'Bar'], [], ['Foo', 'Bar']];
+ yield [['Foo'], ['Bar'], ['Foo', 'Bar']];
+ yield [['Foo', ['Bar']], ['Bar'], ['Foo', ['Bar'], 'Bar']];
+ /**
+ * Override Bar->Bar
+ */
+ yield [['Foo', 'Bar' => ['Bar' => 1]], ['Bar' => ['Bar' => 2]], ['Foo', 'Bar' => ['Bar' => 2]]];
}
- /**
- * @test
- */
- public function columnOrderArrayTable()
+ public function testColumnOrderArrayTable()
{
$headers = ['foo', 'bar', 'baz'];
$table = [['foo' => 'A1', 'baz' => 'C1', 'B1', 'D1'], ['A2', 'B2', 'C2', 'D2'], [null, null, null, 'foo' => 'A3']];
$actual = ArrayFunctions::columnOrderArrayTable($headers, $table);
- self::assertIsArray($actual);
- self::assertCount(count($table), $actual);
+ $this->assertIsArray($actual);
+ $this->assertCount(count($table), $actual);
$expected = [['foo' => 'A1', 'bar' => 'B1', 'baz' => 'C1', 'D1'], ['foo' => 'A2', 'bar' => 'B2', 'baz' => 'C2', 'D2'], ['foo' => 'A3', 'bar' => null, 'baz' => null, null]];
- self::assertEquals($expected, $actual);
- self::assertSame($expected, $actual);
+ $this->assertEquals($expected, $actual);
+ $this->assertSame($expected, $actual);
}
/**
- * @test
* @dataProvider provideColumnOrderings
*/
- public function columnOrder($columns, $array, $expected)
+ public function testColumnOrder($columns, $array, $expected)
{
$actual = ArrayFunctions::columnOrder($columns, $array);
- self::assertIsArray($actual);
- self::assertEquals($expected, $actual);
- self::assertSame($expected, $actual);
+ $this->assertIsArray($actual);
+ $this->assertEquals($expected, $actual);
+ $this->assertSame($expected, $actual);
}
/**
* @see columnOrder
- * @return array
+ * @return \Iterator<(int | string), mixed>
*/
- public function provideColumnOrderings()
+ public function provideColumnOrderings(): \Iterator
{
- return [[['foo', 'bar', 'baz'], ['A', 'B', 'C'], ['foo' => 'A', 'bar' => 'B', 'baz' => 'C']], [['foo', 'bar', 'baz'], ['A', 'B', 'C', 'D'], ['foo' => 'A', 'bar' => 'B', 'baz' => 'C', 'D']], [['foo', 'bar', 'baz'], ['A', 'B', 'C'], ['foo' => 'A', 'bar' => 'B', 'baz' => 'C']], [['foo', 'bar', 'baz'], ['buz' => 'D', 'A', 'B', 'C'], ['foo' => 'A', 'bar' => 'B', 'baz' => 'C', 'buz' => 'D']], [['foo', 'bar', 'baz'], ['foo' => 'A', 'baz' => 'C', 'B', 'D'], ['foo' => 'A', 'bar' => 'B', 'baz' => 'C', 'D']], [['foo', 'bar', 'baz'], ['foo' => 'A', 'baz' => 'C'], ['foo' => 'A', 'bar' => null, 'baz' => 'C']]];
+ yield [['foo', 'bar', 'baz'], ['A', 'B', 'C'], ['foo' => 'A', 'bar' => 'B', 'baz' => 'C']];
+ yield [['foo', 'bar', 'baz'], ['A', 'B', 'C', 'D'], ['foo' => 'A', 'bar' => 'B', 'baz' => 'C', 'D']];
+ yield [['foo', 'bar', 'baz'], ['A', 'B', 'C'], ['foo' => 'A', 'bar' => 'B', 'baz' => 'C']];
+ yield [['foo', 'bar', 'baz'], ['buz' => 'D', 'A', 'B', 'C'], ['foo' => 'A', 'bar' => 'B', 'baz' => 'C', 'buz' => 'D']];
+ yield [['foo', 'bar', 'baz'], ['foo' => 'A', 'baz' => 'C', 'B', 'D'], ['foo' => 'A', 'bar' => 'B', 'baz' => 'C', 'D']];
+ yield [['foo', 'bar', 'baz'], ['foo' => 'A', 'baz' => 'C'], ['foo' => 'A', 'bar' => null, 'baz' => 'C']];
}
/**
* @see matrixFilterByValue
* @see matrixFilterStartsWith
- * @return array
+ * @return \Iterator<(int | string), mixed>
*/
- public function provideMatrix()
+ public function provideMatrix(): \Iterator
{
- return [[[['foo' => 'bar'], ['foo' => 'baz'], ['foo' => 'zaz']]]];
+ yield [[['foo' => 'bar'], ['foo' => 'baz'], ['foo' => 'zaz']]];
}
/**
- * @test
* @dataProvider provideMatrix
*/
- public function matrixFilterByValue(array $matrix)
+ public function testMatrixFilterByValue(array $matrix)
{
- self::assertCount(3, $matrix);
+ $this->assertCount(3, $matrix);
$filtered = ArrayFunctions::matrixFilterByValue($matrix, 'foo', 'bar');
- self::assertCount(1, $filtered);
+ $this->assertCount(1, $filtered);
}
/**
- * @test
* @dataProvider provideMatrix
*/
- public function matrixFilterStartsWith(array $matrix)
+ public function testMatrixFilterStartsWith(array $matrix)
{
- self::assertCount(3, $matrix);
+ $this->assertCount(3, $matrix);
$filtered = ArrayFunctions::matrixFilterStartswith($matrix, 'foo', 'ba');
- self::assertCount(2, $filtered);
+ $this->assertCount(2, $filtered);
}
}
diff --git a/tests/N98/Util/AutoloadHandlerTest.php b/tests/N98/Util/AutoloadHandlerTest.php
index 39d1c2765..591852e0d 100644
--- a/tests/N98/Util/AutoloadHandlerTest.php
+++ b/tests/N98/Util/AutoloadHandlerTest.php
@@ -1,5 +1,7 @@
create(null);
- self::assertInstanceOf(__NAMESPACE__ . '\AutoloadHandler', $handler);
- self::assertIsCallable($handler);
+ $this->assertInstanceOf(__NAMESPACE__ . '\AutoloadHandler', $handler);
+ $this->assertIsCallable($handler);
}
- /**
- * @test
- */
- public function noRegistrationOnCreation(): never
+ public function testNoRegistrationOnCreation(): never
{
$this->expectException(BadMethodCallException::class);
$this->expectExceptionMessage('Autoload callback is not callable');
@@ -52,11 +48,11 @@ public function noRegistrationOnCreation(): never
$handler = $this->create(null, AutoloadHandler::NO_AUTO_REGISTER);
$handler->disable(); // assertions require a disabled handler b/c of exceptions
- self::assertNotContains($handler, spl_autoload_functions());
- self::assertFalse($handler->__invoke('test'));
+ $this->assertNotContains($handler, spl_autoload_functions());
+ $this->assertFalse($handler->__invoke('test'));
$handler->register();
$actual = in_array($handler, spl_autoload_functions());
- self::assertTrue($actual);
+ $this->assertTrue($actual);
$handler->enable();
$handler->__invoke('test');
@@ -71,10 +67,7 @@ private function create($implementation, $flags = null)
return $autoloadHandler;
}
- /**
- * @test
- */
- public function registrationAndDeregistration()
+ public function testRegistrationAndDeregistration()
{
$calls = (object) ['retval' => true];
$assertAble = function ($className) use (&$calls) {
@@ -85,18 +78,15 @@ public function registrationAndDeregistration()
};
$handler = $this->create($assertAble);
- self::assertTrue($handler->isEnabled());
- self::assertTrue($handler->__invoke('Fake'));
+ $this->assertTrue($handler->isEnabled());
+ $this->assertTrue($handler->__invoke('Fake'));
$handler->unregister();
- self::assertFalse($handler->__invoke('Fake'));
- self::assertEquals(1, $calls->count['Fake']);
+ $this->assertFalse($handler->__invoke('Fake'));
+ $this->assertSame(1, $calls->count['Fake']);
}
- /**
- * @test
- */
- public function changingCallback()
+ public function testChangingCallback()
{
$calls = (object) ['retval' => true];
$assertAble = function ($className) use (&$calls) {
@@ -107,55 +97,46 @@ public function changingCallback()
};
$handler = $this->create(null, AutoloadHandler::NO_EXCEPTION);
- self::assertFalse($handler->__invoke('Test'));
- self::assertObjectNotHasProperty('count', $calls);
+ $this->assertFalse($handler->__invoke('Test'));
+ $this->assertObjectNotHasProperty('count', $calls);
$handler->setCallback($assertAble);
- self::assertTrue($handler->__invoke('Test'));
- self::assertEquals(1, $calls->count['Test']);
+ $this->assertTrue($handler->__invoke('Test'));
+ $this->assertSame(1, $calls->count['Test']);
$handler->setCallback(null);
- self::assertFalse($handler->__invoke('Test'));
- self::assertEquals(1, $calls->count['Test']);
+ $this->assertFalse($handler->__invoke('Test'));
+ $this->assertSame(1, $calls->count['Test']);
}
- /**
- * @test
- */
- public function disablingAndEnabling(): never
+ public function testDisablingAndEnabling(): never
{
$handler = $this->create(null);
$handler->setEnabled(false);
- self::assertFalse($handler->__invoke('Test'));
+ $this->assertFalse($handler->__invoke('Test'));
$handler->setEnabled(true);
$this->expectException(BadMethodCallException::class);
- self::assertFalse($handler->__invoke('Test'));
+ $this->assertFalse($handler->__invoke('Test'));
self::fail('An expected exception has not been thrown');
}
- /**
- * @test
- */
- public function callbackSelfReference()
+ public function testCallbackSelfReference()
{
$testClass = 'MyOf' . random_int(1000, 9999) . 'Fake' . random_int(1000, 9999) . 'Class';
$test = $this;
- $handler = $this->create(function ($className) use (&$handler, $test, $testClass) {
+ $handler = $this->create(function ($className) use (&$handler, $test, $testClass): void {
/** @var $handler AutoloadHandler */
- $test->assertEquals($testClass, $className);
+ $test->assertSame($testClass, $className);
$handler->disable();
});
$actual = class_exists($testClass);
$isEnabled = $handler->isEnabled();
- self::assertEquals(1, self::getCount());
- self::assertFalse($isEnabled);
- self::assertFalse($actual);
+ $this->assertSame(1, self::getCount());
+ $this->assertFalse($isEnabled);
+ $this->assertFalse($actual);
}
- /**
- * @test
- */
- public function cleanupCallback()
+ public function testCleanupCallback()
{
$calls = (object) ['retval' => true];
$assertAble = function ($className) use (&$calls) {
@@ -168,10 +149,10 @@ public function cleanupCallback()
$handler = $this->create($assertAble, AutoloadHandler::NO_EXCEPTION);
$cleanup = $handler->getCleanupCallback();
$actual = class_exists('Test');
- self::assertFalse($actual);
- self::assertContains($handler, spl_autoload_functions(), 'before cleanup');
+ $this->assertFalse($actual);
+ $this->assertContains($handler, spl_autoload_functions(), 'before cleanup');
$cleanup();
- self::assertNotContains($handler, spl_autoload_functions(), 'after cleanup');
+ $this->assertNotContains($handler, spl_autoload_functions(), 'after cleanup');
// calling cleanup again must not do any warnings etc.
$cleanup();
}
diff --git a/tests/N98/Util/AutoloadRestorerTest.php b/tests/N98/Util/AutoloadRestorerTest.php
index d27140f0c..3227f866f 100644
--- a/tests/N98/Util/AutoloadRestorerTest.php
+++ b/tests/N98/Util/AutoloadRestorerTest.php
@@ -1,5 +1,7 @@
assertInstanceOf(AutoloadRestorer::class, $autoloadRestorer);
}
- /**
- * @test
- */
- public function restoration()
+ public function testRestoration()
{
- $callbackStub = function () {};
+ $callbackStub = function (): void {};
- self::assertTrue(spl_autoload_register($callbackStub));
+ $this->assertTrue(spl_autoload_register($callbackStub));
$autoloadRestorer = new AutoloadRestorer();
- self::assertContains($callbackStub, spl_autoload_functions());
+ $this->assertContains($callbackStub, spl_autoload_functions());
- self::assertTrue(spl_autoload_unregister($callbackStub));
+ $this->assertTrue(spl_autoload_unregister($callbackStub));
- self::assertNotContains($callbackStub, spl_autoload_functions());
+ $this->assertNotContains($callbackStub, spl_autoload_functions());
$autoloadRestorer->restore();
- self::assertContains($callbackStub, spl_autoload_functions());
+ $this->assertContains($callbackStub, spl_autoload_functions());
}
}
diff --git a/tests/N98/Util/BinaryStringTest.php b/tests/N98/Util/BinaryStringTest.php
index 24dc4d8f9..abf54e964 100644
--- a/tests/N98/Util/BinaryStringTest.php
+++ b/tests/N98/Util/BinaryStringTest.php
@@ -1,5 +1,7 @@
assertEqualsCanonicalizing($expected, BinaryString::trimExplodeEmpty($delimiter, $string));
}
/**
- * @return array
+ * @return \Iterator<(int | string), mixed>
*/
- public function trimExplodeEmptyProvider()
+ public function trimExplodeEmptyProvider(): \Iterator
{
- return [[',', 'Foo,Bar', ['Foo', 'Bar']], ['#', ' Foo# Bar', ['Foo', 'Bar']], [',', ',,Foo, Bar,,', ['Foo', 'Bar']]];
+ yield [',', 'Foo,Bar', ['Foo', 'Bar']];
+ yield ['#', ' Foo# Bar', ['Foo', 'Bar']];
+ yield [',', ',,Foo, Bar,,', ['Foo', 'Bar']];
}
}
diff --git a/tests/N98/Util/Console/Helper/DatabaseHelperTest.php b/tests/N98/Util/Console/Helper/DatabaseHelperTest.php
index 27855700a..bba9623e9 100644
--- a/tests/N98/Util/Console/Helper/DatabaseHelperTest.php
+++ b/tests/N98/Util/Console/Helper/DatabaseHelperTest.php
@@ -1,5 +1,7 @@
getApplication()->find('db:info');
$command->getHelperSet()->setCommand($command);
@@ -34,56 +36,44 @@ protected function getHelper()
public function testHelperInstance()
{
- self::assertInstanceOf(DatabaseHelper::class, $this->getHelper());
+ $this->assertInstanceOf(DatabaseHelper::class, $this->getHelper());
}
- /**
- * @test
- */
- public function getConnection()
+ public function testGetConnection()
{
- self::assertInstanceOf(PDO::class, $this->getHelper()->getConnection());
+ $this->assertInstanceOf(PDO::class, $this->getHelper()->getConnection());
}
- /**
- * @test
- */
- public function dsn()
+ public function testDsn()
{
- self::assertStringStartsWith('mysql:', $this->getHelper()->dsn());
+ $this->assertStringStartsWith('mysql:', $this->getHelper()->dsn());
}
- /**
- * @test
- */
- public function mysqlUserHasPrivilege()
+ public function testMysqlUserHasPrivilege()
{
- self::assertTrue($this->getHelper()->mysqlUserHasPrivilege('SELECT'));
+ $this->assertTrue($this->getHelper()->mysqlUserHasPrivilege('SELECT'));
}
- /**
- * @test
- */
- public function getMysqlVariableValue()
+ public function testGetMysqlVariableValue()
{
- $helper = $this->getHelper();
+ $databaseHelper = $this->getHelper();
// verify (complex) return value with existing global variable
- $actual = $helper->getMysqlVariableValue('version');
+ $actual = $databaseHelper->getMysqlVariableValue('version');
- self::assertIsArray($actual);
- self::assertCount(1, $actual);
+ $this->assertIsArray($actual);
+ $this->assertCount(1, $actual);
$key = '@@version';
- self::assertArrayHasKey($key, $actual);
- self::assertIsString($actual[$key]);
+ $this->assertArrayHasKey($key, $actual);
+ $this->assertIsString($actual[$key]);
// quoted
- $actual = $helper->getMysqlVariableValue('`version`');
- self::assertEquals('@@`version`', key($actual));
+ $actual = $databaseHelper->getMysqlVariableValue('`version`');
+ $this->assertSame('@@`version`', key($actual));
// non-existent global variable
try {
- $helper->getMysqlVariableValue('nonexistent');
+ $databaseHelper->getMysqlVariableValue('nonexistent');
self::fail('An expected exception has not been thrown');
} catch (RuntimeException $runtimeException) {
// do nothing -> We need to check different strings for old MySQL and MariaDB servers
@@ -91,25 +81,22 @@ public function getMysqlVariableValue()
}
}
- /**
- * @test
- */
- public function getMysqlVariable()
+ public function testGetMysqlVariable()
{
- $helper = $this->getHelper();
+ $databaseHelper = $this->getHelper();
// behaviour with existing global variable
- $actual = $helper->getMysqlVariable('version');
- self::assertIsString($actual);
+ $actual = $databaseHelper->getMysqlVariable('version');
+ $this->assertIsString($actual);
// behavior with existent session variable (INTEGER)
- $helper->getConnection()->query('SET @existent = 14;');
- $actual = $helper->getMysqlVariable('existent', '@');
- self::assertEquals(14, $actual);
+ $databaseHelper->getConnection()->query('SET @existent = 14;');
+ $actual = $databaseHelper->getMysqlVariable('existent', '@');
+ $this->assertSame(14, $actual);
// behavior with non-existent session variable
- $actual = $helper->getMysqlVariable('nonexistent', '@');
- self::assertNull($actual);
+ $actual = $databaseHelper->getMysqlVariable('nonexistent', '@');
+ $this->assertNull($actual);
// behavior with non-existent global variable
/*
@@ -127,29 +114,23 @@ public function getMysqlVariable()
// invalid variable type
try {
- $helper->getMysqlVariable('nonexistent', '@@@');
+ $databaseHelper->getMysqlVariable('nonexistent', '@@@');
self::fail('An expected Exception has not been thrown');
} catch (InvalidArgumentException $invalidArgumentException) {
// test against the mysql error message
- self::assertEquals(
- 'Invalid mysql variable type "@@@", must be "@@" (system) or "@" (session)',
- $invalidArgumentException->getMessage(),
- );
+ $this->assertSame('Invalid mysql variable type "@@@", must be "@@" (system) or "@" (session)', $invalidArgumentException->getMessage());
}
}
- /**
- * @test
- */
- public function getTables()
+ public function testGetTables()
{
- $helper = $this->getHelper();
+ $databaseHelper = $this->getHelper();
- $tables = $helper->getTables();
- self::assertIsArray($tables);
- self::assertContains('admin_user', $tables);
+ $tables = $databaseHelper->getTables();
+ $this->assertIsArray($tables);
+ $this->assertContains('admin_user', $tables);
- $dbSettings = $helper->getDbSettings();
+ $dbSettings = $databaseHelper->getDbSettings();
$reflectionObject = new ReflectionObject($dbSettings);
$reflectionProperty = $reflectionObject->getProperty('config');
$reflectionProperty->setAccessible(true);
@@ -157,7 +138,7 @@ public function getTables()
$config = $reflectionProperty->getValue($dbSettings);
$previous = $config['prefix'];
- $this->tearDownRestore[] = function () use ($reflectionProperty, $dbSettings, $previous) {
+ $this->tearDownRestore[] = function () use ($reflectionProperty, $dbSettings, $previous): void {
$config = [];
$config['prefix'] = $previous;
$reflectionProperty->setValue($dbSettings, $config);
@@ -166,27 +147,24 @@ public function getTables()
$config['prefix'] = $previous . 'core_';
$reflectionProperty->setValue($dbSettings, $config);
- $tables = $helper->getTables(null); // default value should be null-able and is false
- self::assertIsArray($tables);
- self::assertNotContains('admin_user', $tables);
- self::assertContains('core_store', $tables);
- self::assertContains('core_website', $tables);
-
- $tables = $helper->getTables(true);
- self::assertIsArray($tables);
- self::assertNotContains('admin_user', $tables);
- self::assertContains('store', $tables);
- self::assertContains('website', $tables);
+ $tables = $databaseHelper->getTables(null); // default value should be null-able and is false
+ $this->assertIsArray($tables);
+ $this->assertNotContains('admin_user', $tables);
+ $this->assertContains('core_store', $tables);
+ $this->assertContains('core_website', $tables);
+
+ $tables = $databaseHelper->getTables(true);
+ $this->assertIsArray($tables);
+ $this->assertNotContains('admin_user', $tables);
+ $this->assertContains('store', $tables);
+ $this->assertContains('website', $tables);
}
- /**
- * @test
- */
- public function resolveTables()
+ public function testResolveTables()
{
$tables = $this->getHelper()->resolveTables(['catalog_*']);
- self::assertContains('catalog_product_entity', $tables);
- self::assertNotContains('catalogrule', $tables);
+ $this->assertContains('catalog_product_entity', $tables);
+ $this->assertNotContains('catalogrule', $tables);
$definitions = ['wild_1' => ['tables' => ['catalog_*']], 'wild_2' => ['tables' => ['core_config_dat?']], 'dataflow' => ['tables' => ['dataflow_batch_import', 'dataflow_batch_export']]];
@@ -194,10 +172,10 @@ public function resolveTables()
['@wild_1', '@wild_2', '@dataflow'],
$definitions,
);
- self::assertContains('catalog_product_entity', $tables);
- self::assertContains('core_config_data', $tables);
- self::assertContains('dataflow_batch_import', $tables);
- self::assertNotContains('catalogrule', $tables);
+ $this->assertContains('catalog_product_entity', $tables);
+ $this->assertContains('core_config_data', $tables);
+ $this->assertContains('dataflow_batch_import', $tables);
+ $this->assertNotContains('catalogrule', $tables);
}
/**
@@ -209,6 +187,7 @@ protected function tearDown(): void
foreach ($this->tearDownRestore as $singleTearDownRestore) {
$singleTearDownRestore();
}
+
$this->tearDownRestore = null;
parent::tearDown();
diff --git a/tests/N98/Util/Console/Helper/IoHelperTest.php b/tests/N98/Util/Console/Helper/IoHelperTest.php
index 28a79c498..3b20fe118 100644
--- a/tests/N98/Util/Console/Helper/IoHelperTest.php
+++ b/tests/N98/Util/Console/Helper/IoHelperTest.php
@@ -1,5 +1,7 @@
getOutput());
+ $this->assertInstanceOf(IoHelper::class, $ioHelper);
+ $this->assertInstanceOf(HelperInterface::class, $ioHelper);
+ $this->assertNull($ioHelper->getOutput());
- self::assertSame('io', $ioHelper->getName());
+ $this->assertSame('io', $ioHelper->getName());
}
}
diff --git a/tests/N98/Util/Console/Helper/MagentoHelper.php b/tests/N98/Util/Console/Helper/MagentoHelper.php
index 521a0c320..3c425d072 100644
--- a/tests/N98/Util/Console/Helper/MagentoHelper.php
+++ b/tests/N98/Util/Console/Helper/MagentoHelper.php
@@ -1,5 +1,7 @@
getHelper());
}
- /**
- * @test
- */
- public function detectMagentoInStandardFolder()
+ public function testDetectMagentoInStandardFolder()
{
vfsStream::setup('root');
vfsStream::create(
['app' => ['Mage.php' => '']],
);
- $helper = $this->getHelper();
- $helper->detect(vfsStream::url('root'), []);
+ $magentoHelper = $this->getHelper();
+ $magentoHelper->detect(vfsStream::url('root'), []);
- self::assertEquals(vfsStream::url('root'), $helper->getRootFolder());
+ self::assertSame(vfsStream::url('root'), $magentoHelper->getRootFolder());
}
- /**
- * @test
- */
- public function detectMagentoInHtdocsSubfolder()
+ public function testDetectMagentoInHtdocsSubfolder()
{
vfsStream::setup('root');
vfsStream::create(
['htdocs' => ['app' => ['Mage.php' => '']]],
);
- $helper = $this->getHelper();
+ $magentoHelper = $this->getHelper();
// vfs cannot resolve relative path so we do 'root/htdocs' etc.
- $helper->detect(
+ $magentoHelper->detect(
vfsStream::url('root'),
[vfsStream::url('root/www'), vfsStream::url('root/public'), vfsStream::url('root/htdocs')],
);
- self::assertEquals(vfsStream::url('root/htdocs'), $helper->getRootFolder());
+ self::assertSame(vfsStream::url('root/htdocs'), $magentoHelper->getRootFolder());
}
- /**
- * @test
- */
- public function detectMagentoFailed()
+ public function testDetectMagentoFailed()
{
vfsStream::setup('root');
vfsStream::create(
['htdocs' => []],
);
- $helper = $this->getHelper();
+ $magentoHelper = $this->getHelper();
// vfs cannot resolve relative path so we do 'root/htdocs' etc.
- $helper->detect(
+ $magentoHelper->detect(
vfsStream::url('root'),
);
- self::assertNull($helper->getRootFolder());
+ self::assertNull($magentoHelper->getRootFolder());
}
- /**
- * @test
- */
- public function detectMagentoInModmanInfrastructure()
+ public function testDetectMagentoInModmanInfrastructure()
{
vfsStream::setup('root');
vfsStream::create(
['.basedir' => 'root/htdocs/magento_root', 'htdocs' => ['magento_root' => ['app' => ['Mage.php' => '']]]],
);
- $helper = $this->getHelper();
+ $magentoHelper = $this->getHelper();
// vfs cannot resolve relative path so we do 'root/htdocs' etc.
- $helper->detect(
+ $magentoHelper->detect(
vfsStream::url('root'),
);
// Verify if this could be checked with more elegance
- self::assertEquals(vfsStream::url('root/../root/htdocs/magento_root'), $helper->getRootFolder());
+ self::assertSame(vfsStream::url('root/../root/htdocs/magento_root'), $magentoHelper->getRootFolder());
}
}
diff --git a/tests/N98/Util/Console/Helper/Table/Renderer/RenderFactoryTest.php b/tests/N98/Util/Console/Helper/Table/Renderer/RenderFactoryTest.php
index 6c6e17811..1a69abced 100644
--- a/tests/N98/Util/Console/Helper/Table/Renderer/RenderFactoryTest.php
+++ b/tests/N98/Util/Console/Helper/Table/Renderer/RenderFactoryTest.php
@@ -1,10 +1,12 @@
create('csv');
- self::assertInstanceOf(CsvRenderer::class, $csv);
+ $this->assertInstanceOf(CsvRenderer::class, $csv);
$json = $rendererFactory->create('json');
- self::assertInstanceOf(JsonRenderer::class, $json);
+ $this->assertInstanceOf(JsonRenderer::class, $json);
$xml = $rendererFactory->create('xml');
- self::assertInstanceOf(XmlRenderer::class, $xml);
+ $this->assertInstanceOf(XmlRenderer::class, $xml);
$invalidFormat = $rendererFactory->create('invalid_format');
- self::assertNull($invalidFormat);
+ $this->assertNull($invalidFormat);
}
}
diff --git a/tests/N98/Util/Console/Helper/Table/Renderer/TestCase.php b/tests/N98/Util/Console/Helper/Table/Renderer/TestCase.php
index 6b8d18f41..0b1667638 100644
--- a/tests/N98/Util/Console/Helper/Table/Renderer/TestCase.php
+++ b/tests/N98/Util/Console/Helper/Table/Renderer/TestCase.php
@@ -1,5 +1,7 @@
assertInstanceOf(__NAMESPACE__ . '\\TextRenderer', $renderer);
$rendererFactory = new RendererFactory();
$renderer = $rendererFactory->create('text');
- self::assertInstanceOf(__NAMESPACE__ . '\\TextRenderer', $renderer);
+ $this->assertInstanceOf(__NAMESPACE__ . '\\TextRenderer', $renderer);
}
- /**
- * @test
- */
- public function rendering()
+ public function testRendering()
{
$textRenderer = new TextRenderer();
$streamOutput = new StreamOutput(fopen('php://memory', 'wb', false));
@@ -55,6 +51,6 @@ public function rendering()
$textRenderer->render($streamOutput, $rows);
- self::assertEquals($expected, $this->getOutputBuffer($streamOutput));
+ $this->assertSame($expected, $this->getOutputBuffer($streamOutput));
}
}
diff --git a/tests/N98/Util/Console/Helper/Table/Renderer/XmlRendererTest.php b/tests/N98/Util/Console/Helper/Table/Renderer/XmlRendererTest.php
index 4d770675d..32aea7ae6 100644
--- a/tests/N98/Util/Console/Helper/Table/Renderer/XmlRendererTest.php
+++ b/tests/N98/Util/Console/Helper/Table/Renderer/XmlRendererTest.php
@@ -1,5 +1,7 @@
assertInstanceOf(__NAMESPACE__ . '\\XmlRenderer', $renderer);
$rendererFactory = new RendererFactory();
$renderer = $rendererFactory->create('xml');
- self::assertInstanceOf(__NAMESPACE__ . '\\XmlRenderer', $renderer);
+ $this->assertInstanceOf(__NAMESPACE__ . '\\XmlRenderer', $renderer);
}
/**
- * @return array
+ * @return \Iterator<(int | string), mixed>
* @see tableRendering
*/
- public function provideTables()
+ public function provideTables(): \Iterator
{
- return [[[['column' => 'Doors wide > open'], ['column' => "null \0 bytes FTW"]], '
+ yield [[['column' => 'Doors wide > open'], ['column' => "null \0 bytes FTW"]], '
@@ -53,10 +52,12 @@ public function provideTables()
bnVsbCAAIGJ5dGVzIEZUVw==
-
'], [[], '
+'];
+ yield [[], '
'], [[['Column1' => 'Value A1', 'Column2' => 'A2 is another value that there is'], [1, "multi\nline\nftw"], ['C1 cell here!', new SimpleXMLElement('PHP Magic->toString() test')]], '
+'];
+ yield [[['Column1' => 'Value A1', 'Column2' => 'A2 is another value that there is'], [1, "multi\nline\nftw"], ['C1 cell here!', new SimpleXMLElement('PHP Magic->toString() test')]], '
@@ -76,7 +77,8 @@ public function provideTables()
C1 cell here!
PHP Magic->toString() test
-
'], [[["\x00" => 'foo']], '
+'];
+ yield [[["\x00" => 'foo']], '
@@ -84,7 +86,8 @@ public function provideTables()
<_>foo
-
'], [[['foo' => 'bar'], ['baz', 'buz' => 'here']], '
+'];
+ yield [[['foo' => 'bar'], ['baz', 'buz' => 'here']], '
@@ -96,13 +99,10 @@ public function provideTables()
baz
here
-
']];
+'];
}
- /**
- * @test
- */
- public function invalidName()
+ public function testInvalidName()
{
$this->expectException(DOMException::class);
$this->expectExceptionMessage("Invalid name '0'");
@@ -111,10 +111,7 @@ public function invalidName()
$xmlRenderer->render($nullOutput, [['foo']]);
}
- /**
- * @test
- */
- public function invalidEncoding()
+ public function testInvalidEncoding()
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage("Encoding error, only US-ASCII and UTF-8 supported, can not process '");
@@ -124,16 +121,15 @@ public function invalidEncoding()
}
/**
- * @test
* @dataProvider provideTables
*/
- public function tableRendering($rows, $expected)
+ public function testTableRendering($rows, $expected)
{
$xmlRenderer = new XmlRenderer();
$streamOutput = new StreamOutput(fopen('php://memory', 'wb', false));
$xmlRenderer->render($streamOutput, $rows);
- self::assertEquals($expected . "\n", $this->getOutputBuffer($streamOutput));
+ $this->assertSame($expected . "\n", $this->getOutputBuffer($streamOutput));
}
}
diff --git a/tests/N98/Util/DateTimeTest.php b/tests/N98/Util/DateTimeTest.php
index 752e0c143..bbf7928db 100644
--- a/tests/N98/Util/DateTimeTest.php
+++ b/tests/N98/Util/DateTimeTest.php
@@ -1,31 +1,36 @@
getDifferenceAsString($time1, $time2));
+ $this->assertSame($expected, $dateTime->getDifferenceAsString($time1, $time2));
}
/**
- * @return array
+ * @return \Iterator<(int | string), mixed>
*/
- public static function getDifferenceAsStringProvider()
+ public static function getDifferenceAsStringProvider(): \Iterator
{
- return [[new DateTime('2013-12-01', new DateTimeZone('UTC')), new DateTime('2013-12-01', new DateTimeZone('UTC')), '0'], [new DateTime('2013-12-01 00:00:00', new DateTimeZone('UTC')), new DateTime('2013-12-01 00:00:01', new DateTimeZone('UTC')), '1s'], [new DateTime('2013-12-01 00:00:00', new DateTimeZone('UTC')), new DateTime('2013-12-01 00:01:01', new DateTimeZone('UTC')), '1m 1s'], [new DateTime('2013-12-01 00:00:00', new DateTimeZone('UTC')), new DateTime('2013-12-01 01:01:01', new DateTimeZone('UTC')), '1h 1m 1s'], [new DateTime('2013-12-01 00:00:00', new DateTimeZone('UTC')), new DateTime('2013-12-02 01:01:01', new DateTimeZone('UTC')), '1d 1h 1m 1s'], [new DateTime('2013-12-01 00:00:00', new DateTimeZone('UTC')), new DateTime('2014-01-02 01:01:01', new DateTimeZone('UTC')), '1M 1d 1h 1m 1s'], [new DateTime('2013-12-01 00:00:00', new DateTimeZone('UTC')), new DateTime('2015-01-02 01:01:01', new DateTimeZone('UTC')), '1Y 1M 1d 1h 1m 1s']];
+ yield [new DateTime('2013-12-01', new DateTimeZone('UTC')), new DateTime('2013-12-01', new DateTimeZone('UTC')), '0'];
+ yield [new DateTime('2013-12-01 00:00:00', new DateTimeZone('UTC')), new DateTime('2013-12-01 00:00:01', new DateTimeZone('UTC')), '1s'];
+ yield [new DateTime('2013-12-01 00:00:00', new DateTimeZone('UTC')), new DateTime('2013-12-01 00:01:01', new DateTimeZone('UTC')), '1m 1s'];
+ yield [new DateTime('2013-12-01 00:00:00', new DateTimeZone('UTC')), new DateTime('2013-12-01 01:01:01', new DateTimeZone('UTC')), '1h 1m 1s'];
+ yield [new DateTime('2013-12-01 00:00:00', new DateTimeZone('UTC')), new DateTime('2013-12-02 01:01:01', new DateTimeZone('UTC')), '1d 1h 1m 1s'];
+ yield [new DateTime('2013-12-01 00:00:00', new DateTimeZone('UTC')), new DateTime('2014-01-02 01:01:01', new DateTimeZone('UTC')), '1M 1d 1h 1m 1s'];
+ yield [new DateTime('2013-12-01 00:00:00', new DateTimeZone('UTC')), new DateTime('2015-01-02 01:01:01', new DateTimeZone('UTC')), '1Y 1M 1d 1h 1m 1s'];
}
}
diff --git a/tests/N98/Util/ExecTest.php b/tests/N98/Util/ExecTest.php
index 06896f378..c31de2d62 100644
--- a/tests/N98/Util/ExecTest.php
+++ b/tests/N98/Util/ExecTest.php
@@ -1,5 +1,7 @@
assertSame(0, $actual);
}
- /**
- * @test
- */
- public function fullParameters()
+ public function testFullParameters()
{
Exec::run('echo test', $commandOutput, $returnCode);
- self::assertEquals(Exec::CODE_CLEAN_EXIT, $returnCode);
- self::assertStringStartsWith('test', $commandOutput);
+ $this->assertSame(Exec::CODE_CLEAN_EXIT, $returnCode);
+ $this->assertStringStartsWith('test', $commandOutput);
}
- /**
- * @test
- */
- public function exception()
+ public function testException()
{
$this->expectException(RuntimeException::class);
Exec::run('foobar');
diff --git a/tests/N98/Util/FilesystemTest.php b/tests/N98/Util/FilesystemTest.php
index bbe3e3a42..7202a9a6c 100644
--- a/tests/N98/Util/FilesystemTest.php
+++ b/tests/N98/Util/FilesystemTest.php
@@ -1,5 +1,7 @@
* @covers N98\Util\Filesystem
*/
-class FilesystemTest extends TestCase
+final class FilesystemTest extends TestCase
{
/**
* @var Filesystem
*/
- protected $fileSystem;
+ private $filesystem;
protected function setUp(): void
{
- $this->fileSystem = new Filesystem();
+ $this->filesystem = new Filesystem();
}
public function testRecursiveCopy()
@@ -45,9 +47,9 @@ public function testRecursiveCopy()
touch($file1);
touch($file2);
- $this->fileSystem->recursiveCopy($basePath, $dest);
- self::assertFileExists($dest . '/folder1/file1.txt');
- self::assertFileExists($dest . '/folder2/file2.txt');
+ $this->filesystem->recursiveCopy($basePath, $dest);
+ $this->assertFileExists($dest . '/folder1/file1.txt');
+ $this->assertFileExists($dest . '/folder2/file2.txt');
//cleanup
unlink($file1);
@@ -62,14 +64,15 @@ public function testRecursiveCopy()
rmdir($dest . '/folder2');
rmdir($dest);
- self::assertFileDoesNotExist($dest . '/folder1/file1.txt');
- self::assertFileDoesNotExist($dest);
+ $this->assertFileDoesNotExist($dest . '/folder1/file1.txt');
+ $this->assertFileDoesNotExist($dest);
if (!is_dir($tmp . '/a')) {
mkdir($tmp . '/a');
}
+
touch($tmp . '/file1.txt');
- $this->fileSystem->recursiveCopy($tmp . '/a', $tmp . '/file1.txt');
+ $this->filesystem->recursiveCopy($tmp . '/a', $tmp . '/file1.txt');
unlink($tmp . '/file1.txt');
rmdir($tmp . '/a');
}
@@ -84,7 +87,7 @@ public function testRecursiveCopyWithBlacklist()
$ignoreMe = $folder1 . '/ignore.me';
$file2 = $folder2 . '/file2.txt';
$dest = sys_get_temp_dir() . '/n98_copy_dest';
- $this->fileSystem->recursiveRemoveDirectory($dest, true);
+ $this->filesystem->recursiveRemoveDirectory($dest, true);
@mkdir($folder1, 0777, true);
@mkdir($folder2, 0777, true);
@@ -92,10 +95,10 @@ public function testRecursiveCopyWithBlacklist()
touch($ignoreMe);
touch($file2);
- $this->fileSystem->recursiveCopy($basePath, $dest, ['ignore.me']);
- self::assertFileExists($dest . '/folder1/file1.txt');
- self::assertFileDoesNotExist($dest . '/folder1/ignore.me');
- self::assertFileExists($dest . '/folder2/file2.txt');
+ $this->filesystem->recursiveCopy($basePath, $dest, ['ignore.me']);
+ $this->assertFileExists($dest . '/folder1/file1.txt');
+ $this->assertFileDoesNotExist($dest . '/folder1/ignore.me');
+ $this->assertFileExists($dest . '/folder2/file2.txt');
//cleanup
unlink($file1);
@@ -128,12 +131,12 @@ public function testRecursiveDirectoryRemoveUnLinksSymLinks()
touch($symLinkedFile);
$result = @symlink($symLinked, $basePath . '/symlink');
- self::assertTrue($result);
+ $this->assertTrue($result);
- $this->fileSystem->recursiveRemoveDirectory($basePath);
+ $this->filesystem->recursiveRemoveDirectory($basePath);
- self::assertFileExists($symLinkedFile);
- self::assertFileDoesNotExist($basePath);
+ $this->assertFileExists($symLinkedFile);
+ $this->assertFileDoesNotExist($basePath);
}
public function testRecursiveRemove()
@@ -150,8 +153,8 @@ public function testRecursiveRemove()
touch($file1);
touch($file2);
- $this->fileSystem->recursiveRemoveDirectory($basePath);
- self::assertFileDoesNotExist($basePath);
+ $this->filesystem->recursiveRemoveDirectory($basePath);
+ $this->assertFileDoesNotExist($basePath);
}
public function testRecursiveRemoveWithTrailingSlash()
@@ -168,13 +171,13 @@ public function testRecursiveRemoveWithTrailingSlash()
touch($file1);
touch($file2);
- $this->fileSystem->recursiveRemoveDirectory($basePath . '/');
- self::assertFileDoesNotExist($basePath);
+ $this->filesystem->recursiveRemoveDirectory($basePath . '/');
+ $this->assertFileDoesNotExist($basePath);
}
public function testFalseIsReturnedIfDirectoryNotExist()
{
- self::assertFalse($this->fileSystem->recursiveRemoveDirectory('not-a-folder'));
+ $this->assertFalse($this->filesystem->recursiveRemoveDirectory('not-a-folder'));
}
public function testFalseIsReturnedIfDirectoryNotReadable()
@@ -182,7 +185,7 @@ public function testFalseIsReturnedIfDirectoryNotReadable()
$tmp = sys_get_temp_dir();
$basePath = $tmp . '/n98_testdir-never-existed';
- self::assertFalse($this->fileSystem->recursiveRemoveDirectory($basePath));
+ $this->assertFalse($this->filesystem->recursiveRemoveDirectory($basePath));
}
public function testParentIsNotRemovedIfEmptyIsTrue()
@@ -199,10 +202,10 @@ public function testParentIsNotRemovedIfEmptyIsTrue()
touch($file1);
touch($file2);
- $this->fileSystem->recursiveRemoveDirectory($basePath, true);
- self::assertFileExists($basePath);
- self::assertFileDoesNotExist($folder1);
- self::assertFileDoesNotExist($folder2);
+ $this->filesystem->recursiveRemoveDirectory($basePath, true);
+ $this->assertFileExists($basePath);
+ $this->assertFileDoesNotExist($folder1);
+ $this->assertFileDoesNotExist($folder2);
}
/**
@@ -214,14 +217,18 @@ public function testParentIsNotRemovedIfEmptyIsTrue()
public function testConvertBytesToHumanReadable($bytes, $decimalPlaces, $expected)
{
$res = Filesystem::humanFileSize($bytes, $decimalPlaces);
- self::assertSame($expected, $res);
+ $this->assertSame($expected, $res);
}
/**
- * @return array
+ * @return \Iterator<(int | string), mixed>
*/
- public static function convertedBytesProvider()
+ public static function convertedBytesProvider(): \Iterator
{
- return [[20_000_000, 2, '19.07M'], [20_000_000, 3, '19.073M'], [2_000_000_000, 2, '1.86G'], [2, 2, '2.00B'], [2048, 2, '2.00K']];
+ yield [20_000_000, 2, '19.07M'];
+ yield [20_000_000, 3, '19.073M'];
+ yield [2_000_000_000, 2, '1.86G'];
+ yield [2, 2, '2.00B'];
+ yield [2048, 2, '2.00K'];
}
}
diff --git a/tests/N98/Util/OperatingSystemTest.php b/tests/N98/Util/OperatingSystemTest.php
index 240390740..9e60cf46f 100644
--- a/tests/N98/Util/OperatingSystemTest.php
+++ b/tests/N98/Util/OperatingSystemTest.php
@@ -1,5 +1,7 @@
assertCount(4, $matrix, 'Number of OSes to check for');
+ $this->assertCount(1, array_filter($matrix), 'One OS must be detected');
}
/**
@@ -34,10 +33,10 @@ public function osDetection()
*/
public function testIsLinux()
{
- self::assertTrue(OperatingSystem::isLinux());
- self::assertFalse(OperatingSystem::isWindows());
- self::assertFalse(OperatingSystem::isMacOs());
- self::assertFalse(OperatingSystem::isNetware());
+ $this->assertTrue(OperatingSystem::isLinux());
+ $this->assertFalse(OperatingSystem::isWindows());
+ $this->assertFalse(OperatingSystem::isMacOs());
+ $this->assertFalse(OperatingSystem::isNetware());
}
/**
@@ -45,10 +44,10 @@ public function testIsLinux()
*/
public function testIsWindows()
{
- self::assertTrue(OperatingSystem::isWindows());
- self::assertFalse(OperatingSystem::isLinux());
- self::assertFalse(OperatingSystem::isMacOs());
- self::assertFalse(OperatingSystem::isNetware());
+ $this->assertTrue(OperatingSystem::isWindows());
+ $this->assertFalse(OperatingSystem::isLinux());
+ $this->assertFalse(OperatingSystem::isMacOs());
+ $this->assertFalse(OperatingSystem::isNetware());
}
/**
@@ -56,10 +55,10 @@ public function testIsWindows()
*/
public function testIsMacOs()
{
- self::assertTrue(OperatingSystem::isMacOs());
- self::assertFalse(OperatingSystem::isLinux());
- self::assertFalse(OperatingSystem::isWindows());
- self::assertFalse(OperatingSystem::isNetware());
+ $this->assertTrue(OperatingSystem::isMacOs());
+ $this->assertFalse(OperatingSystem::isLinux());
+ $this->assertFalse(OperatingSystem::isWindows());
+ $this->assertFalse(OperatingSystem::isNetware());
}
/**
@@ -67,27 +66,23 @@ public function testIsMacOs()
*/
public function testIsNetware()
{
- self::assertTrue(OperatingSystem::isNetware());
- self::assertFalse(OperatingSystem::isLinux());
- self::assertFalse(OperatingSystem::isWindows());
- self::assertFalse(OperatingSystem::isMacOs());
+ $this->assertTrue(OperatingSystem::isNetware());
+ $this->assertFalse(OperatingSystem::isLinux());
+ $this->assertFalse(OperatingSystem::isWindows());
+ $this->assertFalse(OperatingSystem::isMacOs());
}
- /**
- * @test
- */
- public function getCwd()
+ public function testGetCwd()
{
$expected = getcwd();
- self::assertEquals($expected, OperatingSystem::getCwd());
+ $this->assertEquals($expected, OperatingSystem::getCwd());
}
/**
- * @test
* @requires PHP 5.4
*/
- public function phpBinary()
+ public function testPhpBinary()
{
- self::assertEquals(PHP_BINARY, OperatingSystem::getPhpBinary());
+ $this->assertSame(PHP_BINARY, OperatingSystem::getPhpBinary());
}
}
diff --git a/tests/N98/Util/StringTypedTest.php b/tests/N98/Util/StringTypedTest.php
index 369379d08..8a0f17bcc 100644
--- a/tests/N98/Util/StringTypedTest.php
+++ b/tests/N98/Util/StringTypedTest.php
@@ -1,5 +1,7 @@
assertTrue(StringTyped::parseBoolOption('true'));
- self::assertSame('inactive', StringTyped::formatActive(null));
- self::assertSame('active', StringTyped::formatActive('1'));
+ $this->assertSame('inactive', StringTyped::formatActive(null));
+ $this->assertSame('active', StringTyped::formatActive('1'));
}
}
diff --git a/tests/N98/Util/Unicode/CharsetTest.php b/tests/N98/Util/Unicode/CharsetTest.php
index d76fcd938..cc888bbf8 100644
--- a/tests/N98/Util/Unicode/CharsetTest.php
+++ b/tests/N98/Util/Unicode/CharsetTest.php
@@ -1,14 +1,16 @@
assertSame('✖', Charset::convertInteger(Charset::UNICODE_CROSS_CHAR));
+ $this->assertSame('✔', Charset::convertInteger(Charset::UNICODE_CHECKMARK_CHAR));
}
}
diff --git a/tests/N98/Util/VerifyOrDieTest.php b/tests/N98/Util/VerifyOrDieTest.php
index 158096876..08dc72dc1 100644
--- a/tests/N98/Util/VerifyOrDieTest.php
+++ b/tests/N98/Util/VerifyOrDieTest.php
@@ -1,5 +1,7 @@
assertSame('example.txt', VerifyOrDie::filename('example.txt'));
- self::assertSame('.hidden', VerifyOrDie::filename('.hidden'));
+ $this->assertSame('.hidden', VerifyOrDie::filename('.hidden'));
}
- /**
- * @test user-message for verification
- */
- public function userMessage()
+ public function testUserMessage()
{
$message = sprintf('Database name %s is not portable', var_export('-fail', true));
try {
VerifyOrDie::filename('-fail', $message);
self::fail('An expected exception has not been thrown.');
} catch (RuntimeException $runtimeException) {
- self::assertSame($message, $runtimeException->getMessage());
+ $this->assertSame($message, $runtimeException->getMessage());
}
}
- /**
- * @test a filename must have at least one byte
- */
- public function zeroLengthFilename()
+ public function testZeroLengthFilename()
{
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessage('Filename is zero-length string');
VerifyOrDie::filename('');
}
- /**
- * @test
- */
- public function invalidArugment()
+ public function testInvalidArugment()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Parameter basename must be of type string, NULL given');
VerifyOrDie::filename(null);
}
- /**
- * @test a filename must not start with a dash
- */
- public function startWithDashFilename()
+ public function testStartWithDashFilename()
{
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessage("Filename '-rf' starts with a dash");
@@ -74,10 +61,9 @@ public function startWithDashFilename()
}
/**
- * @test
* @dataProvider provideNonPortableFilenames
*/
- public function nonPortableFilenameThrowsException($filename)
+ public function testNonPortableFilenameThrowsException($filename)
{
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessage('is not portable');
@@ -87,8 +73,10 @@ public function nonPortableFilenameThrowsException($filename)
/**
* @see nonPortableFilenameThrowsException
*/
- public function provideNonPortableFilenames()
+ public function provideNonPortableFilenames(): \Iterator
{
- return [['no-slash-/-in.there'], ['windoze-limits-<>:"/\\|?*'], ['lets-keep-spaces out']];
+ yield ['no-slash-/-in.there'];
+ yield ['windoze-limits-<>:"/\\|?*'];
+ yield ['lets-keep-spaces out'];
}
}
diff --git a/tests/N98/Util/WindowsSystemTest.php b/tests/N98/Util/WindowsSystemTest.php
index f63101af4..96ac2a976 100644
--- a/tests/N98/Util/WindowsSystemTest.php
+++ b/tests/N98/Util/WindowsSystemTest.php
@@ -1,5 +1,7 @@
assertTrue(WindowsSystem::isProgramInstalled('notepad'));
- self::assertFalse(WindowsSystem::isProgramInstalled('notepad-that-never-made-it-into-windows-kernel'));
+ $this->assertFalse(WindowsSystem::isProgramInstalled('notepad-that-never-made-it-into-windows-kernel'));
- self::assertFalse(WindowsSystem::isProgramInstalled('invalid\\command*name|thisis'));
+ $this->assertFalse(WindowsSystem::isProgramInstalled('invalid\\command*name|thisis'));
}
/**
* @see isExecutableName
- * @return array
+ * @return \Iterator<(int | string), mixed>
*/
- public function provideExecutableNames()
+ public function provideExecutableNames(): \Iterator
{
- return [['notepad', false], ['notepad.com', true], ['notepad.exe', true], ['notepad.exe.exe', true], ['notepad.eXe', true], ['notepad.EXE', true], ['notepad.bat', true], ['notepad.txt', false]];
+ yield ['notepad', false];
+ yield ['notepad.com', true];
+ yield ['notepad.exe', true];
+ yield ['notepad.exe.exe', true];
+ yield ['notepad.eXe', true];
+ yield ['notepad.EXE', true];
+ yield ['notepad.bat', true];
+ yield ['notepad.txt', false];
}
/**
- * @test
*
* @param string $name
* @param bool $expected
* @dataProvider provideExecutableNames
*/
- public function isExecutableName($name, $expected)
+ public function testIsExecutableName($name, $expected)
{
- self::assertSame($expected, WindowsSystem::isExecutableName($name), $name);
+ $this->assertSame($expected, WindowsSystem::isExecutableName($name), $name);
}
}