mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-15 20:06:31 +00:00
minor #2429 fixed risky tests (fabpot)
This PR was merged into the 1.x branch.
Discussion
----------
fixed risky tests
Commits
-------
7259e52f fixed risky tests
This commit is contained in:
@@ -121,6 +121,10 @@ abstract class Twig_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase
|
||||
|
||||
protected function doIntegrationTest($file, $message, $condition, $templates, $exception, $outputs)
|
||||
{
|
||||
if (!$outputs) {
|
||||
$this->markTestSkipped('no legacy tests to run');
|
||||
}
|
||||
|
||||
if ($condition) {
|
||||
eval('$ret = '.$condition.';');
|
||||
if (!$ret) {
|
||||
|
||||
@@ -398,8 +398,11 @@ EOF
|
||||
{
|
||||
$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
|
||||
$twig->addExtension(new Twig_Tests_EnvironmentTest_ExtensionWithoutDeprecationInitRuntime());
|
||||
|
||||
$twig->initRuntime();
|
||||
|
||||
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
|
||||
// can be executed without throwing any deprecations
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -284,6 +284,10 @@ class Twig_Tests_ExpressionParserTest extends PHPUnit_Framework_TestCase
|
||||
$parser = new Twig_Parser($env);
|
||||
|
||||
$parser->parse($env->tokenize(new Twig_Source($template, 'index')));
|
||||
|
||||
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
|
||||
// can be executed without throwing any exceptions
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
public function getMacroDefinitionSupportsConstantDefaultValues()
|
||||
|
||||
@@ -26,7 +26,7 @@ class Twig_Tests_LegacyIntegrationTest extends Twig_Test_IntegrationTestCase
|
||||
public function getTests($name, $legacyTests = false)
|
||||
{
|
||||
if (!$legacyTests) {
|
||||
return array(array('not', '-', '', array(), '', array()));
|
||||
return array(array('', '', '', array(), '', array()));
|
||||
}
|
||||
|
||||
return parent::getTests($name, true);
|
||||
|
||||
@@ -116,7 +116,9 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
|
||||
$lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
|
||||
$lexer->tokenize(new Twig_Source($template, 'index'));
|
||||
|
||||
// should not throw an exception
|
||||
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
|
||||
// can be executed without throwing any exceptions
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
public function testLongVerbatim()
|
||||
@@ -126,7 +128,9 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
|
||||
$lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
|
||||
$lexer->tokenize(new Twig_Source($template, 'index'));
|
||||
|
||||
// should not throw an exception
|
||||
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
|
||||
// can be executed without throwing any exceptions
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
public function testLongVar()
|
||||
@@ -136,7 +140,9 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
|
||||
$lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
|
||||
$lexer->tokenize(new Twig_Source($template, 'index'));
|
||||
|
||||
// should not throw an exception
|
||||
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
|
||||
// can be executed without throwing any exceptions
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
public function testLongBlock()
|
||||
@@ -146,7 +152,9 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
|
||||
$lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
|
||||
$lexer->tokenize(new Twig_Source($template, 'index'));
|
||||
|
||||
// should not throw an exception
|
||||
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
|
||||
// can be executed without throwing any exceptions
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
public function testBigNumbers()
|
||||
@@ -171,6 +179,10 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
|
||||
$stream = $lexer->tokenize(new Twig_Source($template, 'index'));
|
||||
$stream->expect(Twig_Token::VAR_START_TYPE);
|
||||
$stream->expect(Twig_Token::STRING_TYPE, $expected);
|
||||
|
||||
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
|
||||
// can be executed without throwing any exceptions
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,6 +201,10 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
|
||||
$stream->expect(Twig_Token::NUMBER_TYPE, '1');
|
||||
$stream->expect(Twig_Token::INTERPOLATION_END_TYPE);
|
||||
$stream->expect(Twig_Token::VAR_END_TYPE);
|
||||
|
||||
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
|
||||
// can be executed without throwing any exceptions
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
public function testStringWithEscapedInterpolation()
|
||||
@@ -200,6 +216,10 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
|
||||
$stream->expect(Twig_Token::VAR_START_TYPE);
|
||||
$stream->expect(Twig_Token::STRING_TYPE, 'bar #{baz+1}');
|
||||
$stream->expect(Twig_Token::VAR_END_TYPE);
|
||||
|
||||
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
|
||||
// can be executed without throwing any exceptions
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
public function testStringWithHash()
|
||||
@@ -211,6 +231,10 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
|
||||
$stream->expect(Twig_Token::VAR_START_TYPE);
|
||||
$stream->expect(Twig_Token::STRING_TYPE, 'bar # baz');
|
||||
$stream->expect(Twig_Token::VAR_END_TYPE);
|
||||
|
||||
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
|
||||
// can be executed without throwing any exceptions
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -240,6 +264,10 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
|
||||
$stream->expect(Twig_Token::INTERPOLATION_END_TYPE);
|
||||
$stream->expect(Twig_Token::INTERPOLATION_END_TYPE);
|
||||
$stream->expect(Twig_Token::VAR_END_TYPE);
|
||||
|
||||
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
|
||||
// can be executed without throwing any exceptions
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
public function testStringWithNestedInterpolationsInBlock()
|
||||
@@ -258,6 +286,10 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
|
||||
$stream->expect(Twig_Token::INTERPOLATION_END_TYPE);
|
||||
$stream->expect(Twig_Token::INTERPOLATION_END_TYPE);
|
||||
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
||||
|
||||
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
|
||||
// can be executed without throwing any exceptions
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
public function testOperatorEndingWithALetterAtTheEndOfALine()
|
||||
@@ -269,6 +301,10 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
|
||||
$stream->expect(Twig_Token::VAR_START_TYPE);
|
||||
$stream->expect(Twig_Token::NUMBER_TYPE, 1);
|
||||
$stream->expect(Twig_Token::OPERATOR_TYPE, 'and');
|
||||
|
||||
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
|
||||
// can be executed without throwing any exceptions
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -92,6 +92,10 @@ class Twig_Tests_Loader_ArrayTest extends PHPUnit_Framework_TestCase
|
||||
$loader->getSourceContext($name);
|
||||
$loader->isFresh($name, time());
|
||||
$loader->setTemplate($name, 'foobar');
|
||||
|
||||
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
|
||||
// can be executed without crashing PHP
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class Twig_Tests_NodeVisitor_OptimizerTest extends PHPUnit_Framework_TestCase
|
||||
public function testRenderVariableBlockOptimizer()
|
||||
{
|
||||
if (PHP_VERSION_ID >= 50400) {
|
||||
return;
|
||||
$this->markTestSkipped('not needed on PHP >= 5.4');
|
||||
}
|
||||
|
||||
$env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false));
|
||||
|
||||
@@ -131,9 +131,6 @@ class Twig_Tests_ParserTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertNull($parser->getParent());
|
||||
}
|
||||
|
||||
// The getVarName() must not depend on the template loaders,
|
||||
// If this test does not throw any exception, that's good.
|
||||
// see https://github.com/symfony/symfony/issues/4218
|
||||
public function testGetVarName()
|
||||
{
|
||||
$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array(
|
||||
@@ -149,6 +146,11 @@ class Twig_Tests_ParserTest extends PHPUnit_Framework_TestCase
|
||||
{% endmacro %}
|
||||
EOF
|
||||
, 'index')));
|
||||
|
||||
// The getVarName() must not depend on the template loaders,
|
||||
// If this test does not throw any exception, that's good.
|
||||
// see https://github.com/symfony/symfony/issues/4218
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
protected function getParser()
|
||||
|
||||
@@ -83,10 +83,14 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
if (!$allowed) {
|
||||
$this->fail();
|
||||
} else {
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
} catch (Twig_Sandbox_SecurityError $e) {
|
||||
if ($allowed) {
|
||||
$this->fail();
|
||||
} else {
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
$this->assertContains('is not allowed', $e->getMessage());
|
||||
@@ -255,15 +259,15 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
|
||||
if ($defined) {
|
||||
$this->assertEquals($value, $template->getAttribute($object, $item, $arguments, $type));
|
||||
} else {
|
||||
try {
|
||||
$this->assertEquals($value, $template->getAttribute($object, $item, $arguments, $type));
|
||||
|
||||
throw new Exception('Expected Twig_Error_Runtime exception.');
|
||||
} catch (Twig_Error_Runtime $e) {
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException('Twig_Error_Runtime');
|
||||
if (null !== $exceptionMessage) {
|
||||
$this->assertSame($exceptionMessage, $e->getMessage());
|
||||
$this->expectExceptionMessage($exceptionMessage);
|
||||
}
|
||||
} else {
|
||||
$this->setExpectedException('Twig_Error_Runtime', $exceptionMessage);
|
||||
}
|
||||
$this->assertEquals($value, $template->getAttribute($object, $item, $arguments, $type));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -576,7 +580,13 @@ class Twig_TemplatePropertyObjectAndIterator extends Twig_TemplatePropertyObject
|
||||
|
||||
class Twig_TemplatePropertyObjectAndArrayAccess extends Twig_TemplatePropertyObject implements ArrayAccess
|
||||
{
|
||||
private $data = array();
|
||||
private $data = array(
|
||||
'defined' => 'defined',
|
||||
'zero' => 0,
|
||||
'null' => null,
|
||||
'bar' => true,
|
||||
'baz' => 'baz',
|
||||
);
|
||||
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user