Skip to content

Commit

Permalink
Remove mockery
Browse files Browse the repository at this point in the history
Prior to this change, mockery was used, but the Mockery::close() function was not called in the teardown. This caused tests to be green instead of red when mockery expectations were not met.
This change does away with mockery in its entirety, as it was hardly used and phpunit mocks can be used instead.
  • Loading branch information
johanib committed Nov 18, 2024
1 parent 31ed973 commit 2097a47
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 204 deletions.
2 changes: 1 addition & 1 deletion ci/qa/phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<server name="KERNEL_CLASS" value="Surfnet\Tiqr\Kernel"/>
<server name="SHELL_VERBOSITY" value="-1"/>
<server name="SYMFONY_PHPUNIT_REMOVE" value=""/>
<server name="SYMFONY_PHPUNIT_VERSION" value="6.5"/>
<server name="SYMFONY_PHPUNIT_VERSION" value="9.6"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak"/>
</php>
<testsuites>
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"khanamiryan/qrcode-detector-decoder": "^2.0",
"league/csv": "^9.13",
"malukenho/docheader": "^1",
"mockery/mockery": "^1.6",
"overtrue/phplint": "*",
"phpmd/phpmd": "^2.15",
"phpstan/phpstan": "^1.10",
Expand Down
136 changes: 1 addition & 135 deletions composer.lock

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

1 change: 0 additions & 1 deletion dev/Command/AuthenticationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ protected function decorateResult(string $text): string
protected function readAuthenticationLinkFromFile(string $file, OutputInterface $output): string
{
$qrcode = new QrReader(file_get_contents($file), QrReader::SOURCE_TYPE_BLOB);
/** @phpstan-var mixed $link */
$link = $qrcode->text();

if (!is_string($link)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

namespace Unit\EventSubscriber;

use Mockery;
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
use Surfnet\Tiqr\Attribute\RequiresActiveSession;
Expand All @@ -42,8 +41,6 @@ final class RequiresActiveSessionAttributeListenerTest extends KernelTestCase

public function testControllersWithoutTheRequiresActiveSessionAttributeAreIgnored(): void
{
$this->expectNotToPerformAssertions();

self::bootKernel();

$request = new Request(server: ['REQUEST_URI' => '/route']);
Expand All @@ -63,8 +60,8 @@ public function testControllersWithoutTheRequiresActiveSessionAttributeAreIgnore

$dispatcher = new EventDispatcher();

$mockLogger = Mockery::mock(LoggerInterface::class);
$mockLogger->shouldNotReceive('log');
$mockLogger = $this->createMock(LoggerInterface::class);
$mockLogger->expects($this->never())->method('log');

$listener = new RequiresActiveSessionAttributeListener(
$mockLogger,
Expand Down Expand Up @@ -101,15 +98,14 @@ public function testItDeniesAccessWhenThereIsNoActiveSession(): void

$dispatcher = new EventDispatcher();

$mockLogger = Mockery::mock(LoggerInterface::class);
$mockLogger->shouldReceive('log')
->once()
$mockLogger = $this->createMock(LoggerInterface::class);
$mockLogger->expects($this->once())
->method('log')
->with(
LogLevel::ERROR,
'Route requires active session. Active session wasn\'t found.',
['correlationId' => '', 'route' => '/route']
);

$listener = new RequiresActiveSessionAttributeListener(
$mockLogger,
new SessionCorrelationIdService($requestStack, ['name' => 'PHPSESSID'], 'Mr6LpJYtuWRDdVR2_7VgTChFhzQ'),
Expand Down Expand Up @@ -146,9 +142,9 @@ public function testItDeniesAccessWhenThereIsNoSessionCookie(): void

$dispatcher = new EventDispatcher();

$mockLogger = Mockery::mock(LoggerInterface::class);
$mockLogger->shouldReceive('log')
->once()
$mockLogger = $this->createMock(LoggerInterface::class);
$mockLogger->expects($this->once())
->method('log')
->with(
LogLevel::ERROR,
'Route requires active session. Active session wasn\'t found. No session cookie was set.',
Expand Down Expand Up @@ -191,9 +187,9 @@ public function testItDeniesAccessWhenTheActiveSessionDoesNotMatchTheSessionCook

$dispatcher = new EventDispatcher();

$mockLogger = Mockery::mock(LoggerInterface::class);
$mockLogger->shouldReceive('log')
->once()
$mockLogger = $this->createMock(LoggerInterface::class);
$mockLogger->expects($this->once())
->method('log')
->with(
LogLevel::ERROR,
'Route requires active session. Session does not match session cookie.',
Expand All @@ -212,8 +208,6 @@ public function testItDeniesAccessWhenTheActiveSessionDoesNotMatchTheSessionCook

public function testItDoesNotThrowWhenTheActiveSessionMatchesTheSessionCookie(): void
{
$this->expectNotToPerformAssertions();

self::bootKernel();

$session = new Session(new MockArraySessionStorage());
Expand All @@ -235,8 +229,8 @@ public function testItDoesNotThrowWhenTheActiveSessionMatchesTheSessionCookie():

$dispatcher = new EventDispatcher();

$mockLogger = Mockery::mock(LoggerInterface::class);
$mockLogger->shouldNotReceive('log');
$mockLogger = $this->createMock(LoggerInterface::class);
$mockLogger->expects($this->never())->method('log');

$listener = new RequiresActiveSessionAttributeListener(
$mockLogger,
Expand Down
Loading

0 comments on commit 2097a47

Please sign in to comment.