mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-14 19:36:43 +00:00
added a way to manage legacy tests in fixtures
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
* 1.21.0 (2015-XX-XX)
|
* 1.21.0 (2015-XX-XX)
|
||||||
|
|
||||||
* added deprecation notices for deprecated features
|
* added deprecation notices for deprecated features
|
||||||
* added a deprecation "framework" for filters/functions/tests
|
* added a deprecation "framework" for filters/functions/tests and test fixtures
|
||||||
|
|
||||||
* 1.20.0 (2015-08-12)
|
* 1.20.0 (2015-08-12)
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,15 @@ abstract class Twig_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase
|
|||||||
$this->doIntegrationTest($file, $message, $condition, $templates, $exception, $outputs);
|
$this->doIntegrationTest($file, $message, $condition, $templates, $exception, $outputs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTests()
|
/**
|
||||||
|
* @dataProvider getLegacyTests
|
||||||
|
*/
|
||||||
|
public function testLegacyIntegration($file, $message, $condition, $templates, $exception, $outputs)
|
||||||
|
{
|
||||||
|
$this->doIntegrationTest($file, $message, $condition, $templates, $exception, $outputs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTests($name, $legacyOnly = false)
|
||||||
{
|
{
|
||||||
$fixturesDir = realpath($this->getFixturesDir());
|
$fixturesDir = realpath($this->getFixturesDir());
|
||||||
$tests = array();
|
$tests = array();
|
||||||
@@ -38,10 +46,14 @@ abstract class Twig_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$isLegacyTest = false !== strpos($file->getRealpath(), '.legacy.test');
|
||||||
|
if (($isLegacyTest && !$legacyOnly) || (!$isLegacyTest && $legacyOnly)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$test = file_get_contents($file->getRealpath());
|
$test = file_get_contents($file->getRealpath());
|
||||||
|
|
||||||
if (preg_match('/
|
if (preg_match('/--TEST--\s*(.*?)\s*(?:--CONDITION--\s*(.*))?\s*((?:--TEMPLATE(?:\(.*?\))?--(?:.*?))+)\s*(?:--DATA--\s*(.*))?\s*--EXCEPTION--\s*(.*)/sx', $test, $match)) {
|
||||||
--TEST--\s*(.*?)\s*(?:--CONDITION--\s*(.*))?\s*((?:--TEMPLATE(?:\(.*?\))?--(?:.*?))+)\s*(?:--DATA--\s*(.*))?\s*--EXCEPTION--\s*(.*)/sx', $test, $match)) {
|
|
||||||
$message = $match[1];
|
$message = $match[1];
|
||||||
$condition = $match[2];
|
$condition = $match[2];
|
||||||
$templates = $this->parseTemplates($match[3]);
|
$templates = $this->parseTemplates($match[3]);
|
||||||
@@ -63,6 +75,11 @@ abstract class Twig_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase
|
|||||||
return $tests;
|
return $tests;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getLegacyTests()
|
||||||
|
{
|
||||||
|
return $this->getTests('testLegacyIntegration', true);
|
||||||
|
}
|
||||||
|
|
||||||
protected function doIntegrationTest($file, $message, $condition, $templates, $exception, $outputs)
|
protected function doIntegrationTest($file, $message, $condition, $templates, $exception, $outputs)
|
||||||
{
|
{
|
||||||
if ($condition) {
|
if ($condition) {
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
--TEST--
|
||||||
|
"autoescape" tag accepts an escaping strategy
|
||||||
|
--TEMPLATE--
|
||||||
|
{% autoescape true js %}{{ var }}{% endautoescape %}
|
||||||
|
|
||||||
|
{% autoescape true html %}{{ var }}{% endautoescape %}
|
||||||
|
--DATA--
|
||||||
|
return array('var' => '<br />"')
|
||||||
|
--EXPECT--
|
||||||
|
\x3Cbr\x20\x2F\x3E\x22
|
||||||
|
<br />"
|
||||||
@@ -1,10 +1,6 @@
|
|||||||
--TEST--
|
--TEST--
|
||||||
"autoescape" tag accepts an escaping strategy
|
"autoescape" tag accepts an escaping strategy
|
||||||
--TEMPLATE--
|
--TEMPLATE--
|
||||||
{% autoescape true js %}{{ var }}{% endautoescape %}
|
|
||||||
|
|
||||||
{% autoescape true html %}{{ var }}{% endautoescape %}
|
|
||||||
|
|
||||||
{% autoescape 'js' %}{{ var }}{% endautoescape %}
|
{% autoescape 'js' %}{{ var }}{% endautoescape %}
|
||||||
|
|
||||||
{% autoescape 'html' %}{{ var }}{% endautoescape %}
|
{% autoescape 'html' %}{{ var }}{% endautoescape %}
|
||||||
@@ -13,5 +9,3 @@ return array('var' => '<br />"')
|
|||||||
--EXPECT--
|
--EXPECT--
|
||||||
\x3Cbr\x20\x2F\x3E\x22
|
\x3Cbr\x20\x2F\x3E\x22
|
||||||
<br />"
|
<br />"
|
||||||
\x3Cbr\x20\x2F\x3E\x22
|
|
||||||
<br />"
|
|
||||||
|
|||||||
Reference in New Issue
Block a user