Skip to content

Commit

Permalink
Use PHPUnit 11
Browse files Browse the repository at this point in the history
  • Loading branch information
olvlvl committed Nov 2, 2024
1 parent 03d76d7 commit 08100b2
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 52 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"symfony/dependency-injection": "^7.0"
},
"require-dev": {
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^10.5",
"phpstan/phpstan": "^1.12",
"phpunit/phpunit": "^11.4",
"symfony/config": "^7.0"
},
"autoload": {
Expand Down
10 changes: 8 additions & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
colors="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.4/phpunit.xsd"
beStrictAboutCoverageMetadata="true"
beStrictAboutOutputDuringTests="true"
bootstrap="tests/bootstrap.php"
colors="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true"
displayDetailsOnPhpunitDeprecations="true"
executionOrder="depends,defects"
>
<testsuites>
<testsuite name="olvlvl/symfony-dependency-injection-proxy">
Expand Down
5 changes: 2 additions & 3 deletions tests/FactoryRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@
use olvlvl\SymfonyDependencyInjectionProxy\FactoryRenderer;
use olvlvl\SymfonyDependencyInjectionProxy\MethodRenderer;
use PHPUnit\Framework\Assert;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use ReflectionMethod;
use Serializable;

/**
* @group unit
*/
#[Group('unit')]
final class FactoryRendererTest extends TestCase
{
public function testRender(): void
Expand Down
9 changes: 4 additions & 5 deletions tests/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
namespace tests\olvlvl\SymfonyDependencyInjectionProxy;

use olvlvl\SymfonyDependencyInjectionProxy\ProxyDumper;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface;
use Symfony\Component\DependencyInjection\Alias;
Expand All @@ -29,16 +31,13 @@

use function uniqid;

/**
* @group integration
*/
#[Group('integration')]
final class IntegrationTest extends TestCase
{
/**
* @dataProvider provideDefinition
*
* @param Definition[] $definitions
*/
#[DataProvider('provideDefinition')]
public function testCompilation(array $definitions, callable $assert, ?callable $tweakBuilder = null): void
{
$builder = new ContainerBuilder();
Expand Down
23 changes: 7 additions & 16 deletions tests/InterfaceResolver/BasicInterfaceResolverTest.php
Original file line number Diff line number Diff line change
@@ -1,33 +1,25 @@
<?php

/*
* This file is part of the olvlvl/symfony-dependency-injection-proxy package.
*
* (c) Olivier Laviale <olivier.laviale@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace tests\olvlvl\SymfonyDependencyInjectionProxy\InterfaceResolver;

use ArrayIterator;
use DateTimeImmutable;
use DateTimeInterface;
use LogicException;
use olvlvl\SymfonyDependencyInjectionProxy\InterfaceResolver\BasicInterfaceResolver;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use Throwable;

/**
* @group unit
*/
#[Group('unit')]
final class BasicInterfaceResolverTest extends TestCase
{
/**
* @test
* @throws Throwable
*/
#[Test]
public function shouldFailIfClassImplementsManyInterfaces(): void
{
$stu = new BasicInterfaceResolver();
Expand All @@ -40,9 +32,9 @@ public function shouldFailIfClassImplementsManyInterfaces(): void
}

/**
* @test
* @throws Throwable
*/
#[Test]
public function shouldFailIfClassDoesNotExist(): void
{
$stu = new BasicInterfaceResolver();
Expand All @@ -55,12 +47,11 @@ public function shouldFailIfClassDoesNotExist(): void
}

/**
* @dataProvider provideResolveInterface
*
* @param class-string $class
*
* @throws Throwable
*/
#[DataProvider('provideResolveInterface')]
public function testResolveInterface(string $class, string $expected): void
{
$stu = new BasicInterfaceResolver();
Expand Down
10 changes: 4 additions & 6 deletions tests/MethodRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,18 @@
namespace tests\olvlvl\SymfonyDependencyInjectionProxy;

use olvlvl\SymfonyDependencyInjectionProxy\MethodRenderer;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use ReflectionMethod;
use tests\olvlvl\SymfonyDependencyInjectionProxy\cases\SampleInterfaceForMethodRenderer70;
use tests\olvlvl\SymfonyDependencyInjectionProxy\cases\SampleInterfaceForMethodRenderer72;
use tests\olvlvl\SymfonyDependencyInjectionProxy\cases\SampleInterfaceForMethodRenderer80;

/**
* @group unit
*/
#[Group('unit')]
final class MethodRendererTest extends TestCase
{
/**
* @dataProvider provideRender
*/
#[DataProvider('provideRender')]
public function testRender(ReflectionMethod $method, string $getterCode, string $expected): void
{
$stu = new MethodRenderer();
Expand Down
26 changes: 8 additions & 18 deletions tests/ProxyDumperTest.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
<?php

/*
* This file is part of the olvlvl/symfony-dependency-injection-proxy package.
*
* (c) Olivier Laviale <olivier.laviale@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace tests\olvlvl\SymfonyDependencyInjectionProxy;

use ArrayAccess;
Expand All @@ -18,18 +9,17 @@
use olvlvl\SymfonyDependencyInjectionProxy\FactoryRenderer;
use olvlvl\SymfonyDependencyInjectionProxy\InterfaceResolver;
use olvlvl\SymfonyDependencyInjectionProxy\ProxyDumper;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\Definition;
use Throwable;

/**
* @group unit
*/
#[Group('unit')]
final class ProxyDumperTest extends TestCase
{
/**
* @dataProvider provideIsProxyCandidate
*/
#[DataProvider('provideIsProxyCandidate')]
public function testIsProxyCandidate(Definition $definition, bool $expected): void
{
$stu = new ProxyDumper(
Expand Down Expand Up @@ -64,9 +54,9 @@ public static function provideIsProxyCandidate(): array
}

/**
* @test
* @throws Throwable
*/
#[Test]
public function shouldFailIfFactoryCodeIsEmpty(): void
{
$stu = new ProxyDumper(
Expand All @@ -81,8 +71,8 @@ public function shouldFailIfFactoryCodeIsEmpty(): void

/**
* @throws Throwable
* @dataProvider provideGetProxyFactoryCode
*/
#[DataProvider('provideGetProxyFactoryCode')]
public function testGetProxyFactoryCode(string $id, bool $private, bool $shared, string $expectedStore): void
{
$definition = (new Definition())
Expand Down Expand Up @@ -132,7 +122,7 @@ public static function provideGetProxyFactoryCode(): array
}

/**
* @see https://github.com/symfony/symfony/issues/28852
* @link https://github.com/symfony/symfony/issues/28852
*/
public function testGetProxyCode(): void
{
Expand Down

0 comments on commit 08100b2

Please sign in to comment.