Skip to content

Commit 0112a49

Browse files
authored
Merge 4.x into 5.x
2 parents 1a4b89b + 822c572 commit 0112a49

18 files changed

+165
-194
lines changed

composer.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@
4949
"knplabs/knp-menu": "^3.0",
5050
"knplabs/knp-menu-bundle": "^3.0",
5151
"masterminds/html5": "^2.7",
52-
"matthiasnoback/symfony-config-test": "^4.2 || ^5.1",
53-
"matthiasnoback/symfony-dependency-injection-test": "^4.0 || ^5.0",
52+
"matthiasnoback/symfony-config-test": "^6.1",
53+
"matthiasnoback/symfony-dependency-injection-test": "^6.1",
5454
"phpstan/extension-installer": "^1.0",
5555
"phpstan/phpdoc-parser": "^1.0",
5656
"phpstan/phpstan": "^1.0 || ^2.0",
5757
"phpstan/phpstan-phpunit": "^1.0 || ^2.0",
5858
"phpstan/phpstan-strict-rules": "^1.0 || ^2.0",
5959
"phpstan/phpstan-symfony": "^1.0 || ^2.0",
60-
"phpunit/phpunit": "^9.5",
60+
"phpunit/phpunit": "^10.5.54 || ^11.5.38 || ^12.3.10",
6161
"psalm/plugin-phpunit": "^0.18 || ^0.19",
6262
"psalm/plugin-symfony": "^5.0",
6363
"rector/rector": "^1.1 || ^2.0",
@@ -67,7 +67,6 @@
6767
"symfony/asset": "^6.4 || ^7.1",
6868
"symfony/browser-kit": "^6.4 || ^7.1",
6969
"symfony/filesystem": "^6.4 || ^7.1",
70-
"symfony/phpunit-bridge": "^6.4 || ^7.1",
7170
"symfony/security-bundle": "^6.4 || ^7.1",
7271
"symfony/security-csrf": "^6.4 || ^7.1",
7372
"symfony/twig-bundle": "^6.4 || ^7.1",

phpunit.xml.dist

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,32 @@ DO NOT EDIT THIS FILE!
66
It's auto-generated by sonata-project/dev-kit package.
77
-->
88

9-
<phpunit backupGlobals="false"
10-
backupStaticAttributes="false"
9+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1110
colors="true"
1211
failOnWarning="true"
1312
failOnRisky="true"
14-
stopOnFailure="false"
13+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
14+
displayDetailsOnAllIssues="true"
1515
bootstrap="tests/bootstrap.php"
1616
>
1717
<testsuites>
1818
<testsuite name="SonataClassificationBundle Test Suite">
19-
<directory suffix="Test.php">./tests/</directory>
19+
<directory>./tests/</directory>
2020
</testsuite>
2121
</testsuites>
2222

23-
<coverage>
23+
<source ignoreSuppressionOfDeprecations="true">
2424
<include>
25-
<directory suffix=".php">./src/</directory>
25+
<directory>src</directory>
2626
</include>
27-
</coverage>
28-
29-
<listeners>
30-
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
31-
</listeners>
27+
</source>
3228

3329
<extensions>
34-
<extension class="DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension" />
30+
<bootstrap class="DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension" />
3531
</extensions>
3632

3733
<php>
3834
<ini name="precision" value="8" />
39-
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0" />
4035
<env name="KERNEL_CLASS" value="\Sonata\ClassificationBundle\Tests\App\AppKernel" />
4136
<server name="APP_ENV" value="test" force="true" />
4237
<server name="APP_DEBUG" value="false" />

rector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
$rectorConfig->sets([
3636
LevelSetList::UP_TO_PHP_81,
37-
PHPUnitSetList::PHPUNIT_90,
37+
PHPUnitSetList::PHPUNIT_100,
3838
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
3939
]);
4040

tests/Admin/AdminTest.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Sonata\AdminBundle\Admin\AdminExtensionInterface;
1919
use Sonata\ClassificationBundle\Admin\ContextAdmin;
2020
use Sonata\ClassificationBundle\Admin\ContextAwareAdmin;
21+
use Sonata\ClassificationBundle\Model\ContextAwareInterface;
2122
use Sonata\ClassificationBundle\Model\ContextManagerInterface;
2223

