Skip to content
Merged
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
7 changes: 3 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@
"knplabs/knp-menu": "^3.0",
"knplabs/knp-menu-bundle": "^3.0",
"masterminds/html5": "^2.7",
"matthiasnoback/symfony-config-test": "^4.2 || ^5.1",
"matthiasnoback/symfony-dependency-injection-test": "^4.0 || ^5.0",
"matthiasnoback/symfony-config-test": "^6.1",
"matthiasnoback/symfony-dependency-injection-test": "^6.1",
"phpstan/extension-installer": "^1.0",
"phpstan/phpdoc-parser": "^1.0",
"phpstan/phpstan": "^1.0 || ^2.0",
"phpstan/phpstan-phpunit": "^1.0 || ^2.0",
"phpstan/phpstan-strict-rules": "^1.0 || ^2.0",
"phpstan/phpstan-symfony": "^1.0 || ^2.0",
"phpunit/phpunit": "^9.5",
"phpunit/phpunit": "^10.5.54 || ^11.5.38 || ^12.3.10",
"psalm/plugin-phpunit": "^0.18 || ^0.19",
"psalm/plugin-symfony": "^5.0",
"rector/rector": "^1.1 || ^2.0",
Expand All @@ -67,7 +67,6 @@
"symfony/asset": "^6.4 || ^7.1",
"symfony/browser-kit": "^6.4 || ^7.1",
"symfony/filesystem": "^6.4 || ^7.1",
"symfony/phpunit-bridge": "^6.4 || ^7.1",
"symfony/security-bundle": "^6.4 || ^7.1",
"symfony/security-csrf": "^6.4 || ^7.1",
"symfony/twig-bundle": "^6.4 || ^7.1",
Expand Down
21 changes: 8 additions & 13 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,32 @@ DO NOT EDIT THIS FILE!
It's auto-generated by sonata-project/dev-kit package.
-->

<phpunit backupGlobals="false"
backupStaticAttributes="false"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
colors="true"
failOnWarning="true"
failOnRisky="true"
stopOnFailure="false"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
displayDetailsOnAllIssues="true"
bootstrap="tests/bootstrap.php"
>
<testsuites>
<testsuite name="SonataClassificationBundle Test Suite">
<directory suffix="Test.php">./tests/</directory>
<directory>./tests/</directory>
</testsuite>
</testsuites>

<coverage>
<source ignoreSuppressionOfDeprecations="true">
<include>
<directory suffix=".php">./src/</directory>
<directory>src</directory>
</include>
</coverage>

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

<extensions>
<extension class="DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension" />
<bootstrap class="DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension" />
</extensions>

<php>
<ini name="precision" value="8" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0" />
<env name="KERNEL_CLASS" value="\Sonata\ClassificationBundle\Tests\App\AppKernel" />
<server name="APP_ENV" value="test" force="true" />
<server name="APP_DEBUG" value="false" />
Expand Down
2 changes: 1 addition & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

$rectorConfig->sets([
LevelSetList::UP_TO_PHP_81,
PHPUnitSetList::PHPUNIT_90,
PHPUnitSetList::PHPUNIT_100,
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
]);

Expand Down
18 changes: 12 additions & 6 deletions tests/Admin/AdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Sonata\AdminBundle\Admin\AdminExtensionInterface;
use Sonata\ClassificationBundle\Admin\ContextAdmin;
use Sonata\ClassificationBundle\Admin\ContextAwareAdmin;
use Sonata\ClassificationBundle\Model\ContextAwareInterface;
use Sonata\ClassificationBundle\Model\ContextManagerInterface;

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

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

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

