Skip to content

Commit 6517a1b

Browse files
authored
Merge pull request #24 from pdsinterop/feature/phpunit-workflow
Feature/phpunit workflow
2 parents 08a2540 + 78fe61b commit 6517a1b

8 files changed

Lines changed: 111 additions & 223 deletions

File tree

.github/workflows/tests.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
name: Test jobs
3+
4+
on:
5+
- push
6+
- pull_request
7+
# Allow manually triggering the workflow.
8+
- workflow_dispatch
9+
10+
# Cancels all previous workflow runs for the same branch that have not yet completed.
11+
concurrency:
12+
# The concurrency group contains the workflow name and the branch name.
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
phpunit:
18+
runs-on: ubuntu-20.04
19+
20+
strategy:
21+
matrix:
22+
php: ['8.0', '8.1']
23+
24+
steps:
25+
- uses: actions/checkout@v3
26+
- uses: shivammathur/setup-php@v2
27+
with:
28+
php-version: ${{ matrix.php }}
29+
- uses: "ramsey/composer-install@v2"
30+
with:
31+
composer-options: --no-scripts
32+
- run: bin/phpunit

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"require-dev": {
3333
"ext-xdebug": "*",
3434
"ext-xml": "*",
35-
"phpunit/phpunit": "^8.5 | ^9.5"
35+
"phpunit/phpunit": "^9"
3636
},
3737
"scripts": {
3838
"tests:example": "php -S localhost:8080 -t ./tests/ ./tests/example.php",

phpunit.xml.dist

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
5+
6+
beStrictAboutCoversAnnotation="true"
7+
beStrictAboutOutputDuringTests="true"
8+
beStrictAboutTodoAnnotatedTests="true"
9+
bootstrap="vendor/autoload.php"
10+
cacheResultFile=".phpunit.cache/test-results"
11+
convertDeprecationsToExceptions="true"
12+
failOnRisky="true"
13+
failOnWarning="true"
14+
forceCoversAnnotation="true"
15+
verbose="true"
16+
>
17+
<testsuites>
18+
<testsuite name="all">
19+
<directory suffix=".php">tests/</directory>
20+
</testsuite>
21+
</testsuites>
22+
23+
<coverage processUncoveredFiles="false">
24+
<include>
25+
<directory suffix=".php">src/</directory>
26+
</include>
27+
<report>
28+
<!-- clover outputFile="build/clover.xml"/ -->
29+
<!-- html outputDirectory="build/coverage"/ -->
30+
<text outputFile="php://stdout"/>
31+
</report>
32+
</coverage>
33+
</phpunit>

tests/dummyTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
/*
3+
This file is here as an example and to make sure the github actions runner has a test to run.
4+
It does not actually test anything.
5+
*/
6+
7+
namespace Pdsinterop\Dummy;
8+
9+
use PHPUnit\Framework\TestCase;
10+
11+
class DummyTest extends TestCase
12+
{
13+
/**
14+
* @coversNothing
15+
*/
16+
public function testDummy(): void
17+
{
18+
$this->assertTrue(true);
19+
}
20+
}

tests/example.php

Lines changed: 0 additions & 218 deletions
This file was deleted.

tests/unit/Config/ServerTest.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
use Pdsinterop\Solid\Auth\Exception\LogicException;
88
use PHPUnit\Framework\TestCase;
99

10+
/**
11+
* @coversNothing
12+
*/
1013
class ServerTest extends TestCase
1114
{
1215
final public function testServerConfigShouldComplainWhenInstantiatedWithoutData() : void
@@ -95,13 +98,25 @@ final public function testServerConfigShouldReturnArrayWhenSerializedWithRequire
9598
*/
9699
final public function testServerConfigShouldReturnExpectedValuesWhenSerializedWithRequiredKeysPresent(array $actual)
97100
{
98-
self::assertEquals($actual, [
101+
self::assertEquals([
99102
'authorization_endpoint' => 'https://server/authorize',
100103
'id_token_signing_alg_values_supported' => ['RS256'],
101104
'issuer' => 'https://server/identifier',
102105
'jwks_uri' => 'https://server/jwk',
103-
'response_types_supported' => ['code', 'id_token', 'token'],
106+
'response_types_supported' => ['code', 'code token', 'code id_token', 'id_token code', 'id_token', 'id_token token', 'code id_token token', 'none'],
104107
'subject_types_supported' => ['public'],
105-
]);
108+
'token_types_supported' => ['legacyPop','dpop'],
109+
'response_modes_supported' => ['query', 'fragment'],
110+
'grant_types_supported' => ['authorization_code', 'implicit', 'refresh_token', 'client_credentials'],
111+
'token_endpoint_auth_methods_supported' => 'client_secret_basic',
112+
'token_endpoint_auth_signing_alg_values_supported' => ['RS256'],
113+
'display_values_supported' => [],
114+
'claim_types_supported' => ['normal'],
115+
'claims_supported' => [],
116+
'claims_parameter_supported' => false,
117+
'request_parameter_supported' => true,
118+
'request_uri_parameter_supported' => false,
119+
'require_request_uri_registration' => false
120+
], $actual);
106121
}
107122
}

tests/unit/Enum/AbstractEnumTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,6 @@ final public function testEnumValuesShouldMatchExpectedValues(array $actual) : v
8484
{
8585
$expected = $this->getExpectedValues();
8686

87-
self::assertEquals($actual, $expected);
87+
self::assertEquals($expected, $actual);
8888
}
8989
}

tests/unit/Enum/OpenId/OpenIdConnectMetadataTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
use Pdsinterop\Solid\Auth\Enum\AbstractEnumTest as TestCase;
66

7+
/**
8+
* @coversNothing
9+
*/
710
class OpenIdConnectMetadataTest extends TestCase
811
{
912
final public function getEnum() : OpenIdConnectMetadata
@@ -49,6 +52,9 @@ final public function getExpectedValues() : array
4952
'userinfo_encryption_enc_values_supported',
5053
'userinfo_endpoint',
5154
'userinfo_signing_alg_values_supported',
55+
'token_types_supported',
56+
'check_session_iframe',
57+
'end_session_endpoint'
5258
];
5359
}
5460

0 commit comments

Comments
 (0)