Skip to content

Commit beb9d9f

Browse files
authored
Merge pull request #1496 from garak/upgrade-phpunit
⬆️ upgrade PHPUnit
2 parents 60f6c6f + 8fa307d commit beb9d9f

16 files changed

+47
-78
lines changed

.github/workflows/build.yaml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ jobs:
1515
- name: Setup PHP
1616
uses: shivammathur/setup-php@v2
1717
with:
18-
php-version: 8.1
18+
php-version: 8.3
1919
- run: |
20-
composer require --no-update doctrine/annotations:"^2.0" liip/imagine-bundle:"^2.8" phpstan/extension-installer phpstan/phpstan-phpunit:1.3.* phpstan/phpstan:1.9.*
21-
composer config --no-plugins allow-plugins.phpstan/extension-installer true
20+
composer require --no-update doctrine/annotations:"^2.0" liip/imagine-bundle:"^2.13" phpstan/phpstan:"^1.12"
2221
composer install --ignore-platform-reqs
2322
XDEBUG_MODE=off vendor/bin/phpstan
2423
cs-fixer:
@@ -38,7 +37,7 @@ jobs:
3837
- name: Checkout
3938
uses: actions/checkout@v4
4039
- name: Require the vendor
41-
run: composer require --dev --no-update vincentlanglet/twig-cs-fixer ^3.1
40+
run: composer require --dev --no-update vincentlanglet/twig-cs-fixer ^3.5
4241
- name: Update
4342
run: composer update --no-interaction --no-progress
4443
- name: Run
@@ -86,13 +85,13 @@ jobs:
8685
with_oneupbundle: false
8786
max_deprecations: 0
8887
- php: '8.3'
89-
symfony: '7.1.*'
88+
symfony: '7.2.*'
9089
dependencies: highest
9190
with_imagine: false
9291
with_oneupbundle: false
9392
max_deprecations: 0
9493
- php: '8.4'
95-
symfony: '7.2.*@dev'
94+
symfony: '7.3.*@dev'
9695
dependencies: highest
9796
with_imagine: false
9897
with_oneupbundle: false

composer.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
},
3232
"require-dev": {
3333
"ext-sqlite3": "*",
34-
"dg/bypass-finals": "^1.8",
34+
"dg/bypass-finals": "^1.9",
3535
"doctrine/common": "^3.0",
3636
"doctrine/doctrine-bundle": "^2.7",
3737
"doctrine/mongodb-odm": "^2.4",
@@ -41,23 +41,22 @@
4141
"league/flysystem-memory": "^2.0 || ^3.0",
4242
"matthiasnoback/symfony-dependency-injection-test": "^5.1",
4343
"mikey179/vfsstream": "^1.6.11",
44-
"phpunit/phpunit": "^9.6",
44+
"phpunit/phpunit": "^10.5 || ^11.5 || ^12.0",
4545
"symfony/asset": "^5.4 || ^6.0 || ^7.0",
4646
"symfony/browser-kit": "^5.4 || ^6.0 || ^7.0",
4747
"symfony/css-selector": "^5.4 || ^6.0 || ^7.0",
4848
"symfony/doctrine-bridge": "^5.4 || ^6.0 || ^7.0",
4949
"symfony/dom-crawler": "^5.4 || ^6.0 || ^7.0",
5050
"symfony/form": "^5.4 || ^6.0 || ^7.0",
5151
"symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0",
52-
"symfony/phpunit-bridge": "^7.0",
52+
"symfony/phpunit-bridge": "^7.2",
5353
"symfony/security-csrf": "^5.4 || ^6.0 || ^7.0",
5454
"symfony/translation": "^5.4 || ^6.0 || ^7.0",
5555
"symfony/twig-bridge": "^5.4 || ^6.0 || ^7.0",
5656
"symfony/twig-bundle": "^5.4 || ^6.0 || ^7.0",
5757
"symfony/validator": "^5.4 || ^6.0 || ^7.0",
5858
"symfony/var-dumper": "^5.4 || ^6.0 || ^7.0",
59-
"symfony/yaml": "^5.4 || ^6.0 || ^7.0",
60-
"yoast/phpunit-polyfills": "^2.0"
59+
"symfony/yaml": "^5.4 || ^6.0 || ^7.0"
6160
},
6261
"suggest": {
6362
"doctrine/doctrine-bundle": "For integration with Doctrine",

phpstan-baseline.neon

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,6 @@ parameters:
6565
count: 1
6666
path: tests/Injector/FileInjectorTest.php
6767

68-
-
69-
message: "#^Trying to mock an undefined method findOneBySlug\\(\\) on class Doctrine\\\\ORM\\\\EntityRepository\\.$#"
70-
count: 1
71-
path: tests/Naming/SlugNamerTest.php
72-
73-
-
74-
message: "#^Trying to mock an undefined method getFilesystem\\(\\) on class League\\\\Flysystem\\\\MountManager\\.$#"
75-
count: 1
76-
path: tests/Storage/Flysystem/MountManagerFlysystemStorageTest.php
77-
7868
-
7969
message: "#^Return type of call to method PHPUnit\\\\Framework\\\\TestCase\\:\\:createMock\\(\\) contains unresolvable type\\.$#"
8070
count: 4

phpunit.xml.dist

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,14 @@
1717
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0" />
1818
</php>
1919

20-
<coverage>
20+
<source>
2121
<include>
2222
<directory>./src</directory>
2323
</include>
24-
</coverage>
24+
</source>
2525

2626
<extensions>
27-
<extension class="Vich\UploaderBundle\Tests\BypassFinalHook"/>
27+
<bootstrap class="Vich\UploaderBundle\Tests\BypassFinalExtension"/>
28+
<bootstrap class="Symfony\Bridge\PhpUnit\SymfonyExtension"/>
2829
</extensions>
29-
30-
<listeners>
31-
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
32-
</listeners>
3330
</phpunit>

tests/BypassFinalExtension.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace Vich\UploaderBundle\Tests;
4+
5+
use DG\BypassFinals;
6+
use PHPUnit\Runner\Extension\Extension;
7+
use PHPUnit\Runner\Extension\Facade;
8+
use PHPUnit\Runner\Extension\ParameterCollection;
9+
use PHPUnit\TextUI\Configuration\Configuration;
10+
11+
final class BypassFinalExtension implements Extension
12+
{
13+
public function bootstrap(Configuration $configuration, Facade $facade, ParameterCollection $parameters): void
14+
{
15+
BypassFinals::enable();
16+
}
17+
}

tests/BypassFinalHook.php

Lines changed: 0 additions & 14 deletions
This file was deleted.

tests/Command/MappingDebugClassCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function testComplete(array $input, array $expectedSuggestions): void
4242
$this->assertEqualsCanonicalizing($expectedSuggestions, $tester->complete($input));
4343
}
4444

