Skip to content

Commit 15005b5

Browse files
authored
Merge pull request #86 from ChadSikorra/v1-migrate-tests-to-phpunit
[1.0.0] Migate all unit tests from PHPSpec to PHPUnit
2 parents 01d4a82 + 0d23f7f commit 15005b5

333 files changed

Lines changed: 19127 additions & 15796 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/analysis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
2525

2626
- name: Install Composer Dependencies
27-
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
27+
run: composer install --no-progress --prefer-dist --optimize-autoloader
2828

2929
- name: Cache Dependencies
3030
uses: actions/cache@v3
@@ -43,11 +43,11 @@ jobs:
4343
COMPOSER_ALLOW_SUPERUSER: 1
4444
run: sudo composer run-script --timeout=0 test-coverage
4545

46-
- name: Upload Spec Coverage to Codecov
46+
- name: Upload Unit Coverage to Codecov
4747
uses: codecov/codecov-action@v3
4848
with:
4949
token: ${{ secrets.CODECOV_TOKEN }}
50-
file: ./coverage.xml
50+
file: ./coverage-unit.xml
5151
name: FreeDSx-LDAP-Unit
5252

5353
- name: Upload Integration Coverage to Codecov

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
fail-fast: false
88
matrix:
99
operating-system: [ubuntu-latest, windows-latest]
10-
php-versions: ['8.1', '8.2']
10+
php-versions: ['8.1', '8.2', '8.3', '8.4', '8.5']
1111
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
1212
steps:
1313
- name: Checkout
@@ -30,7 +30,7 @@ jobs:
3030
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
3131

3232
- name: Install Composer dependencies
33-
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
33+
run: composer install --no-progress --prefer-dist --optimize-autoloader
3434

3535
- name: Cache dependencies
3636
uses: actions/cache@v3
@@ -39,8 +39,8 @@ jobs:
3939
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
4040
restore-keys: ${{ runner.os }}-composer-
4141

42-
- name: Run Specs
43-
run: composer run-script test-spec
42+
- name: Run Unit Tests
43+
run: composer run-script test-unit
4444

4545
# Not ideal, but we run as root here because the LDAP server needs access to certs / keys system directories.
4646
# For tests this seems fine, but in a real scenario this would be bad...

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CHANGELOG
22
=========
33

4-
1.0.0 (2023-xx-xx)
4+
1.0.0 (202x-xx-xx)
55
------------------
66
* Updated the minimum version of PHP to version 8.1.
77
* All classes now use "strict_types=1". This internal change should not impact external usage.
@@ -10,6 +10,9 @@ CHANGELOG
1010
* Added entry handler processing of searches. This allows immediate processing of entries via anonymous functions.
1111
* Added the ability to cancel search or sync requests when using entry handler processing for searches.
1212
* Added support for the SensitiveParameter attribute to mask bind related credentials from stack traces.
13+
* Removed various deprecations for PHP >= 8.1 (implicit nullability, return type declarations, etc.).
14+
* Added PHP 8.3, 8.4, and 8.5 to normal CI runs.
15+
* Migrated all unit tests from PHPSpec to PHPUnit.
1316

1417
0.8.0 (2022-05-21)
1518
------------------

