Skip to content

Commit 08f956c

Browse files
committed
Move from PHPSpec to PHPUnit.
1 parent d46250d commit 08f956c

316 files changed

Lines changed: 19082 additions & 15753 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/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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...

composer.json

Lines changed: 13 additions & 12 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": [
5455
"phpspec run --no-interaction -c phpspec.cov.yml",
5556
"phpunit --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",

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: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,29 @@
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+
<coverage includeUncoveredFiles="true"
16+
pathCoverage="false"
17+
ignoreDeprecatedCodeUnits="true"
18+
disableCodeCoverageIgnore="true">
19+
</coverage>
820
<testsuites>
9-
<testsuite name="FreeDSx LDAP Unit Tests">
21+
<testsuite name="integration">
1022
<directory>./tests/integration</directory>
1123
</testsuite>
24+
<testsuite name="unit">
25+
<directory>./tests/unit</directory>
26+
</testsuite>
1227
</testsuites>
1328
<php>
1429
<env name="LDAP_SERVER" value="example.com"/>

src/FreeDSx/Ldap/Server/RequestHistory.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,12 @@ public function pagingRequest(): PagingRequests
5959
{
6060
return $this->pagingRequests;
6161
}
62+
63+
/**
64+
* @return int[]
65+
*/
66+
public function getIds(): array
67+
{
68+
return $this->ids;
69+
}
6270
}

tests/integration/FreeDSx/Ldap/LdapClientTest.php renamed to tests/integration/LdapClientTest.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* file that was distributed with this source code.
1212
*/
1313

14-
namespace integration\FreeDSx\Ldap;
14+
namespace Tests\Integration\FreeDSx\Ldap;
1515

1616
use FreeDSx\Ldap\ClientOptions;
1717
use FreeDSx\Ldap\Entry\Entries;
@@ -379,9 +379,9 @@ public function testSearchOperationWithEntryHandler(): void
379379

380380
$this->client->search($op);
381381

382-
$this->assertSame(
382+
$this->assertCount(
383383
843,
384-
$entries->count()
384+
$entries
385385
);
386386
}
387387

@@ -424,9 +424,9 @@ public function testSubSearchOperation(): void
424424
Entries::class,
425425
$entries
426426
);
427-
$this->assertSame(
427+
$this->assertCount(
428428
843,
429-
$entries->count()
429+
$entries,
430430
);
431431
}
432432

@@ -439,13 +439,9 @@ public function testListSearchOperation(): void
439439
'ou=Payroll,ou=FreeDSx-Test,dc=example,dc=com'
440440
));
441441

442-
$this->assertInstanceOf(
443-
Entries::class,
444-
$entries
445-
);
446-
$this->assertSame(
442+
$this->assertCount(
447443
100,
448-
$entries->count()
444+
$entries,
449445
);
450446

451447
foreach ($entries->toArray() as $entry) {

tests/integration/FreeDSx/Ldap/LdapProxyTest.php renamed to tests/integration/LdapProxyTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* file that was distributed with this source code.
1212
*/
1313

14-
namespace integration\FreeDSx\Ldap;
14+
namespace Tests\Integration\FreeDSx\Ldap;
1515

1616
use FreeDSx\Ldap\Operations;
1717
use FreeDSx\Ldap\Search\Filters;
@@ -58,18 +58,18 @@ public function testItCanHandlePaging(): void
5858

5959
$entries = $paging->getEntries();
6060

61-
$this->assertSame(
61+
$this->assertCount(
6262
1000,
63-
$entries->count()
63+
$entries
6464
);
6565

6666
while ($paging->hasEntries()) {
6767
$entries->add(...$paging->getEntries()->toArray());
6868
}
6969

70-
$this->assertSame(
70+
$this->assertCount(
7171
10001,
72-
$entries->count()
72+
$entries
7373
);
7474
}
7575

tests/integration/FreeDSx/Ldap/LdapServerTest.php renamed to tests/integration/LdapServerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* file that was distributed with this source code.
1212
*/
1313

14-
namespace integration\FreeDSx\Ldap;
14+
namespace Tests\Integration\FreeDSx\Ldap;
1515

1616
use FreeDSx\Ldap\Entry\Entry;
1717
use FreeDSx\Ldap\Exception\BindException;

tests/integration/FreeDSx/Ldap/LdapTestCase.php renamed to tests/integration/LdapTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* file that was distributed with this source code.
1212
*/
1313

14-
namespace integration\FreeDSx\Ldap;
14+
namespace Tests\Integration\FreeDSx\Ldap;
1515

1616
use FreeDSx\Ldap\ClientOptions;
1717
use FreeDSx\Ldap\LdapClient;

tests/integration/FreeDSx/Ldap/Search/DirSyncTest.php renamed to tests/integration/Search/DirSyncTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
* file that was distributed with this source code.
1212
*/
1313

14-
namespace integration\FreeDSx\Ldap\Search;
14+
namespace Tests\Integration\FreeDSx\Ldap\Search;
1515

1616
use FreeDSx\Ldap\LdapClient;
1717
use FreeDSx\Ldap\Search\DirSync;
1818
use FreeDSx\Ldap\Search\Filter\FilterInterface;
1919
use FreeDSx\Ldap\Search\Filters;
20-
use integration\FreeDSx\Ldap\LdapTestCase;
20+
use Tests\Integration\FreeDSx\Ldap\LdapTestCase;
2121

2222
class DirSyncTest extends LdapTestCase
2323
{

0 commit comments

Comments
 (0)