Sha256: 0b25d0126885cc68b2ffa626a356264775285323c8016044b312f5ec84768e5c

Contents?: true

Size: 1.11 KB

Versions: 10

Compression:

Stored size: 1.11 KB

Contents

<?php

namespace MtHaml\Tests;

use MtHaml\Parser;
use MtHaml\NodeVisitor\Printer;

require_once __DIR__ . '/TestCase.php';

class ParserTest extends TestCase
{
    /** @dataProvider getParserFixtures */
    public function testParser($file)
    {
        $parts = $this->parseTestFile($file);

        try {
            $parser = new Parser;
            $node = $parser->parse($parts['HAML'], $file, 2);

            $renderer = new Printer;
            $node->accept($renderer);
        } catch (\Exception $e) {
            return $this->assertException($parts, $e);
        }
        $this->assertException($parts);

        file_put_contents($file . '.out', $renderer->getOutput());

        $this->assertSame($parts['EXPECT'], $renderer->getOutput());

        unlink($file . '.out');
    }

    public function getParserFixtures()
    {
        if (false !== $tests = getenv('PARSER_TESTS')) {
            $files = explode(' ', $tests);
        } else {
            $files = glob(__DIR__ . '/fixtures/parser/*.test');
        }

        return array_map(function ($file) {
            return array($file);
        }, $files);
    }
}

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
guard-mthaml-0.4.0 vendor/mthaml/mthaml/test/MtHaml/Tests/ParserTest.php
guard-mthaml-0.3.1 vendor/mthaml/mthaml/test/MtHaml/Tests/ParserTest.php
guard-mthaml-0.3.0 vendor/mthaml/mthaml/test/MtHaml/Tests/ParserTest.php
guard-mthaml-0.2.5 vendor/mthaml/mthaml/test/MtHaml/Tests/ParserTest.php
guard-mthaml-0.2.4 vendor/mthaml/mthaml/test/MtHaml/Tests/ParserTest.php
guard-mthaml-0.2.3 vendor/mthaml/mthaml/test/MtHaml/Tests/ParserTest.php
guard-mthaml-0.2.2 vendor/mthaml/mthaml/test/MtHaml/Tests/ParserTest.php
guard-mthaml-0.2.1 vendor/mthaml/mthaml/test/MtHaml/Tests/ParserTest.php
guard-mthaml-0.2.0 vendor/mthaml/mthaml/test/MtHaml/Tests/ParserTest.php
guard-mthaml-0.1.0 vendor/mthaml/mthaml/test/MtHaml/Tests/ParserTest.php