Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): Upgrade PHPUnit #1241

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"bamarni/composer-bin-plugin": "^1.8.1",
"phpspec/prophecy": "^1.6",
"phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "^9.3",
"phpunit/phpunit": "^11.0",
"symfony/config": "^6.4 || ^7.0",
"symfony/dependency-injection": "^6.4 || ^7.0",
"symfony/finder": "^6.4 || ^7.0",
Expand Down
8 changes: 4 additions & 4 deletions fixtures/Parser/FileListProviderTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@

trait FileListProviderTrait
{
public function providePhpList()
public static function providePhpList(): array
{
return FilesReference::getPhpList();
}

public function provideYamlList()
public static function provideYamlList(): array
{
return FilesReference::getYamlList();
}

public function provideJsonList()
public static function provideJsonList(): array
{
return FilesReference::getJsonList();
}

public function provideUnsupportedList()
public static function provideUnsupportedList(): array
{
return FilesReference::getUnsupportedList();
}
Expand Down
44 changes: 5 additions & 39 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -21,59 +21,25 @@
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0"/>
</php>

<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
</listeners>

<coverage>
<source>
<include>
<directory>src</directory>
</include>

<exclude>
<directory>src/Bridge</directory>
<file>src/deep_clone.php</file>
</exclude>
</source>

<coverage>
<report>
<clover outputFile="dist/clover.xml"/>
</report>
</coverage>

<testsuites>
<testsuite name="Dependent tests">
<file>tests/Definition/PropertyTest.php</file>
<file>tests/Definition/PropertyBagTest.php</file>
<file>tests/Definition/MethodCallBagTest.php</file>
<file>tests/Definition/SpecificationBagTest.php</file>
<file>tests/Definition/FlagBagTest.php</file>
<file>tests/Definition/Fixture/SimpleFixtureTest.php</file>
<file>tests/Definition/Fixture/SimpleFixtureWithFlagsTest.php</file>
<file>tests/Definition/Fixture/TemplatingFixtureTest.php</file>
<file>tests/Definition/ServiceReference/FixtureReferenceTest.php</file>
<file>tests/Definition/Fixture/TemplatingTest.php</file>
<file>tests/Definition/MethodCall/OptionalMethodCallTest.php</file>
<file>tests/Definition/Value/FunctionCallValueTest.php</file>
<file>tests/Definition/Value/FixtureMethodCallValueTest.php</file>
<file>tests/Definition/Value/FixtureReferenceValueTest.php</file>
<file>tests/Definition/Value/FixturePropertyValueTest.php</file>
<file>tests/Definition/Value/FixturePropertyValueTest.php</file>
<file>tests/Definition/Value/UniqueValueTest.php</file>
<file>tests/ParameterTest.php</file>
<file>tests/ParameterBagTest.php</file>
<file>tests/FixtureBagTest.php</file>
<file>tests/Definition/Object/SimpleObjectTest.php</file>
<file>tests/ObjectBagTest.php</file>
<file>tests/ObjectSetTest.php</file>
<file>tests/FixtureSetTest.php</file>
<file>tests/FixtureBuilder/BareFixtureSetTest.php</file>
<file>tests/Generator/ResolvedFixtureSetTest.php</file>
<file>tests/Generator/ResolvedValueWithFixtureSetTest.php</file>
<file>tests/Generator/Resolver/Fixture/TemplatingFixtureBagTest.php</file>
<file>tests/Generator/Resolver/UniqueValuesPoolTest.php</file>
<file>tests/FixtureBuilder/ExpressionLanguage/TokenTypeTest.php</file>
<file>tests/FixtureBuilder/ExpressionLanguage/TokenTest.php</file>
</testsuite>
<testsuite name="Independent tests">
<testsuite name="Tests">
<directory>tests</directory>
<exclude>tests/Bridge</exclude>
</testsuite>
Expand Down
17 changes: 17 additions & 0 deletions src/Generator/Resolver/Value/Chainable/EvaluatedValueResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Nelmio\Alice\Generator\Resolver\Value\Chainable;

use ErrorException;
use Nelmio\Alice\Definition\Value\EvaluatedValue;
use Nelmio\Alice\Definition\ValueInterface;
use Nelmio\Alice\FixtureInterface;
Expand All @@ -25,6 +26,10 @@
use Nelmio\Alice\Throwable\Exception\Generator\Resolver\UnresolvableValueExceptionFactory;
use Nelmio\Alice\Throwable\Exception\NoValueForCurrentException;
use Throwable;
use function error_reporting;
use function ErrorException;
use function restore_error_handler;
use function set_error_handler;

final class EvaluatedValueResolver implements ChainableValueResolverInterface
{
Expand Down Expand Up @@ -75,9 +80,21 @@ public function resolve(
};

try {
set_error_handler(function (int $errorNumber, string $errorString, string $errorFile, int $errorLine) {
$suppressed = !(error_reporting() & $errorNumber);

if ($suppressed) {
return false;
}

throw new ErrorException($errorString, 0, $errorNumber, $errorFile, $errorLine);
});

$evaluatedExpression = $evaluateExpression($expression);
} catch (Throwable $throwable) {
throw UnresolvableValueExceptionFactory::createForCouldNotEvaluateExpression($value, 0, $throwable);
} finally {
restore_error_handler();
}

return new ResolvedValueWithFixtureSet($evaluatedExpression, $fixtureSet);
Expand Down
8 changes: 3 additions & 5 deletions tests/DeepCloneTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use DateTime;
use DateTimeImmutable;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use stdClass;

Expand All @@ -24,11 +25,8 @@
*/
class DeepCloneTest extends TestCase
{
/**
* @dataProvider provideScalarValues
* @param mixed $value
*/
public function testDeepCloneScalarsReturnsScalar($value): void
#[DataProvider('provideScalarValues')]
public function testDeepCloneScalarsReturnsScalar(mixed $value): void
{
$clone = deep_clone($value);

Expand Down
5 changes: 2 additions & 3 deletions tests/Definition/Fixture/TemplatingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Nelmio\Alice\Definition\FlagBag;
use Nelmio\Alice\Definition\ServiceReference\FixtureReference;
use Nelmio\Alice\Definition\SpecificationBagFactory;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

/**
Expand All @@ -35,9 +36,7 @@ public function testIsImmutable(): void
self::assertTrue(true, 'Nothing to do.');
}

/**
* @dataProvider provideFlags
*/
#[DataProvider('provideFlags')]
public function testDetectTemplateFlags(SimpleFixtureWithFlags $fixture, bool $isATemplate, bool $extendsFixtures, array $extendedFixtures): void
{
$templating = new Templating($fixture);
Expand Down
5 changes: 2 additions & 3 deletions tests/Definition/Flag/OptionalFlagTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use InvalidArgumentException;
use Nelmio\Alice\Definition\FlagInterface;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

/**
Expand All @@ -36,9 +37,7 @@ public function testReadAccessorsReturnPropertiesValues(): void
self::assertEquals('%?', $flag->__toString());
}

/**
* @dataProvider providePercentageValues
*/
#[DataProvider('providePercentageValues')]
public function testThrowsExceptionIfPercentageValueIsInvalid(int $percentage, ?string $expectedMessage = null): void
{
try {
Expand Down
5 changes: 2 additions & 3 deletions tests/Definition/RangeNameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Nelmio\Alice\Definition;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

/**
Expand All @@ -21,9 +22,7 @@
*/
class RangeNameTest extends TestCase
{
/**
* @dataProvider provideRanges
*/
#[DataProvider('provideRanges')]
public function testReadAccessorsReturnPropertiesValues(array $input, array $expected): void
{
$name = 'user';
Expand Down
19 changes: 5 additions & 14 deletions tests/Definition/Value/DynamicArrayValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace Nelmio\Alice\Definition\Value;

use Nelmio\Alice\Definition\ValueInterface;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use stdClass;
use TypeError;
Expand All @@ -29,13 +30,8 @@ public function testIsAValue(): void
self::assertTrue(is_a(UniqueValue::class, ValueInterface::class, true));
}

/**
* @dataProvider provideInputTypes
* @param mixed $quantifier
* @param mixed $element
* @param mixed $errorMessage
*/
public function testThrowsErrorIfInvalidInputType($quantifier, $element, $errorMessage): void
#[DataProvider('provideInputTypes')]
public function testThrowsErrorIfInvalidInputType(mixed $quantifier, mixed $element, mixed $errorMessage): void
{
try {
new DynamicArrayValue($quantifier, $element);
Expand All @@ -45,13 +41,8 @@ public function testThrowsErrorIfInvalidInputType($quantifier, $element, $errorM
}
}

/**
* @dataProvider provideValues
* @param mixed $quantifier
* @param mixed $element
* @param mixed $expectedQuantifier
*/
public function testReadAccessorsReturnPropertiesValues($quantifier, $element, $expectedQuantifier): void
#[DataProvider('provideValues')]
public function testReadAccessorsReturnPropertiesValues(mixed $quantifier, mixed $element, mixed $expectedQuantifier): void
{
$value = new DynamicArrayValue($quantifier, $element);

Expand Down
11 changes: 3 additions & 8 deletions tests/Definition/Value/OptionalValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace Nelmio\Alice\Definition\Value;

use Nelmio\Alice\Definition\ValueInterface;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use stdClass;
use TypeError;
Expand All @@ -29,14 +30,8 @@ public function testIsAValue(): void
self::assertTrue(is_a(OptionalValue::class, ValueInterface::class, true));
}

/**
* @dataProvider provideInputValues
* @param mixed $quantifier
* @param mixed $firstMember
* @param mixed $secondMember
* @param mixed $errorMessage
*/
public function testThrowsErrorIfInvalidTypeGiven($quantifier, $firstMember, $secondMember, $errorMessage): void
#[DataProvider('provideInputValues')]
public function testThrowsErrorIfInvalidTypeGiven(mixed $quantifier, mixed $firstMember, mixed $secondMember, mixed $errorMessage): void
{
try {
new OptionalValue($quantifier, $firstMember, $secondMember);
Expand Down
9 changes: 3 additions & 6 deletions tests/Definition/Value/ParameterValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace Nelmio\Alice\Definition\Value;

use Nelmio\Alice\Definition\ValueInterface;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use stdClass;
use TypeError;
Expand All @@ -29,12 +30,8 @@ public function testIsAValue(): void
self::assertTrue(is_a(ParameterValue::class, ValueInterface::class, true));
}

/**
* @dataProvider provideInputValues
* @param mixed $value
* @param mixed $errorMessage
*/
public function testThrowsErrorIfInvalidTypeGiven($value, $errorMessage): void
#[DataProvider('provideInputValues')]
public function testThrowsErrorIfInvalidTypeGiven(mixed $value, mixed $errorMessage): void
{
try {
new ParameterValue($value);
Expand Down
8 changes: 3 additions & 5 deletions tests/Definition/Value/UniqueValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use InvalidArgumentException;
use Nelmio\Alice\Definition\ValueInterface;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use stdClass;
use const PHP_VERSION_ID;
Expand All @@ -30,11 +31,8 @@ public function testIsAValue(): void
self::assertTrue(is_a(UniqueValue::class, ValueInterface::class, true));
}

/**
* @dataProvider provideValues
* @param mixed $value
*/
public function testReadAccessorsReturnPropertiesValues($value): void
#[DataProvider('provideValues')]
public function testReadAccessorsReturnPropertiesValues(mixed $value): void
{
$id = 'Nelmio\Entity\User#user0#username';

Expand Down
8 changes: 3 additions & 5 deletions tests/FileLocator/DefaultFileLocatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use Nelmio\Alice\FileLocatorInterface;
use Nelmio\Alice\Throwable\Exception\FileLocator\FileNotFoundException;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use ReflectionObject;

Expand All @@ -39,11 +40,8 @@ public function testIsAFileLocator(): void
self::assertTrue(is_a(DefaultFileLocator::class, FileLocatorInterface::class, true));
}

/**
* @dataProvider provideAbsolutePaths
* @param mixed $path
*/
public function testCanDetectAbsolutePaths($path): void
#[DataProvider('provideAbsolutePaths')]
public function testCanDetectAbsolutePaths(mixed $path): void
{
$reflectionObject = new ReflectionObject($this->locator);
$methodReflection = $reflectionObject->getMethod('isAbsolutePath');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;

abstract class ChainableDenormalizerTest extends TestCase
abstract class ChainableDenormalizerTestCase extends TestCase
{
use ProphecyTrait;
use ReferenceProviderTrait;
Expand Down
Loading