Skip to content

Commit

Permalink
[MINOR] Removed deprecated name argument from block constructor (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] committed Aug 7, 2019
2 parents 1e99892 + a325f79 commit bb8be71
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
11 changes: 8 additions & 3 deletions src/Block/Service/GDPRInformationBlockService.php
Expand Up @@ -37,9 +37,9 @@ final class GDPRInformationBlockService extends AbstractBlockService implements
*/
private $request;

public function __construct(string $name, EngineInterface $templating, RequestStack $request)
public function __construct(EngineInterface $templating, RequestStack $request)
{
parent::__construct($name, $templating);
parent::__construct($templating);

$this->request = $request;
}
Expand Down Expand Up @@ -106,11 +106,16 @@ public function validate(ErrorElement $errorElement, BlockInterface $block): voi

public function getMetadata(): MetadataInterface
{
return new Metadata($this->getName(), null, null, 'Core23GDPRBundle', [
return new Metadata('core23_gdpr.block.information', null, null, 'Core23GDPRBundle', [
'class' => 'fa fa-balance-scale',
]);
}

public function getName(): string
{
return $this->getMetadata()->getTitle();
}

private function hasGdprCookie(): bool
{
$request = $this->request->getMasterRequest();
Expand Down
1 change: 0 additions & 1 deletion src/Resources/config/block.xml
Expand Up @@ -3,7 +3,6 @@
<services>
<service id="core23_gdpr.block.information" class="Core23\GDPRBundle\Block\Service\GDPRInformationBlockService">
<tag name="sonata.block"/>
<argument>core23_gdpr.block.information</argument>
<argument type="service" id="sonata.templating"/>
<argument type="service" id="request_stack"/>
</service>
Expand Down
12 changes: 6 additions & 6 deletions tests/Block/Service/GDPRInformationBlockServiceTest.php
Expand Up @@ -45,7 +45,7 @@ protected function setUp(): void

public function testDefaultSettings(): void
{
$blockService = new GDPRInformationBlockService('block.service', $this->templating, $this->requestStack);
$blockService = new GDPRInformationBlockService($this->templating, $this->requestStack);
$blockContext = $this->getBlockContext($blockService);

$this->assertSettings([
Expand All @@ -67,7 +67,7 @@ public function testExecute(): void
'position' => 'block',
]);

$blockService = new GDPRInformationBlockService('block.service', $this->templating, $this->requestStack);
$blockService = new GDPRInformationBlockService($this->templating, $this->requestStack);
$blockService->execute($blockContext);

static::assertSame('@Core23GDPR/Block/block_gdpr.html.twig', $this->templating->view);
Expand All @@ -90,19 +90,19 @@ public function testExecuteWithExistingCookie(): void
'position' => 'block',
]);

$blockService = new GDPRInformationBlockService('block.service', $this->templating, $this->requestStack);
$blockService = new GDPRInformationBlockService($this->templating, $this->requestStack);
$response = $blockService->execute($blockContext);

static::assertTrue($response->isEmpty());
}

public function testGetMetadata(): void
{
$blockService = new GDPRInformationBlockService('block.service', $this->templating, $this->requestStack);
$blockService = new GDPRInformationBlockService($this->templating, $this->requestStack);

$metadata = $blockService->getMetadata();

static::assertSame('block.service', $metadata->getTitle());
static::assertSame('core23_gdpr.block.information', $metadata->getTitle());
static::assertNotNull($metadata->getImage());
static::assertStringStartsWith('data:image/png;base64,', $metadata->getImage() ?? '');
static::assertSame('Core23GDPRBundle', $metadata->getDomain());
Expand All @@ -113,7 +113,7 @@ public function testGetMetadata(): void

public function testConfigureEditForm(): void
{
$blockService = new GDPRInformationBlockService('block.service', $this->templating, $this->requestStack);
$blockService = new GDPRInformationBlockService($this->templating, $this->requestStack);

$block = new Block();

Expand Down

0 comments on commit bb8be71

Please sign in to comment.