Skip to content

Instantly share code, notes, and snippets.

@jjbohn
Created September 9, 2011 02:15
Show Gist options
  • Save jjbohn/1205333 to your computer and use it in GitHub Desktop.
Save jjbohn/1205333 to your computer and use it in GitHub Desktop.
<?php
class DescribeIndex extends View
{
function itRendersTheSelectedVideo()
{
$video = \Mockery::mock(
'Application_Model_Video', array('getName' => 'Revolution OS'));
$output = $this->render('MyBundle:Video:detail.html.twig', array(
'video' => $video,
);
$output->should->contain('Revolution OS');
}
}
<?php
use PHPSpec\Context;
use OpenSky\Component\DependencyInjection\TemplatingEngineAwareInterface;
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
class View extends Context
{
private $engine;
public function setTemplatingEngine(EngineInterface $engine)
{
$this->engine = $engine;
}
public function spec()
{
$interceptor = call_user_func_array(
array(
'\PHPSpec\Specification\Interceptor\InterceptorFactory',
'create'), func_get_args()
);
$interceptor->addMatchers(array('contain', 'haveSelector'));
return $interceptor;
}
public function render($template, array $templateContext = array())
{
if (is_null($this->engine)) {
throw new \LogicException('No templating engine set.');
}
return $this->spec($this->engine->render($template, $templateContext));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment