Skip to content

Commit

Permalink
Get PHPUnit tests up and running
Browse files Browse the repository at this point in the history
  • Loading branch information
MKodde committed Nov 1, 2023
1 parent aace758 commit 5ce7452
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 251 deletions.
5 changes: 5 additions & 0 deletions ci/qa/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ parameters:
count: 2
path: ../../src/Surfnet/AzureMfa/Infrastructure/Controller/DefaultController.php

-
message: "#^Call to an undefined method Symfony\\\\Contracts\\\\Translation\\\\TranslatorInterface\\:\\:setLocale\\(\\)\\.$#"
count: 1
path: ../../src/Surfnet/AzureMfa/Infrastructure/EventSubscriber/LocaleResponseListener.php

-
message: "#^Method Surfnet\\\\AzureMfa\\\\Infrastructure\\\\Institution\\\\ConfigurationValidator\\:\\:__construct\\(\\) has parameter \\$configuration with no value type specified in iterable type array\\.$#"
count: 1
Expand Down
27 changes: 5 additions & 22 deletions ci/qa/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/8.4/phpunit.xsd"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/9.6/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
bootstrap="../../vendor/autoload.php"
>
<php>
<ini name="error_reporting" value="-1"/>
Expand All @@ -14,37 +14,20 @@
<server name="APP_SECRET" value="SECRETFORTEST"/>
<server name="SHELL_VERBOSITY" value="-1"/>
<server name="SYMFONY_PHPUNIT_REMOVE" value=""/>
<server name="SYMFONY_PHPUNIT_VERSION" value="8.4"/>
<server name="SYMFONY_PHPUNIT_VERSION" value="9.6"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak" />
</php>

<testsuites>
<testsuite name="unit tests">
<directory suffix="Test.php">tests</directory>
<directory suffix="Test.php">../../tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>src</directory>
<directory>../../src</directory>
</whitelist>
</filter>

<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener">
<arguments>
<array>
<!-- set this option to 0 to disable the DebugClassLoader integration -->
<element key="debug-class-loader">
<integer>0</integer>
</element>
</array>
</arguments>
</listener>
<listener class="Symfony\Component\Panther\ServerListener" />
</listeners>

<extensions>
<extension class="Symfony\Component\Panther\ServerExtension" />
</extensions>
</phpunit>
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
"behat/mink-goutte-driver": "^2.0",
"behat/mink-selenium2-driver": "^1.6",
"friends-of-behat/symfony-extension": "^2.4",
"dbrekelmans/bdi": "^1.1",
"overtrue/phplint": "*",
"malukenho/docheader": "^1",
"mockery/mockery": "^1.6",
Expand All @@ -65,7 +64,6 @@
"soyuka/contexts": "^3.3",
"symfony/browser-kit": "^6.3",
"symfony/css-selector": "^6.3",
"symfony/panther": "^2.1",
"symfony/phpunit-bridge": "^6.3",
"symfony/stopwatch": "^6.3",
"symfony/web-profiler-bundle": "^6.3"
Expand All @@ -78,7 +76,8 @@
"@phpcpd",
"@phpcs",
"@phpmd",
"@phpstan"
"@phpstan",
"@test"
],

"behat": "./ci/qa/behat",
Expand All @@ -91,6 +90,7 @@
"phpmd": "./ci/qa/phpmd",
"phpstan": "./ci/qa/phpstan",
"phpstan-baseline": "./ci/qa/phpstan-update-baseline",
"test": "./ci/qa/phpunit",
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
Expand Down
207 changes: 2 additions & 205 deletions composer.lock

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

2 changes: 1 addition & 1 deletion config/packages/test/framework.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
framework:
test: ~
session:
storage_id: session.storage.mock_file
storage_factory_id: session.storage.factory.mock_file
profiler:
collect: false
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
namespace Surfnet\AzureMfa\Infrastructure\EventSubscriber;

use RuntimeException;
use Symfony\Bundle\FrameworkBundle\Translation\Translator;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Contracts\Translation\TranslatorInterface;

/**
* Handles the lang selection based on cookie.
Expand All @@ -37,7 +37,7 @@ final class LocaleResponseListener implements EventSubscriberInterface
const STEPUP_LOCALE_COOKIE = 'stepup_locale';

public function __construct(
private readonly Translator $translator,
private readonly TranslatorInterface $translator,
private readonly RequestStack $requestStack
) {
}
Expand Down
6 changes: 0 additions & 6 deletions symfony.lock
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,6 @@
"php": {
"version": "7.2"
},
"php-webdriver/webdriver": {
"version": "1.10.0"
},
"phpdocumentor/reflection-common": {
"version": "2.2.0"
},
Expand Down Expand Up @@ -425,9 +422,6 @@
"symfony/options-resolver": {
"version": "v4.4.19"
},
"symfony/panther": {
"version": "v0.9.0"
},
"symfony/phpunit-bridge": {
"version": "5.1",
"recipe": {
Expand Down
Loading

0 comments on commit 5ce7452

Please sign in to comment.