mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-12 02:16:41 +00:00
simplified a test
This commit is contained in:
@@ -1,37 +1,39 @@
|
||||
<?php
|
||||
|
||||
final class CustomExtensionTest extends \PHPUnit_Framework_TestCase
|
||||
/*
|
||||
* This file is part of Twig.
|
||||
*
|
||||
* (c) Fabien Potencier
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
class CustomExtensionTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @param Twig_ExtensionInterface $extension
|
||||
* @param string $expectedExceptionMessage
|
||||
*
|
||||
* @requires PHP 5.3
|
||||
* @dataProvider provideInvalidExtensions
|
||||
*/
|
||||
public function testGetInvalidOperators(\Twig_ExtensionInterface $extension, $expectedExceptionMessage)
|
||||
public function testGetInvalidOperators(Twig_ExtensionInterface $extension, $expectedExceptionMessage)
|
||||
{
|
||||
$this->setExpectedException('InvalidArgumentException', $expectedExceptionMessage);
|
||||
|
||||
$loader = new \Twig_Loader_Array(array('foo' => '{{ foo }}'));
|
||||
$env = new \Twig_Environment($loader);
|
||||
$env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
|
||||
$env->addExtension($extension);
|
||||
|
||||
$method = new \ReflectionMethod($env, 'initExtensions');
|
||||
$method->setAccessible(true);
|
||||
$method->invoke($env);
|
||||
$env->getUnaryOperators();
|
||||
}
|
||||
|
||||
public function provideInvalidExtensions()
|
||||
{
|
||||
return array(
|
||||
array(new InvalidOperatorExtension(new \stdClass()), '"InvalidOperatorExtension::getOperators()" must return an array with operators, got "stdClass".'),
|
||||
array(new InvalidOperatorExtension(new stdClass()), '"InvalidOperatorExtension::getOperators()" must return an array with operators, got "stdClass".'),
|
||||
array(new InvalidOperatorExtension(array(1, 2, 3)), '"InvalidOperatorExtension::getOperators()" must return an array of 2 elements, got 3.'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
final class InvalidOperatorExtension implements \Twig_ExtensionInterface
|
||||
class InvalidOperatorExtension implements Twig_ExtensionInterface
|
||||
{
|
||||
private $operators;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user