Skip to content

Commit

Permalink
Merge c550740 into f638a35
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 committed Jun 29, 2016
2 parents f638a35 + c550740 commit bc9b087
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 66 deletions.
83 changes: 83 additions & 0 deletions Test/Mock/MockTemplating.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php

/*
* This file is part of the Sonata Project package.
*
* (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Sonata\BlockBundle\Test\Mock;

use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
use Symfony\Component\HttpFoundation\Response;

/**
* Mocking class for template usage.
*
* @author Thomas Rabaix <thomas.rabaix@sonata-project.org>
*/
class MockTemplating implements EngineInterface
{
/**
* @var string
*/
public $view;

/**
* @var array
*/
public $parameters;

/**
* @var Response
*/
public $response;

/**
* @var string
*/
public $name;

/**
* {@inheritdoc}
*/
public function render($name, array $parameters = array())
{
$this->name = $name;
$this->parameters = $parameters;
}

/**
* {@inheritdoc}
*/
public function renderResponse($view, array $parameters = array(), Response $response = null)
{
$this->view = $view;
$this->parameters = $parameters;

if ($response) {
return $response;
}

return new Response();
}

/**
* {@inheritdoc}
*/
public function supports($name)
{
return true;
}

/**
* {@inheritdoc}
*/
public function exists($name)
{
return true;
}
}
1 change: 0 additions & 1 deletion Tests/Block/AbstractBlockServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
E_USER_DEPRECATED
);


/**
* @deprecated Deprecated since version 3.x. Use Sonata\BlockBundle\Test\AbstractBlockServiceTestCase instead.
*/
Expand Down
73 changes: 11 additions & 62 deletions Tests/Block/Service/FakeTemplating.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,68 +11,17 @@

namespace Sonata\BlockBundle\Tests\Block\Service;

use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
use Symfony\Component\HttpFoundation\Response;
use Sonata\BlockBundle\Test\Mock\MockTemplating;

class FakeTemplating implements EngineInterface
{
/**
* @var string
*/
public $view;

/**
* @var array
*/
public $parameters;

/**
* @var Response
*/
public $response;

/**
* @var string
*/
public $name;

/**
* {@inheritdoc}
*/
public function render($name, array $parameters = array())
{
$this->name = $name;
$this->parameters = $parameters;
}

/**
* {@inheritdoc}
*/
public function renderResponse($view, array $parameters = array(), Response $response = null)
{
$this->view = $view;
$this->parameters = $parameters;
@trigger_error(
'The '.__NAMESPACE__.'\FakeTemplating class is deprecated since version 3.x and will be removed in 4.0.'
.' Use Sonata\BlockBundle\Test\Mock\MockTemplating instead.',
E_USER_DEPRECATED
);

if ($response) {
return $response;
}

return new Response();
}

/**
* {@inheritdoc}
*/
public function supports($name)
{
return true;
}

/**
* {@inheritdoc}
*/
public function exists($name)
{
return true;
}
/**
* @deprecated Deprecated since version 3.x. Use Sonata\BlockBundle\Test\Mock\MockTemplating instead.
*/
class FakeTemplating extends MockTemplating
{
}
3 changes: 2 additions & 1 deletion Tests/Block/Service/RssBlockServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Sonata\BlockBundle\Block\BlockContext;
use Sonata\BlockBundle\Block\Service\RssBlockService;
use Sonata\BlockBundle\Model\Block;
use Sonata\BlockBundle\Test\Mock\MockTemplating;
use Sonata\BlockBundle\Util\OptionsResolver;

class RssBlockServiceTest extends BaseTestBlockService
Expand All @@ -23,7 +24,7 @@ class RssBlockServiceTest extends BaseTestBlockService
*/
public function testService()
{
$templating = new FakeTemplating();
$templating = new MockTemplating();
$service = new RssBlockService('sonata.page.block.rss', $templating);

$block = new Block();
Expand Down
3 changes: 2 additions & 1 deletion Tests/Block/Service/TextBlockServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
use Sonata\BlockBundle\Block\BlockContext;
use Sonata\BlockBundle\Block\Service\TextBlockService;
use Sonata\BlockBundle\Model\Block;
use Sonata\BlockBundle\Test\Mock\MockTemplating;
use Sonata\BlockBundle\Util\OptionsResolver;

class TextBlockServiceTest extends BaseTestBlockService
{
public function testService()
{
$templating = new FakeTemplating();
$templating = new MockTemplating();
$service = new TextBlockService('sonata.page.block.text', $templating);

$block = new Block();
Expand Down
3 changes: 2 additions & 1 deletion UPGRADE-3.x.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
UPGRADE 3.x
===========

## Deprecated AbstractBlockServiceTest class
## Deprecated test classes

The `Tests\Block\AbstractBlockServiceTest` class is deprecated. Use `Test\AbstractBlockServiceTestCase` instead.
The `Tests\Block\Service\FakeTemplating` class is deprecated. Use `Test\Mock\MockTemplating` instead.

0 comments on commit bc9b087

Please sign in to comment.