Skip to content

Commit

Permalink
Remove test deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 committed Feb 10, 2020
1 parent 20ec5cc commit 592c57a
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 12 deletions.
24 changes: 17 additions & 7 deletions src/Test/BlockServiceTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,36 @@ abstract class InternalBlockServiceTestCase extends TestCase
*/
protected $blockContextManager;

/**
* @var Environment
*/
protected $twig;

/**
* NEXT_MAJOR: Remove this property.
*
* @var FakeTemplating
*/
protected $templating;
private $internalTemplating;

/**
* @var Environment
* NEXT_MAJOR: Remove this property hack.
*/
protected $twig;
public function __get($name)
{
if ('templating' === $name) {
if (null === $this->internalTemplating) {
$this->internalTemplating = new FakeTemplating();
}

return $this->internalTemplating;
}
}

/**
* @internal
*/
protected function internalSetUp(): void
{
$this->container = $this->createMock(ContainerInterface::class);
// NEXT_MAJOR: Remove the following assignment.
$this->templating = new FakeTemplating();

$blockLoader = $this->createMock(BlockLoaderInterface::class);
$this->blockServiceManager = $this->createMock(BlockServiceManagerInterface::class);
Expand Down
39 changes: 34 additions & 5 deletions tests/Block/Service/EmptyBlockServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,44 @@ final class EmptyBlockServiceTest extends BlockServiceTestCase
{
/**
* NEXT_MAJOR: Remove this test.
*
* @group legacy
*/
public function testArgumentCheck()
public function testInvalidConstructor(): void
{
new EmptyBlockService($this->twig);
new EmptyBlockService($this->templating);
new EmptyBlockService('sonata.page.block.rss');

$this->expectException(\TypeError::class);
$this->expectExceptionMessage('Argument 1 passed to Sonata\BlockBundle\Block\Service\EmptyBlockService::__construct() must be a string or an instance of Twig\Environment or Symfony\Component\Templating\EngineInterface, instance of stdClass given.');

new EmptyBlockService(new \stdClass());
}

/**
* NEXT_MAJOR: Remove this test.
*
* @group legacy
*/
public function testDeprecatedStringConstructor(): void
{
new EmptyBlockService('sonata.page.block.empty');
}

/**
* NEXT_MAJOR: Remove this test.
*
* @group legacy
*
* @expectedDeprecation The Sonata\BlockBundle\Test\FakeTemplating class is deprecated since 3.17 and will be removed in version 4.0.
*/
public function testDeprecatedTemplatingConstructor(): void
{
new EmptyBlockService($this->templating);
}

/**
* NEXT_MAJOR: Remove this test.
*/
public function testValiConstructor(): void
{
new EmptyBlockService($this->twig);
}
}

0 comments on commit 592c57a

Please sign in to comment.