public function testGetPersistentParametersWithValidExtension(): void
{
$admin = $this->getMockForAbstractClass(ContextAwareAdmin::class, [
$this->contextManager,
]);
$admin = new
/** @phpstan-extends ContextAwareAdmin<ContextAwareInterface> */
class($this->contextManager) extends ContextAwareAdmin {
public function __construct(ContextManagerInterface $contextManager)
{
parent::__construct($contextManager);
}
};

$extension = $this->createMock(AdminExtensionInterface::class);
$extension->expects(static::once())->method('configurePersistentParameters')->with(
Expand Down
28 changes: 7 additions & 21 deletions tests/Block/Service/AbstractCategoriesBlockServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ protected function setUp(): void

public function testDefaultSettings(): void
{
$blockService = $this->getMockForAbstractClass(AbstractCategoriesBlockService::class, [
$this->twig, $this->contextManager, $this->categoryManager, $this->categoryAdmin,
]);
$blockService = new class($this->twig, $this->contextManager, $this->categoryManager, $this->categoryAdmin) extends AbstractCategoriesBlockService {};
$blockContext = $this->getBlockContext($blockService);

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

public function testLoad(): void
{
$category = $this->getMockBuilder(CategoryInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
$category = $this->createMock(CategoryInterface::class);
$category->expects(static::any())->method('getId')->willReturn(23);

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

$blockService = $this->getMockForAbstractClass(AbstractCategoriesBlockService::class, [
$this->twig, $this->contextManager, $this->categoryManager, $this->categoryAdmin,
]);
$blockService = new class($this->twig, $this->contextManager, $this->categoryManager, $this->categoryAdmin) extends AbstractCategoriesBlockService {};
$blockService->load($block);
}

public function testPrePersist(): void
{
$category = $this->getMockBuilder(CategoryInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
$category = $this->createMock(CategoryInterface::class);
$category->expects(static::any())->method('getId')->willReturn(23);

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

$blockService = $this->getMockForAbstractClass(AbstractCategoriesBlockService::class, [
$this->twig, $this->contextManager, $this->categoryManager, $this->categoryAdmin,
]);
$blockService = new class($this->twig, $this->contextManager, $this->categoryManager, $this->categoryAdmin) extends AbstractCategoriesBlockService {};
$blockService->prePersist($block);
}

public function testPreUpdate(): void
{
$category = $this->getMockBuilder(CategoryInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
$category = $this->createMock(CategoryInterface::class);
$category->expects(static::any())->method('getId')->willReturn(23);

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

$blockService = $this->getMockForAbstractClass(AbstractCategoriesBlockService::class, [
$this->twig, $this->contextManager, $this->categoryManager, $this->categoryAdmin,
]);
$blockService = new class($this->twig, $this->contextManager, $this->categoryManager, $this->categoryAdmin) extends AbstractCategoriesBlockService {};
$blockService->preUpdate($block);
}
}
28 changes: 7 additions & 21 deletions tests/Block/Service/AbstractCollectionsBlockServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ protected function setUp(): void

public function testDefaultSettings(): void
{
$blockService = $this->getMockForAbstractClass(AbstractCollectionsBlockService::class, [
$this->twig, $this->contextManager, $this->collectionManager, $this->collectionAdmin,
]);
$blockService = new class($this->twig, $this->contextManager, $this->collectionManager, $this->collectionAdmin) extends AbstractCollectionsBlockService {};
$blockContext = $this->getBlockContext($blockService);

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

public function testLoad(): void
{
$collection = $this->getMockBuilder(CollectionInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
$collection = $this->createMock(CollectionInterface::class);
$collection->expects(static::any())->method('getId')->willReturn(23);

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

$blockService = $this->getMockForAbstractClass(AbstractCollectionsBlockService::class, [
$this->twig, $this->contextManager, $this->collectionManager, $this->collectionAdmin,
]);
$blockService = new class($this->twig, $this->contextManager, $this->collectionManager, $this->collectionAdmin) extends AbstractCollectionsBlockService {};
$blockService->load($block);
}

public function testPrePersist(): void
{
$collection = $this->getMockBuilder(CollectionInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
$collection = $this->createMock(CollectionInterface::class);
$collection->expects(static::any())->method('getId')->willReturn(23);

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

$blockService = $this->getMockForAbstractClass(AbstractCollectionsBlockService::class, [
$this->twig, $this->contextManager, $this->collectionManager, $this->collectionAdmin,
]);
$blockService = new class($this->twig, $this->contextManager, $this->collectionManager, $this->collectionAdmin) extends AbstractCollectionsBlockService {};
$blockService->prePersist($block);
}

public function testPreUpdate(): void
{
$collection = $this->getMockBuilder(CollectionInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
$collection = $this->createMock(CollectionInterface::class);
$collection->expects(static::any())->method('getId')->willReturn(23);

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

$blockService = $this->getMockForAbstractClass(AbstractCollectionsBlockService::class, [
$this->twig, $this->contextManager, $this->collectionManager, $this->collectionAdmin,
]);
$blockService = new class($this->twig, $this->contextManager, $this->collectionManager, $this->collectionAdmin) extends AbstractCollectionsBlockService {};
$blockService->preUpdate($block);
}
}
28 changes: 7 additions & 21 deletions tests/Block/Service/AbstractTagsBlockServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ protected function setUp(): void

public function testDefaultSettings(): void
{
$blockService = $this->getMockForAbstractClass(AbstractTagsBlockService::class, [
$this->twig, $this->contextManager, $this->tagManager, $this->tagAdmin,
]);
$blockService = new class($this->twig, $this->contextManager, $this->tagManager, $this->tagAdmin) extends AbstractTagsBlockService {};
$blockContext = $this->getBlockContext($blockService);

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

public function testLoad(): void
{
$tag = $this->getMockBuilder(TagInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
$tag = $this->createMock(TagInterface::class);
$tag->expects(static::any())->method('getId')->willReturn(23);

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

$blockService = $this->getMockForAbstractClass(AbstractTagsBlockService::class, [
$this->twig, $this->contextManager, $this->tagManager, $this->tagAdmin,
]);
$blockService = new class($this->twig, $this->contextManager, $this->tagManager, $this->tagAdmin) extends AbstractTagsBlockService {};
$blockService->load($block);
}

public function testPrePersist(): void
{
$tag = $this->getMockBuilder(TagInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
$tag = $this->createMock(TagInterface::class);
$tag->expects(static::any())->method('getId')->willReturn(23);

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

$blockService = $this->getMockForAbstractClass(AbstractTagsBlockService::class, [
$this->twig, $this->contextManager, $this->tagManager, $this->tagAdmin,
]);
$blockService = new class($this->twig, $this->contextManager, $this->tagManager, $this->tagAdmin) extends AbstractTagsBlockService {};
$blockService->prePersist($block);
}

public function testPreUpdate(): void
{
$tag = $this->getMockBuilder(TagInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
$tag = $this->createMock(TagInterface::class);
$tag->expects(static::any())->method('getId')->willReturn(23);

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

$blockService = $this->getMockForAbstractClass(AbstractTagsBlockService::class, [
$this->twig, $this->contextManager, $this->tagManager, $this->tagAdmin,
]);
$blockService = new class($this->twig, $this->contextManager, $this->tagManager, $this->tagAdmin) extends AbstractTagsBlockService {};
$blockService->preUpdate($block);
}
}
Loading