45-
public function provideCompletionSuggestions(): \Generator
45+
public static function provideCompletionSuggestions(): \Generator
4646
{
4747
yield 'fqcn' => [
4848
[''],

tests/Command/MappingDebugCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function testComplete(array $input, array $expectedSuggestions): void
4343
$this->assertEqualsCanonicalizing($expectedSuggestions, $tester->complete($input));
4444
}
4545

46-
public function provideCompletionSuggestions(): \Generator
46+
public static function provideCompletionSuggestions(): \Generator
4747
{
4848
yield 'mapping' => [
4949
[''],

tests/DummyEntity.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,12 @@
55
use Vich\UploaderBundle\Mapping\Annotation as Vich;
66

77
/**
8-
* @Vich\Uploadable
9-
*
108
* @author Dustin Dobervich <ddobervich@gmail.com>
119
*/
10+
#[Vich\Uploadable]
1211
class DummyEntity
1312
{
14-
/**
15-
* @Vich\UploadableField(mapping="dummy_file", fileNameProperty="fileName")
16-
*/
13+
#[Vich\UploadableField(mapping: 'dummy_file', fileNameProperty: 'fileName')]
1714
protected ?object $file = null;
1815

1916
protected ?string $fileName = null;

tests/EventListener/Doctrine/RemoveListenerTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ protected function setUp(): void
2828

2929
public function testPreRemove(): void
3030
{
31-
$this->object = $this->getEntityProxyMock();
31+
$this->object = $this->getEntityProxyMock('One');
3232

3333
$this->metadata
3434
->expects(self::once())
3535
->method('isUploadable')
36-
->with('VichUploaderEntityProxy')
36+
->with('VichUploaderEntityProxyOne')
3737
->willReturn(true);
3838

3939
$this->object
@@ -48,15 +48,15 @@ public function testPreRemove(): void
4848

4949
public function testPreRemoveSkipNonUploadable(): void
5050
{
51-
$this->object = $this->getEntityProxyMock();
51+
$this->object = $this->getEntityProxyMock('Two');
5252
$this->object
5353
->expects($this->never())
5454
->method('__load');
5555

5656
$this->metadata
5757
->expects(self::once())
5858
->method('isUploadable')
59-
->with('VichUploaderEntityProxy')
59+
->with('VichUploaderEntityProxyTwo')
6060
->willReturn(false);
6161

6262
$this->event = $this->getEventMock();
@@ -122,10 +122,10 @@ public function testPostFlushSkipsNonUploadable(): void
122122
$this->listener->postFlush();
123123
}
124124

125-
protected function getEntityProxyMock(): Proxy|MockObject
125+
private function getEntityProxyMock(string $postfix): Proxy|MockObject
126126
{
127127
return $this->getMockBuilder(Proxy::class)
128-
->setMockClassName('VichUploaderEntityProxy')
128+
->setMockClassName('VichUploaderEntityProxy'.$postfix)
129129
->getMock();
130130
}
131131
}

tests/Fixtures/TestBundle/src/Entity/Article.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,17 @@
55
use Vich\UploaderBundle\Mapping\Annotation as Vich;
66

77
/**
8-
* @Vich\Uploadable
9-
*
108
* @author Dustin Dobervich <ddobervich@gmail.com>
119
*/
10+
#[Vich\Uploadable]
1211
class Article
1312
{
14-
/**
15-
* @Vich\UploadableField(mapping="dummy_file", fileNameProperty="fileName")
16-
*/
13+
#[Vich\UploadableField(mapping: 'dummy_file', fileNameProperty: 'fileName')]
1714
protected ?object $attachment = null;
1815

1916
protected ?string $attachmentName = null;
2017

21-
/**
22-
* @Vich\UploadableField(mapping="dummy_image", fileNameProperty="imageName", originalName="originalNameField", mimeType="mimeTypeField", size="sizeField")
23-
*/
18+
#[Vich\UploadableField(mapping: 'dummy_image', fileNameProperty: 'imageName', size: 'sizeField', mimeType: 'mimeTypeField', originalName: 'originalNameField')]
2419
protected ?object $image = null;
2520

2621
protected ?string $imageName = null;

tests/Fixtures/TestBundle/src/Entity/Image.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@
33
namespace Vich\TestBundle\Entity;
44

55
use Symfony\Component\HttpFoundation\File\File;
6-
use Symfony\Component\HttpFoundation\File\UploadedFile;
76
use Vich\UploaderBundle\Mapping\Annotation as Vich;
87

9-
/**
10-
* @Vich\Uploadable
11-
*/
8+
#[Vich\Uploadable]
129
class Image
1310
{
1411
protected ?int $id = null;
@@ -17,9 +14,7 @@ class Image
1714

1815
protected ?\DateTime $updatedAt = null;
1916

20-
/**
21-
* @Vich\UploadableField(mapping="image_mapping", fileNameProperty="imageName")
22-
*/
17+
#[Vich\UploadableField(mapping: 'image_mapping', fileNameProperty: 'imageName')]
2318
protected ?File $imageFile = null;
2419

2520
protected ?string $imageName = null;

tests/Form/Type/VichImageTypeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public function testLiipImagineBundleIntegration(
219219
self::assertEquals($vars, $view->vars);
220220
}
221221

222-
public function getLiipImagineBundleIntegrationData(): array
222+
public static function getLiipImagineBundleIntegrationData(): array
223223
{
224224
$field = 'image';
225225
$object = new Product();

tests/Metadata/Driver/AnnotationDriverTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Vich\UploaderBundle\Metadata\Driver\AnnotationDriver;
1515
use Vich\UploaderBundle\Tests\DummyEntity;
1616
use Vich\UploaderBundle\Tests\DummyFile;
17-
use Yoast\PHPUnitPolyfills\Polyfills\AssertObjectProperty;
1817

1918
/**
2019
* AnnotationDriverTest.
@@ -25,8 +24,6 @@
2524
*/
2625
final class AnnotationDriverTest extends TestCase
2726
{
28-
use AssertObjectProperty;
29-
3027
private Connection|MockObject $connection;
3128

3229
private EntityManagerInterface|MockObject $entityManager;

tests/Metadata/Driver/FileDriverTestCase.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@
88
use Vich\TestBundle\Entity\Article;
99
use Vich\TestBundle\Entity\Product;
1010
use Vich\UploaderBundle\Metadata\ClassMetadata;
11-
use Yoast\PHPUnitPolyfills\Polyfills\AssertObjectProperty;
1211

1312
abstract class FileDriverTestCase extends TestCase
1413
{
15-
use AssertObjectProperty;
16-
1714
/**
1815
* @dataProvider classesProvider
1916
*/

tests/TestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ abstract class TestCase extends BaseTestCase
1818
protected function getUploadedFileMock(): UploadedFile|MockObject
1919
{
2020
return $this->getMockBuilder(UploadedFile::class)
21-
->setConstructorArgs(['lala', 'lala', $mimeType = null, $error = 9, $test = true])
21+
->setConstructorArgs(['lala', 'lala', null, 9, true])
2222
->getMock();
2323
}
2424

0 commit comments

Comments
 (0)