Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for latest sonata dependencies #826

Merged
merged 2 commits into from
Jul 20, 2023
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
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
],
"require": {
"php": "^8.1",
"sonata-project/block-bundle": "^3.23.0 || ^4.5.1",
"sonata-project/form-extensions": "^0.1.1 || ^1.4",
"sonata-project/block-bundle": "^4.21 || ^5.0",
"sonata-project/form-extensions": "^1.19 || ^2.0",
"symfony/dependency-injection": "^5.4 || ^6.2",
"symfony/event-dispatcher": "^5.4 || ^6.2",
"symfony/expression-language": "^5.4 || ^6.2",
Expand Down
11 changes: 5 additions & 6 deletions src/Block/Service/GDPRInformationBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

namespace Nucleos\GDPRBundle\Block\Service;

use LogicException;
use Sonata\BlockBundle\Block\BlockContextInterface;
use Sonata\BlockBundle\Block\Service\AbstractBlockService;
use Sonata\BlockBundle\Block\Service\EditableBlockService;
Expand Down Expand Up @@ -56,11 +55,11 @@
'block' => $blockContext->getBlock(),
];

if (!\is_string($blockContext->getTemplate())) {
throw new LogicException('Cannot render block without template');
}

return $this->renderPrivateResponse($blockContext->getTemplate(), $parameters, $response);
return $this
->renderResponse($blockContext->getTemplate(), $parameters, $response)
->setTtl(0)

Check warning on line 60 in src/Block/Service/GDPRInformationBlockService.php

View workflow job for this annotation

GitHub Actions / run / Mutation Tests (8.2)

Escaped Mutant for Mutator "DecrementInteger": --- Original +++ New @@ @@ return new Response('', Response::HTTP_NO_CONTENT); } $parameters = ['context' => $blockContext, 'settings' => $blockContext->getSettings(), 'block' => $blockContext->getBlock()]; - return $this->renderResponse($blockContext->getTemplate(), $parameters, $response)->setTtl(0)->setPrivate(); + return $this->renderResponse($blockContext->getTemplate(), $parameters, $response)->setTtl(-1)->setPrivate(); } public function configureCreateForm(FormMapper $form, BlockInterface $block) : void {

Check warning on line 60 in src/Block/Service/GDPRInformationBlockService.php

View workflow job for this annotation

GitHub Actions / run / Mutation Tests (8.2)

Escaped Mutant for Mutator "IncrementInteger": --- Original +++ New @@ @@ return new Response('', Response::HTTP_NO_CONTENT); } $parameters = ['context' => $blockContext, 'settings' => $blockContext->getSettings(), 'block' => $blockContext->getBlock()]; - return $this->renderResponse($blockContext->getTemplate(), $parameters, $response)->setTtl(0)->setPrivate(); + return $this->renderResponse($blockContext->getTemplate(), $parameters, $response)->setTtl(1)->setPrivate(); } public function configureCreateForm(FormMapper $form, BlockInterface $block) : void {
->setPrivate()
;
}

public function configureCreateForm(FormMapper $form, BlockInterface $block): void
Expand All @@ -70,15 +69,15 @@

