From e6256ea0d7f1e947ed24b22965df8c0452792c90 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Tue, 9 Aug 2022 11:19:28 -0700 Subject: [PATCH] Remove dependency on deprecated YAML library. Use spec-provided JSON files instead. --- .gitmodules | 3 --- .../Test/FiveThree/Functional/MustacheSpecTest.php | 3 ++- test/Mustache/Test/SpecTestCase.php | 13 +++---------- test/bootstrap.php | 2 -- vendor/yaml | 1 - 5 files changed, 5 insertions(+), 17 deletions(-) delete mode 160000 vendor/yaml diff --git a/.gitmodules b/.gitmodules index 042ea4d..a33e1c9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ [submodule "vendor/spec"] path = vendor/spec url = https://github.com/mustache/spec.git -[submodule "vendor/yaml"] - path = vendor/yaml - url = https://github.com/fabpot/yaml.git diff --git a/test/Mustache/Test/FiveThree/Functional/MustacheSpecTest.php b/test/Mustache/Test/FiveThree/Functional/MustacheSpecTest.php index af3f982..a038872 100644 --- a/test/Mustache/Test/FiveThree/Functional/MustacheSpecTest.php +++ b/test/Mustache/Test/FiveThree/Functional/MustacheSpecTest.php @@ -49,9 +49,10 @@ class Mustache_Test_FiveThree_Functional_MustacheSpecTest extends Mustache_Test_ private function prepareLambdasSpec($data) { foreach ($data as $key => $val) { - if ($key === 'lambda') { + if (isset($val['__tag__']) && $val['__tag__'] === 'code') { if (!isset($val['php'])) { $this->markTestSkipped(sprintf('PHP lambda test not implemented for this test.')); + return; } $func = $val['php']; diff --git a/test/Mustache/Test/SpecTestCase.php b/test/Mustache/Test/SpecTestCase.php index db188de..447c11f 100644 --- a/test/Mustache/Test/SpecTestCase.php +++ b/test/Mustache/Test/SpecTestCase.php @@ -28,7 +28,7 @@ abstract class Mustache_Test_SpecTestCase extends PHPUnit_Framework_TestCase /** * Data provider for the mustache spec test. * - * Loads YAML files from the spec and converts them to PHPisms. + * Loads JSON files from the spec and converts them to PHPisms. * * @param string $name * @@ -36,21 +36,14 @@ abstract class Mustache_Test_SpecTestCase extends PHPUnit_Framework_TestCase */ protected function loadSpec($name) { - $filename = dirname(__FILE__) . '/../../../vendor/spec/specs/' . $name . '.yml'; + $filename = dirname(__FILE__) . '/../../../vendor/spec/specs/' . $name . '.json'; if (!file_exists($filename)) { return array(); } $data = array(); - $yaml = new sfYamlParser(); $file = file_get_contents($filename); - - // @hack: pre-process the 'lambdas' spec so the Symfony YAML parser doesn't complain. - if ($name === '~lambdas') { - $file = str_replace(" !code\n", "\n", $file); - } - - $spec = $yaml->parse($file); + $spec = json_decode($file, true); foreach ($spec['tests'] as $test) { $data[] = array( diff --git a/test/bootstrap.php b/test/bootstrap.php index b3d0a19..a0292aa 100644 --- a/test/bootstrap.php +++ b/test/bootstrap.php @@ -13,8 +13,6 @@ require dirname(__FILE__) . '/../src/Mustache/Autoloader.php'; Mustache_Autoloader::register(); Mustache_Autoloader::register(dirname(__FILE__) . '/../test'); -require dirname(__FILE__) . '/../vendor/yaml/lib/sfYamlParser.php'; - /** * Minimal stream wrapper to test protocol-based access to templates. */ diff --git a/vendor/yaml b/vendor/yaml deleted file mode 160000 index 8a266aa..0000000 --- a/vendor/yaml +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8a266aadcec878681ed458796b1ce792cc377f79