2324
final class AdminTest extends TestCase
@@ -44,18 +45,23 @@ public function testGetPersistentParametersWithNoExtension(): void
4445
'hide_context' => 0,
4546
];
4647

47-
$admin = $this->getMockForAbstractClass(ContextAwareAdmin::class, [
48-
$this->contextManager,
49-
]);
48+
$admin = new
49+
/** @phpstan-extends ContextAwareAdmin<ContextAwareInterface> */
50+
class($this->contextManager) extends ContextAwareAdmin {};
5051

5152
static::assertSame($expected, $admin->getPersistentParameters());
5253
}
5354

5455
public function testGetPersistentParametersWithValidExtension(): void
5556
{
56-
$admin = $this->getMockForAbstractClass(ContextAwareAdmin::class, [
57-
$this->contextManager,
58-
]);
57+
$admin = new
58+
/** @phpstan-extends ContextAwareAdmin<ContextAwareInterface> */
59+
class($this->contextManager) extends ContextAwareAdmin {
60+
public function __construct(ContextManagerInterface $contextManager)
61+
{
62+
parent::__construct($contextManager);
63+
}
64+
};
5965

6066
$extension = $this->createMock(AdminExtensionInterface::class);
6167
$extension->expects(static::once())->method('configurePersistentParameters')->with(

tests/Block/Service/AbstractCategoriesBlockServiceTest.php

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ protected function setUp(): void
5252

5353
public function testDefaultSettings(): void
5454
{
55-
$blockService = $this->getMockForAbstractClass(AbstractCategoriesBlockService::class, [
56-
$this->twig, $this->contextManager, $this->categoryManager, $this->categoryAdmin,
57-
]);
55+
$blockService = new class($this->twig, $this->contextManager, $this->categoryManager, $this->categoryAdmin) extends AbstractCategoriesBlockService {};
5856
$blockContext = $this->getBlockContext($blockService);
5957

6058
$this->assertSettings([
@@ -71,9 +69,7 @@ public function testDefaultSettings(): void
7169

7270
public function testLoad(): void
7371
{
74-
$category = $this->getMockBuilder(CategoryInterface::class)
75-
->disableOriginalConstructor()
76-
->getMockForAbstractClass();
72+
$category = $this->createMock(CategoryInterface::class);
7773
$category->expects(static::any())->method('getId')->willReturn(23);
7874

7975
$this->categoryManager->expects(static::any())
@@ -90,17 +86,13 @@ public function testLoad(): void
9086
->method('setSetting')
9187
->with(static::equalTo('categoryId'), static::equalTo($category));
9288

93-
$blockService = $this->getMockForAbstractClass(AbstractCategoriesBlockService::class, [
94-
$this->twig, $this->contextManager, $this->categoryManager, $this->categoryAdmin,
95-
]);
89+
$blockService = new class($this->twig, $this->contextManager, $this->categoryManager, $this->categoryAdmin) extends AbstractCategoriesBlockService {};
9690
$blockService->load($block);
9791
}
9892

9993
public function testPrePersist(): void
10094
{
101-
$category = $this->getMockBuilder(CategoryInterface::class)
102-
->disableOriginalConstructor()
103-
->getMockForAbstractClass();
95+
$category = $this->createMock(CategoryInterface::class);
10496
$category->expects(static::any())->method('getId')->willReturn(23);
10597

10698
$block = $this->createMock(BlockInterface::class);
@@ -112,17 +104,13 @@ public function testPrePersist(): void
112104
->method('setSetting')
113105
->with(static::equalTo('categoryId'), static::equalTo(23));
114106

115-
$blockService = $this->getMockForAbstractClass(AbstractCategoriesBlockService::class, [
116-
$this->twig, $this->contextManager, $this->categoryManager, $this->categoryAdmin,
117-
]);
107+
$blockService = new class($this->twig, $this->contextManager, $this->categoryManager, $this->categoryAdmin) extends AbstractCategoriesBlockService {};
118108
$blockService->prePersist($block);
119109
}
120110

121111
public function testPreUpdate(): void
122112
{
123-
$category = $this->getMockBuilder(CategoryInterface::class)
124-
->disableOriginalConstructor()
125-
->getMockForAbstractClass();
113+
$category = $this->createMock(CategoryInterface::class);
126114
$category->expects(static::any())->method('getId')->willReturn(23);
127115

128116
$block = $this->createMock(BlockInterface::class);
@@ -134,9 +122,7 @@ public function testPreUpdate(): void
134122
->method('setSetting')
135123
->with(static::equalTo('categoryId'), static::equalTo(23));
136124

137-
$blockService = $this->getMockForAbstractClass(AbstractCategoriesBlockService::class, [
138-
$this->twig, $this->contextManager, $this->categoryManager, $this->categoryAdmin,
139-
]);
125+
$blockService = new class($this->twig, $this->contextManager, $this->categoryManager, $this->categoryAdmin) extends AbstractCategoriesBlockService {};
140126
$blockService->preUpdate($block);
141127
}
142128
}

tests/Block/Service/AbstractCollectionsBlockServiceTest.php

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ protected function setUp(): void
5252

5353
public function testDefaultSettings(): void
5454
{
55-
$blockService = $this->getMockForAbstractClass(AbstractCollectionsBlockService::class, [
56-
$this->twig, $this->contextManager, $this->collectionManager, $this->collectionAdmin,
57-
]);
55+
$blockService = new class($this->twig, $this->contextManager, $this->collectionManager, $this->collectionAdmin) extends AbstractCollectionsBlockService {};
5856
$blockContext = $this->getBlockContext($blockService);
5957

6058
$this->assertSettings([
@@ -71,9 +69,7 @@ public function testDefaultSettings(): void
7169

7270
public function testLoad(): void
7371
{
74-
$collection = $this->getMockBuilder(CollectionInterface::class)
75-
->disableOriginalConstructor()
76-
->getMockForAbstractClass();
72+
$collection = $this->createMock(CollectionInterface::class);
7773
$collection->expects(static::any())->method('getId')->willReturn(23);
7874

7975
$this->collectionManager->expects(static::any())
@@ -90,17 +86,13 @@ public function testLoad(): void
9086
->method('setSetting')
9187
->with(static::equalTo('collectionId'), static::equalTo($collection));
9288

93-
$blockService = $this->getMockForAbstractClass(AbstractCollectionsBlockService::class, [
94-
$this->twig, $this->contextManager, $this->collectionManager, $this->collectionAdmin,
95-
]);
89+
$blockService = new class($this->twig, $this->contextManager, $this->collectionManager, $this->collectionAdmin) extends AbstractCollectionsBlockService {};
9690
$blockService->load($block);
9791
}
9892

9993
public function testPrePersist(): void
10094
{
101-
$collection = $this->getMockBuilder(CollectionInterface::class)
102-
->disableOriginalConstructor()
103-
->getMockForAbstractClass();
95+
$collection = $this->createMock(CollectionInterface::class);
10496
$collection->expects(static::any())->method('getId')->willReturn(23);
10597

10698
$block = $this->createMock(BlockInterface::class);
@@ -112,17 +104,13 @@ public function testPrePersist(): void
112104
->method('setSetting')
113105
->with(static::equalTo('collectionId'), static::equalTo(23));
114106

115-
$blockService = $this->getMockForAbstractClass(AbstractCollectionsBlockService::class, [
116-
$this->twig, $this->contextManager, $this->collectionManager, $this->collectionAdmin,
117-
]);
107+
$blockService = new class($this->twig, $this->contextManager, $this->collectionManager, $this->collectionAdmin) extends AbstractCollectionsBlockService {};
118108
$blockService->prePersist($block);
119109
}
120110

121111
public function testPreUpdate(): void
122112
{
123-
$collection = $this->getMockBuilder(CollectionInterface::class)
124-
->disableOriginalConstructor()
125-
->getMockForAbstractClass();
113+
$collection = $this->createMock(CollectionInterface::class);
126114
$collection->expects(static::any())->method('getId')->willReturn(23);
127115

128116
$block = $this->createMock(BlockInterface::class);
@@ -134,9 +122,7 @@ public function testPreUpdate(): void
134122
->method('setSetting')
135123
->with(static::equalTo('collectionId'), static::equalTo(23));
136124

137-
$blockService = $this->getMockForAbstractClass(AbstractCollectionsBlockService::class, [
138-
$this->twig, $this->contextManager, $this->collectionManager, $this->collectionAdmin,
139-
]);
125+
$blockService = new class($this->twig, $this->contextManager, $this->collectionManager, $this->collectionAdmin) extends AbstractCollectionsBlockService {};
140126
$blockService->preUpdate($block);
141127
}
142128
}

tests/Block/Service/AbstractTagsBlockServiceTest.php

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ protected function setUp(): void
5252

5353
public function testDefaultSettings(): void
5454
{
55-
$blockService = $this->getMockForAbstractClass(AbstractTagsBlockService::class, [
56-
$this->twig, $this->contextManager, $this->tagManager, $this->tagAdmin,
57-
]);
55+
$blockService = new class($this->twig, $this->contextManager, $this->tagManager, $this->tagAdmin) extends AbstractTagsBlockService {};
5856
$blockContext = $this->getBlockContext($blockService);
5957

6058
$this->assertSettings([
@@ -71,9 +69,7 @@ public function testDefaultSettings(): void
7169

7270
public function testLoad(): void
7371
{
74-
$tag = $this->getMockBuilder(TagInterface::class)
75-
->disableOriginalConstructor()
76-
->getMockForAbstractClass();
72+
$tag = $this->createMock(TagInterface::class);
7773
$tag->expects(static::any())->method('getId')->willReturn(23);
7874

7975
$this->tagManager->expects(static::any())
@@ -90,17 +86,13 @@ public function testLoad(): void
9086
->method('setSetting')
9187
->with(static::equalTo('tagId'), static::equalTo($tag));
9288

93-
$blockService = $this->getMockForAbstractClass(AbstractTagsBlockService::class, [
94-
$this->twig, $this->contextManager, $this->tagManager, $this->tagAdmin,
95-
]);
89+
$blockService = new class($this->twig, $this->contextManager, $this->tagManager, $this->tagAdmin) extends AbstractTagsBlockService {};
9690
$blockService->load($block);
9791
}
9892

9993
public function testPrePersist(): void
10094
{
101-
$tag = $this->getMockBuilder(TagInterface::class)
102-
->disableOriginalConstructor()
103-
->getMockForAbstractClass();
95+
$tag = $this->createMock(TagInterface::class);
10496
$tag->expects(static::any())->method('getId')->willReturn(23);
10597

10698
$block = $this->createMock(BlockInterface::class);
@@ -112,17 +104,13 @@ public function testPrePersist(): void
112104
->method('setSetting')
113105
->with(static::equalTo('tagId'), static::equalTo(23));
114106

115-
$blockService = $this->getMockForAbstractClass(AbstractTagsBlockService::class, [
116-
$this->twig, $this->contextManager, $this->tagManager, $this->tagAdmin,
117-
]);
107+
$blockService = new class($this->twig, $this->contextManager, $this->tagManager, $this->tagAdmin) extends AbstractTagsBlockService {};
118108
$blockService->prePersist($block);
119109
}
120110

121111
public function testPreUpdate(): void
122112
{
123-
$tag = $this->getMockBuilder(TagInterface::class)
124-
->disableOriginalConstructor()
125-
->getMockForAbstractClass();
113+
$tag = $this->createMock(TagInterface::class);
126114
$tag->expects(static::any())->method('getId')->willReturn(23);
127115

128116
$block = $this->createMock(BlockInterface::class);
@@ -134,9 +122,7 @@ public function testPreUpdate(): void
134122
->method('setSetting')
135123
->with(static::equalTo('tagId'), static::equalTo(23));
136124

137-
$blockService = $this->getMockForAbstractClass(AbstractTagsBlockService::class, [
138-
$this->twig, $this->contextManager, $this->tagManager, $this->tagAdmin,
139-
]);
125+
$blockService = new class($this->twig, $this->contextManager, $this->tagManager, $this->tagAdmin) extends AbstractTagsBlockService {};
140126
$blockService->preUpdate($block);
141127
}
142128
}

0 commit comments

Comments
 (0)