fix tests against PhpUnit 10 refactors

This commit is contained in:
Fabio Ivona
2022-08-25 16:19:22 +02:00
parent c0d66b7dc7
commit a4ec4b2841
5 changed files with 19 additions and 16 deletions

1
.gitignore vendored
View File

@ -4,6 +4,7 @@ composer.lock
/vendor/
coverage.xml
.phpunit.result.cache
.phpunit.cache
/.php-cs-fixer.php
.php-cs-fixer.cache
.temp/coverage.php

View File

@ -1,14 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
colors="true"
cacheDirectory=".phpunit.cache"
>
<testsuites>
<testsuite name="default">
<directory suffix=".php">./tests</directory>
</testsuite>
</testsuites>
<coverage processUncoveredFiles="true">
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>

View File

@ -73,7 +73,7 @@ final class Reflection
return $test === null
? static::bindCallable($callable)
: Closure::fromCallable($callable)->bindTo($test)(...$test->getProvidedData());
: Closure::fromCallable($callable)->bindTo($test)(...$test->providedData());
}
/**

View File

@ -60,13 +60,13 @@ it('guesses if the given argument is a class or function', function () {
})->covers(TestCoversClass3::class, 'testCoversFunction');
it('appends CoversNothing to method attributes', function () {
$phpDoc = (new ReflectionClass($this))->getMethod($this->getName());
$phpDoc = (new ReflectionClass($this))->getMethod($this->name());
expect(str_contains($phpDoc->getDocComment(), '* @coversNothing'))->toBeTrue();
})->coversNothing();
it('does not append CoversNothing to other methods', function () {
$phpDoc = (new ReflectionClass($this))->getMethod($this->getName());
$phpDoc = (new ReflectionClass($this))->getMethod($this->name());
expect(str_contains($phpDoc->getDocComment(), '* @coversNothing'))->toBeFalse();
});

View File

@ -38,8 +38,9 @@ it('allows to call underlying protected/private methods', function () {
});
it('throws error if method do not exist', function () {
test()->name();
})->throws(\ReflectionException::class, 'Call to undefined method PHPUnit\Framework\TestCase::name()');
$user = new User();
$user->foo();
})->throws(Error::class, 'Call to undefined method User::foo()');
it('can forward unexpected calls to any global function')->_assertThat();