public function configureEditForm(FormMapper $form, BlockInterface $block): void
{
$form->add('settings', ImmutableArrayType::class, [

Check warning on line 72 in src/Block/Service/GDPRInformationBlockService.php

View workflow job for this annotation

GitHub Actions / run / Mutation Tests (8.2)

Escaped Mutant for Mutator "ArrayItemRemoval": --- Original +++ New @@ @@ } public function configureEditForm(FormMapper $form, BlockInterface $block) : void { - $form->add('settings', ImmutableArrayType::class, ['keys' => [['text', TextType::class, ['label' => 'form.label_text', 'required' => false]], ['url', UrlType::class, ['label' => 'form.label_url', 'required' => false]], ['position', ChoiceType::class, ['label' => 'form.label_position', 'choices' => ['form.choice_top' => 'top', 'form.choice_fixedtop' => 'fixedtop', 'form.choice_bottom' => 'bottom', 'form.choice_block' => 'block']]]], 'translation_domain' => 'NucleosGDPRBundle']); + $form->add('settings', ImmutableArrayType::class, ['translation_domain' => 'NucleosGDPRBundle']); } public function configureSettings(OptionsResolver $resolver) : void {
'keys' => [

Check warning on line 73 in src/Block/Service/GDPRInformationBlockService.php

View workflow job for this annotation

GitHub Actions / run / Mutation Tests (8.2)

Escaped Mutant for Mutator "ArrayItemRemoval": --- Original +++ New @@ @@ } public function configureEditForm(FormMapper $form, BlockInterface $block) : void { - $form->add('settings', ImmutableArrayType::class, ['keys' => [['text', TextType::class, ['label' => 'form.label_text', 'required' => false]], ['url', UrlType::class, ['label' => 'form.label_url', 'required' => false]], ['position', ChoiceType::class, ['label' => 'form.label_position', 'choices' => ['form.choice_top' => 'top', 'form.choice_fixedtop' => 'fixedtop', 'form.choice_bottom' => 'bottom', 'form.choice_block' => 'block']]]], 'translation_domain' => 'NucleosGDPRBundle']); + $form->add('settings', ImmutableArrayType::class, ['keys' => [['url', UrlType::class, ['label' => 'form.label_url', 'required' => false]], ['position', ChoiceType::class, ['label' => 'form.label_position', 'choices' => ['form.choice_top' => 'top', 'form.choice_fixedtop' => 'fixedtop', 'form.choice_bottom' => 'bottom', 'form.choice_block' => 'block']]]], 'translation_domain' => 'NucleosGDPRBundle']); } public function configureSettings(OptionsResolver $resolver) : void {
['text', TextType::class, [

Check warning on line 74 in src/Block/Service/GDPRInformationBlockService.php

View workflow job for this annotation

GitHub Actions / run / Mutation Tests (8.2)

Escaped Mutant for Mutator "ArrayItemRemoval": --- Original +++ New @@ @@ } public function configureEditForm(FormMapper $form, BlockInterface $block) : void { - $form->add('settings', ImmutableArrayType::class, ['keys' => [['text', TextType::class, ['label' => 'form.label_text', 'required' => false]], ['url', UrlType::class, ['label' => 'form.label_url', 'required' => false]], ['position', ChoiceType::class, ['label' => 'form.label_position', 'choices' => ['form.choice_top' => 'top', 'form.choice_fixedtop' => 'fixedtop', 'form.choice_bottom' => 'bottom', 'form.choice_block' => 'block']]]], 'translation_domain' => 'NucleosGDPRBundle']); + $form->add('settings', ImmutableArrayType::class, ['keys' => [['text', TextType::class, ['required' => false]], ['url', UrlType::class, ['label' => 'form.label_url', 'required' => false]], ['position', ChoiceType::class, ['label' => 'form.label_position', 'choices' => ['form.choice_top' => 'top', 'form.choice_fixedtop' => 'fixedtop', 'form.choice_bottom' => 'bottom', 'form.choice_block' => 'block']]]], 'translation_domain' => 'NucleosGDPRBundle']); } public function configureSettings(OptionsResolver $resolver) : void {

Check warning on line 74 in src/Block/Service/GDPRInformationBlockService.php

View workflow job for this annotation

GitHub Actions / run / Mutation Tests (8.2)

Escaped Mutant for Mutator "ArrayItemRemoval": --- Original +++ New @@ @@ } public function configureEditForm(FormMapper $form, BlockInterface $block) : void { - $form->add('settings', ImmutableArrayType::class, ['keys' => [['text', TextType::class, ['label' => 'form.label_text', 'required' => false]], ['url', UrlType::class, ['label' => 'form.label_url', 'required' => false]], ['position', ChoiceType::class, ['label' => 'form.label_position', 'choices' => ['form.choice_top' => 'top', 'form.choice_fixedtop' => 'fixedtop', 'form.choice_bottom' => 'bottom', 'form.choice_block' => 'block']]]], 'translation_domain' => 'NucleosGDPRBundle']); + $form->add('settings', ImmutableArrayType::class, ['keys' => [[TextType::class, ['label' => 'form.label_text', 'required' => false]], ['url', UrlType::class, ['label' => 'form.label_url', 'required' => false]], ['position', ChoiceType::class, ['label' => 'form.label_position', 'choices' => ['form.choice_top' => 'top', 'form.choice_fixedtop' => 'fixedtop', 'form.choice_bottom' => 'bottom', 'form.choice_block' => 'block']]]], 'translation_domain' => 'NucleosGDPRBundle']); } public function configureSettings(OptionsResolver $resolver) : void {
'label' => 'form.label_text',
'required' => false,

Check warning on line 76 in src/Block/Service/GDPRInformationBlockService.php

View workflow job for this annotation

GitHub Actions / run / Mutation Tests (8.2)

Escaped Mutant for Mutator "FalseValue": --- Original +++ New @@ @@ } public function configureEditForm(FormMapper $form, BlockInterface $block) : void { - $form->add('settings', ImmutableArrayType::class, ['keys' => [['text', TextType::class, ['label' => 'form.label_text', 'required' => false]], ['url', UrlType::class, ['label' => 'form.label_url', 'required' => false]], ['position', ChoiceType::class, ['label' => 'form.label_position', 'choices' => ['form.choice_top' => 'top', 'form.choice_fixedtop' => 'fixedtop', 'form.choice_bottom' => 'bottom', 'form.choice_block' => 'block']]]], 'translation_domain' => 'NucleosGDPRBundle']); + $form->add('settings', ImmutableArrayType::class, ['keys' => [['text', TextType::class, ['label' => 'form.label_text', 'required' => true]], ['url', UrlType::class, ['label' => 'form.label_url', 'required' => false]], ['position', ChoiceType::class, ['label' => 'form.label_position', 'choices' => ['form.choice_top' => 'top', 'form.choice_fixedtop' => 'fixedtop', 'form.choice_bottom' => 'bottom', 'form.choice_block' => 'block']]]], 'translation_domain' => 'NucleosGDPRBundle']); } public function configureSettings(OptionsResolver $resolver) : void {
]],
['url', UrlType::class, [

Check warning on line 78 in src/Block/Service/GDPRInformationBlockService.php

View workflow job for this annotation

GitHub Actions / run / Mutation Tests (8.2)

Escaped Mutant for Mutator "ArrayItemRemoval": --- Original +++ New @@ @@ } public function configureEditForm(FormMapper $form, BlockInterface $block) : void { - $form->add('settings', ImmutableArrayType::class, ['keys' => [['text', TextType::class, ['label' => 'form.label_text', 'required' => false]], ['url', UrlType::class, ['label' => 'form.label_url', 'required' => false]], ['position', ChoiceType::class, ['label' => 'form.label_position', 'choices' => ['form.choice_top' => 'top', 'form.choice_fixedtop' => 'fixedtop', 'form.choice_bottom' => 'bottom', 'form.choice_block' => 'block']]]], 'translation_domain' => 'NucleosGDPRBundle']); + $form->add('settings', ImmutableArrayType::class, ['keys' => [['text', TextType::class, ['label' => 'form.label_text', 'required' => false]], ['url', UrlType::class, ['required' => false]], ['position', ChoiceType::class, ['label' => 'form.label_position', 'choices' => ['form.choice_top' => 'top', 'form.choice_fixedtop' => 'fixedtop', 'form.choice_bottom' => 'bottom', 'form.choice_block' => 'block']]]], 'translation_domain' => 'NucleosGDPRBundle']); } public function configureSettings(OptionsResolver $resolver) : void {

Check warning on line 78 in src/Block/Service/GDPRInformationBlockService.php

View workflow job for this annotation

GitHub Actions / run / Mutation Tests (8.2)

Escaped Mutant for Mutator "ArrayItemRemoval": --- Original +++ New @@ @@ } public function configureEditForm(FormMapper $form, BlockInterface $block) : void { - $form->add('settings', ImmutableArrayType::class, ['keys' => [['text', TextType::class, ['label' => 'form.label_text', 'required' => false]], ['url', UrlType::class, ['label' => 'form.label_url', 'required' => false]], ['position', ChoiceType::class, ['label' => 'form.label_position', 'choices' => ['form.choice_top' => 'top', 'form.choice_fixedtop' => 'fixedtop', 'form.choice_bottom' => 'bottom', 'form.choice_block' => 'block']]]], 'translation_domain' => 'NucleosGDPRBundle']); + $form->add('settings', ImmutableArrayType::class, ['keys' => [['text', TextType::class, ['label' => 'form.label_text', 'required' => false]], [UrlType::class, ['label' => 'form.label_url', 'required' => false]], ['position', ChoiceType::class, ['label' => 'form.label_position', 'choices' => ['form.choice_top' => 'top', 'form.choice_fixedtop' => 'fixedtop', 'form.choice_bottom' => 'bottom', 'form.choice_block' => 'block']]]], 'translation_domain' => 'NucleosGDPRBundle']); } public function configureSettings(OptionsResolver $resolver) : void {
'label' => 'form.label_url',
'required' => false,

Check warning on line 80 in src/Block/Service/GDPRInformationBlockService.php

View workflow job for this annotation

GitHub Actions / run / Mutation Tests (8.2)

Escaped Mutant for Mutator "FalseValue": --- Original +++ New @@ @@ } public function configureEditForm(FormMapper $form, BlockInterface $block) : void { - $form->add('settings', ImmutableArrayType::class, ['keys' => [['text', TextType::class, ['label' => 'form.label_text', 'required' => false]], ['url', UrlType::class, ['label' => 'form.label_url', 'required' => false]], ['position', ChoiceType::class, ['label' => 'form.label_position', 'choices' => ['form.choice_top' => 'top', 'form.choice_fixedtop' => 'fixedtop', 'form.choice_bottom' => 'bottom', 'form.choice_block' => 'block']]]], 'translation_domain' => 'NucleosGDPRBundle']); + $form->add('settings', ImmutableArrayType::class, ['keys' => [['text', TextType::class, ['label' => 'form.label_text', 'required' => false]], ['url', UrlType::class, ['label' => 'form.label_url', 'required' => true]], ['position', ChoiceType::class, ['label' => 'form.label_position', 'choices' => ['form.choice_top' => 'top', 'form.choice_fixedtop' => 'fixedtop', 'form.choice_bottom' => 'bottom', 'form.choice_block' => 'block']]]], 'translation_domain' => 'NucleosGDPRBundle']); } public function configureSettings(OptionsResolver $resolver) : void {
]],
['position', ChoiceType::class, [
'label' => 'form.label_position',
Expand Down
18 changes: 0 additions & 18 deletions tests/Block/Service/GDPRInformationBlockServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

namespace Nucleos\GDPRBundle\Tests\Block\Service;

use LogicException;
use Nucleos\GDPRBundle\Block\Service\GDPRInformationBlockService;
use PHPUnit\Framework\MockObject\MockObject;
use Sonata\BlockBundle\Block\BlockContext;
Expand Down Expand Up @@ -89,23 +88,6 @@ public function testExecute(): void
static::assertSame('TWIG_CONTENT', $response->getContent());
}

public function testExecuteWithNullTemplate(): void
{
$this->expectException(LogicException::class);
$this->expectExceptionMessage('Cannot render block without template');

$block = new Block();

$blockContext = new BlockContext($block, [
'template' => null,
]);

$response = new Response();

$blockService = new GDPRInformationBlockService($this->twig, $this->requestStack);
$blockService->execute($blockContext, $response);
}

public function testExecuteWithExistingCookie(): void
{
$this->request->cookies->set(GDPRInformationBlockService::COOKIE_NAME, 'true');
Expand Down