Skip to content

Commit b04d5d6

Browse files
committed
Add contracts tests
1 parent 02d191f commit b04d5d6

File tree

4 files changed

+71
-0
lines changed

4 files changed

+71
-0
lines changed

composer.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,14 @@
2626
}
2727
},
2828
"require-dev": {
29+
"phpunit/phpunit": "^10.5|^11.0",
2930
"vimeo/psalm": "^5.21"
3031
},
32+
"autoload-dev": {
33+
"psr-4": {
34+
"Phplrt\\Contracts\\Exception\\Tests\\": "tests"
35+
}
36+
},
3137
"extra": {
3238
"branch-alias": {
3339
"dev-master": "4.x-dev",

phpunit.xml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
4+
colors="true"
5+
backupGlobals="true"
6+
stopOnFailure="false"
7+
processIsolation="false"
8+
bootstrap="vendor/autoload.php"
9+
cacheDirectory="vendor/.phpunit.cache"
10+
backupStaticProperties="false"
11+
>
12+
<testsuites>
13+
<testsuite name="unit">
14+
<directory>tests</directory>
15+
</testsuite>
16+
</testsuites>
17+
18+
<coverage/>
19+
20+
<source>
21+
<include>
22+
<directory suffix=".php">src</directory>
23+
</include>
24+
</source>
25+
26+
<php>
27+
<ini name="error_reporting" value="-1"/>
28+
<ini name="memory_limit" value="-1"/>
29+
</php>
30+
</phpunit>

tests/CompatibilityTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Phplrt\Contracts\Exception\Tests;
6+
7+
use Phplrt\Contracts\Exception\RuntimeExceptionInterface;
8+
use Phplrt\Contracts\Lexer\TokenInterface;
9+
use Phplrt\Contracts\Source\ReadableInterface;
10+
use PHPUnit\Framework\Attributes\Group;
11+
12+
#[Group('phplrt/exception-contracts')]
13+
class CompatibilityTest extends TestCase
14+
{
15+
public function testRuntimeExceptionCompatibility(): void
16+
{
17+
self::expectNotToPerformAssertions();
18+
19+
new class extends \Exception implements RuntimeExceptionInterface {
20+
public function getToken(): TokenInterface {}
21+
public function getSource(): ReadableInterface {}
22+
};
23+
}
24+
}

tests/TestCase.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Phplrt\Contracts\Exception\Tests;
6+
7+
use PHPUnit\Framework\Attributes\Group;
8+
use PHPUnit\Framework\TestCase as BaseTestCase;
9+
10+
#[Group('phplrt/exception-contracts')]
11+
abstract class TestCase extends BaseTestCase {}

0 commit comments

Comments
 (0)