Skip to content
This repository has been archived by the owner on Dec 11, 2021. It is now read-only.

Commit

Permalink
Merge pull request #38 from bitExpert/dependabot/composer/phpstan/php…
Browse files Browse the repository at this point in the history
…stan-0.12.77

Bump phpstan/phpstan from 0.12.71 to 0.12.77
  • Loading branch information
shochdoerfer committed Feb 19, 2021
2 parents d32ba42 + 6fb3cea commit dded996
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 12 deletions.
14 changes: 9 additions & 5 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,4 @@ parameters:
- tests/BitExpert
bootstrapFiles:
- vendor/bitexpert/phpstan-magento/autoload.php
ignoreErrors:
-
message: '~Unable to resolve the template type CallbackInput in call to method static method PHPUnit\\Framework\\Assert::callback\(\)~'
path: tests/BitExpert/Magento/PasswordNormalizer/Command/PasswordNormalizerUnitTest.php

Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
// check environment
$force = (bool) $input->getOption(self::OPTION_FORCE);

if (!($force || State::MODE_DEVELOPER === $this->getState()->getMode())) {
if (!($force === true || State::MODE_DEVELOPER === $this->getState()->getMode())) {
throw new LocalizedException(__('This command can only be run in developer mode!'));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use Magento\Framework\Exception\LocalizedException;
use Magento\Indexer\Model\Indexer;
use N98\Magento\Application;
use PHPUnit\Framework\Constraint\Callback;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -117,6 +116,40 @@ public function commandCannotBeRunInProductionMode(): void
$command->run($this->input, $this->output);
}

/**
* @test
*/
public function commandCanBeRunInProductionModeWithForceMode(): void
{
$this->input->expects(self::any())
->method('getOption')
->willReturnMap([
[PasswordNormalizer::OPTION_FORCE, true],
[PasswordNormalizer::OPTION_PASSWORD, 'random-password-to-set'],
[PasswordNormalizer::OPTION_EMAIL_MASK, 'customer_(ID)@example.com'],
[PasswordNormalizer::OPTION_EXCLUDE_EMAILS, ''],
]);

$this->state->expects(self::any())
->method('getMode')
->willReturn(\Magento\Framework\App\State::MODE_PRODUCTION);

$this->connection->expects(self::any())
->method('query')
->willReturn($this->statement);

$this->encryptor->expects(self::any())
->method('getHash')
->willReturn('abcdef');

/** @var PasswordNormalizer $command */
$command = $this->getPasswordNormalizerMock();
$command->setApplication($this->application);
$return = $command->run($this->input, $this->output);

self::assertSame(0, $return);
}

/**
* @test
*/
Expand All @@ -135,6 +168,75 @@ public function commandCannotBeRunInDefaultMode(): void
$command->run($this->input, $this->output);
}

/**
* @test
*/
public function commandCanBeRunInDefaultModeWithForceMode(): void
{
$this->input->expects(self::any())
->method('getOption')
->willReturnMap([
[PasswordNormalizer::OPTION_FORCE, true],
[PasswordNormalizer::OPTION_PASSWORD, 'random-password-to-set'],
[PasswordNormalizer::OPTION_EMAIL_MASK, 'customer_(ID)@example.com'],
[PasswordNormalizer::OPTION_EXCLUDE_EMAILS, ''],
]);

$this->state->expects(self::any())
->method('getMode')
->willReturn(\Magento\Framework\App\State::MODE_DEFAULT);

$this->connection->expects(self::any())
->method('query')
->willReturn($this->statement);

$this->encryptor->expects(self::any())
->method('getHash')
->willReturn('abcdef');

/** @var PasswordNormalizer $command */
$command = $this->getPasswordNormalizerMock();
$command->setApplication($this->application);
$return = $command->run($this->input, $this->output);

self::assertSame(0, $return);
}


/**
* @test
*/
public function nonBoolForceModeWillBeCastedToBool(): void
{
$this->input->expects(self::any())
->method('getOption')
->willReturnMap([
[PasswordNormalizer::OPTION_FORCE, "yes"],
[PasswordNormalizer::OPTION_PASSWORD, 'random-password-to-set'],
[PasswordNormalizer::OPTION_EMAIL_MASK, 'customer_(ID)@example.com'],
[PasswordNormalizer::OPTION_EXCLUDE_EMAILS, ''],
]);

$this->state->expects(self::any())
->method('getMode')
->willReturn(\Magento\Framework\App\State::MODE_PRODUCTION);

$this->connection->expects(self::any())
->method('query')
->willReturn($this->statement);

$this->encryptor->expects(self::any())
->method('getHash')
->willReturn('abcdef');

/** @var PasswordNormalizer $command */
$command = $this->getPasswordNormalizerMock();
$command->setApplication($this->application);
$return = $command->run($this->input, $this->output);

self::assertSame(0, $return);
}

/**
* @test
*/
Expand Down Expand Up @@ -216,7 +318,9 @@ public function passingRequiredPasswordParameterSucceeds(): void
/** @var PasswordNormalizer $command */
$command = $this->getPasswordNormalizerMock();
$command->setApplication($this->application);
$command->run($this->input, $this->output);
$return = $command->run($this->input, $this->output);

self::assertSame(0, $return);
}

/**
Expand Down

0 comments on commit dded996

Please sign in to comment.