-
-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
161 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?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; | ||
$this->response = $response; | ||
|
||
if ($response) { | ||
return $response; | ||
} | ||
|
||
return new Response(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function supports($name) | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function exists($name) | ||
{ | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?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\Tests\Test\Mock; | ||
|
||
use Sonata\BlockBundle\Test\Mock\MockTemplating; | ||
|
||
class MockTemplatingTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testRender() | ||
{ | ||
$templating = new MockTemplating(); | ||
$templating->render('template.html.twig', array( | ||
'foo' => 'bar', | ||
)); | ||
|
||
$this->assertSame('template.html.twig', $templating->name); | ||
$this->assertSame(array( | ||
'foo' => 'bar', | ||
), $templating->parameters); | ||
} | ||
|
||
public function testRenderResponse() | ||
{ | ||
$response = $this->getMockBuilder('Symfony\Component\HttpFoundation\Response')->getMock(); | ||
|
||
$templating = new MockTemplating(); | ||
$templating->renderResponse('template.html.twig', array( | ||
'foo' => 'bar', | ||
), $response); | ||
|
||
$this->assertSame('template.html.twig', $templating->view); | ||
$this->assertSame(array( | ||
'foo' => 'bar', | ||
), $templating->parameters); | ||
$this->assertSame($response, $templating->response); | ||
} | ||
|
||
public function testSupports() | ||
{ | ||
$templating = new MockTemplating(); | ||
$this->assertTrue($templating->supports('foo')); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function testExists() | ||
{ | ||
$templating = new MockTemplating(); | ||
$this->assertTrue($templating->exists('foo')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |