Skip to content

Commit 3f47f95

Browse files
Fix
1 parent 9679844 commit 3f47f95

13 files changed

Lines changed: 135 additions & 98 deletions

tests/Admin/AdminTest.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,19 @@ public function testGetPersistentParametersWithNoExtension(): void
4444
'hide_context' => 0,
4545
];
4646

47-
$admin = $this->getMockForAbstractClass(ContextAwareAdmin::class, [
48-
$this->contextManager,
49-
]);
47+
$admin = new class($this->contextManager) extends ContextAwareAdmin {};
5048

5149
static::assertSame($expected, $admin->getPersistentParameters());
5250
}
5351

5452
public function testGetPersistentParametersWithValidExtension(): void
5553
{
56-
$admin = $this->getMockForAbstractClass(ContextAwareAdmin::class, [
57-
$this->contextManager,
58-
]);
54+
$admin = new class($this->contextManager) extends ContextAwareAdmin {
55+
public function __construct(ContextManagerInterface $contextManager)
56+
{
57+
parent::__construct($contextManager);
58+
}
59+
};
5960

6061
$extension = $this->createMock(AdminExtensionInterface::class);
6162
$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
}

tests/Controller/CategoryAdminControllerTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,12 @@ public function testTreeAction(string|false $context, array $categories): void
265265

266266
$categoriesMock = [];
267267
foreach ($categories as $category) {
268-
$categoryMock = $this->getMockForAbstractClass(Category::class);
268+
$categoryMock = new class extends Category {
269+
public function getId()
270+
{
271+
return 42;
272+
}
273+
};
269274
$categoryMock->setName($category[0]);
270275

271276
$contextId = $category[1];

tests/Functional/Admin/CategoryAdminTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
namespace Sonata\ClassificationBundle\Tests\Functional\Admin;
1515

16-
use PHPUnit\Framework\Attributes\DataProvider;
1716
use Doctrine\ORM\EntityManagerInterface;
17+
use PHPUnit\Framework\Attributes\DataProvider;
1818
use Sonata\ClassificationBundle\Tests\App\Entity\Category;
1919
use Sonata\ClassificationBundle\Tests\App\Entity\Context;
2020
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@@ -57,7 +57,6 @@ public static function provideCrudUrlsCases(): iterable
5757
}
5858

5959
/**
60-
*
6160
* @param array<string, mixed> $parameters
6261
* @param array<string, mixed> $fieldValues
6362
*/

tests/Functional/Admin/CollectionAdminTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
namespace Sonata\ClassificationBundle\Tests\Functional\Admin;
1515

16-
use PHPUnit\Framework\Attributes\DataProvider;
1716
use Doctrine\ORM\EntityManagerInterface;
17+
use PHPUnit\Framework\Attributes\DataProvider;
1818
use Sonata\ClassificationBundle\Tests\App\Entity\Collection;
1919
use Sonata\ClassificationBundle\Tests\App\Entity\Context;
2020
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@@ -47,7 +47,6 @@ public static function provideCrudUrlsCases(): iterable
4747
}
4848

4949
/**
50-
*
5150
* @param array<string, mixed> $parameters
5251
* @param array<string, mixed> $fieldValues
5352
*/

tests/Functional/Admin/ContextAdminTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
namespace Sonata\ClassificationBundle\Tests\Functional\Admin;
1515

16-
use PHPUnit\Framework\Attributes\DataProvider;
1716
use Doctrine\ORM\EntityManagerInterface;
17+
use PHPUnit\Framework\Attributes\DataProvider;
1818
use Sonata\ClassificationBundle\Tests\App\Entity\Context;
1919
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
2020

@@ -46,7 +46,6 @@ public static function provideCrudUrlsCases(): iterable
4646
}
4747

4848
/**
49-
*
5049
* @param array<string, mixed> $parameters
5150
* @param array<string, mixed> $fieldValues
5251
*/

tests/Functional/Admin/TagAdminTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
namespace Sonata\ClassificationBundle\Tests\Functional\Admin;
1515

16-
use PHPUnit\Framework\Attributes\DataProvider;
1716
use Doctrine\ORM\EntityManagerInterface;
17+
use PHPUnit\Framework\Attributes\DataProvider;
1818
use Sonata\ClassificationBundle\Tests\App\Entity\Context;
1919
use Sonata\ClassificationBundle\Tests\App\Entity\Tag;
2020
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@@ -47,7 +47,6 @@ public static function provideCrudUrlsCases(): iterable
4747
}
4848

4949
/**
50-
*
5150
* @param array<string, mixed> $parameters
5251
* @param array<string, mixed> $fieldValues
5352
*/

0 commit comments

Comments
 (0)