Created
September 9, 2011 02:15
-
-
Save jjbohn/1205333 to your computer and use it in GitHub Desktop.
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
<?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'); | |
} | |
} |
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
<?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