composer.json

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222
"psr/log": "^3"
2323
},
2424
"require-dev": {
25-
"phpspec/phpspec": "^7.2",
26-
"phpunit/phpunit": "^9.6",
25+
"phpunit/phpunit": "^10.5",
2726
"symplify/easy-coding-standard": "^9.4",
28-
"friends-of-phpspec/phpspec-code-coverage": "^6.3",
29-
"phpstan/phpstan": "^1.11",
27+
"phpstan/phpstan": "^2.1",
3028
"symfony/process": "^5.4",
3129
"squizlabs/php_codesniffer": "^3.7",
32-
"slevomat/coding-standard": "^7.2"
30+
"slevomat/coding-standard": "^7.2",
31+
"phpstan/phpstan-phpunit": "^2.0",
32+
"phpstan/extension-installer": "^1.4"
3333
},
3434
"suggest": {
3535
"ext-openssl": "For SSL/TLS support and some SASL mechanisms.",
@@ -40,31 +40,32 @@
4040
},
4141
"autoload-dev": {
4242
"psr-4": {
43-
"integration\\FreeDSx\\Ldap\\": "tests/integration/FreeDSx/Ldap",
44-
"spec\\FreeDSx\\Ldap\\": "tests/spec/FreeDSx/Ldap"
43+
"Tests\\Integration\\FreeDSx\\Ldap\\": "tests/integration",
44+
"Tests\\Unit\\FreeDSx\\Ldap\\": "tests/unit"
4545
}
4646
},
4747
"config": {
4848
"allow-plugins": {
49-
"dealerdirect/phpcodesniffer-composer-installer": true
49+
"dealerdirect/phpcodesniffer-composer-installer": true,
50+
"phpstan/extension-installer": true
5051
}
5152
},
5253
"scripts": {
5354
"test-coverage": [
54-
"phpspec run --no-interaction -c phpspec.cov.yml",
55-
"phpunit --coverage-clover=coverage-integration.xml"
55+
"phpunit --testsuite unit --coverage-clover=coverage-unit.xml",
56+
"phpunit --testsuite integration --coverage-clover=coverage-integration.xml"
5657
],
57-
"test-spec": [
58-
"phpspec run --no-interaction"
58+
"test-unit": [
59+
"phpunit --testsuite unit"
5960
],
6061
"test-integration": [
61-
"phpunit"
62+
"phpunit --testsuite integration"
6263
],
6364
"analyse": [
6465
"phpstan --memory-limit=-1 analyse"
6566
],
6667
"analyse-tests": [
67-
"phpstan analyse -c phpstan.tests.neon"
68+
"phpstan --memory-limit=-1 analyse -c phpstan.tests.neon"
6869
],
6970
"cs-fix": [
7071
"phpcbf --standard=ruleset.xml --extensions=php --tab-width=4 -sp src",

phpspec.cov.yml

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

phpspec.yml

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

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
parameters:
2-
level: max
2+
level: 9
33
paths:
44
- %currentWorkingDirectory%/src
55
treatPhpDocTypesAsCertain: false

phpstan.tests.neon

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
parameters:
2-
level: 1
2+
level: 3
33
paths:
44
- %currentWorkingDirectory%/tests
5-
ignoreErrors:
6-
# Does not seem to be a great extension for phpspec :(
7-
- '#Call to an undefined (static )?method spec\\FreeDSx\\Ldap\\.*Spec::#'

phpunit.xml.dist

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,34 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3-
<coverage processUncoveredFiles="true">
4-
<include>
5-
<directory suffix=".php">src</directory>
6-
</include>
7-
</coverage>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
backupGlobals="false"
4+
colors="true"
5+
displayDetailsOnTestsThatTriggerDeprecations="true"
6+
displayDetailsOnTestsThatTriggerErrors="true"
7+
displayDetailsOnTestsThatTriggerNotices="true"
8+
displayDetailsOnTestsThatTriggerWarnings="true"
9+
displayDetailsOnPhpunitDeprecations="true"
10+
processIsolation="false"
11+
stopOnFailure="false"
12+
bootstrap="vendor/autoload.php"
13+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
14+
>
15+
<source>
16+
<include>
17+
<directory suffix=".php">./src</directory>
18+
</include>
19+
</source>
20+
<coverage includeUncoveredFiles="true"
21+
pathCoverage="false"
22+
ignoreDeprecatedCodeUnits="true"
23+
disableCodeCoverageIgnore="true">
24+
</coverage>
825
<testsuites>
9-
<testsuite name="FreeDSx LDAP Unit Tests">
26+
<testsuite name="integration">
1027
<directory>./tests/integration</directory>
1128
</testsuite>
29+
<testsuite name="unit">
30+
<directory>./tests/unit</directory>
31+
</testsuite>
1232
</testsuites>
1333
<php>
1434
<env name="LDAP_SERVER" value="example.com"/>

src/FreeDSx/Ldap/Control/Sync/SyncDoneControl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function toAsn1(): AbstractType
6767
));
6868
}
6969
$this->controlValue->addChild(Asn1::boolean(
70-
$this->refreshDeletes ?? false
70+
$this->refreshDeletes
7171
));
7272

7373
return parent::toAsn1();

0 commit comments

Comments
 (0)