Sha256: d657b8816ce0b81a25028dc3bdd26d41dd21d57e5a7032e6c1efdf44987877a7

Contents?: true

Size: 1.42 KB

Versions: 10

Compression:

Stored size: 1.42 KB

Contents

<?php

namespace MtHaml\Tests;

require_once __DIR__ . '/TestCase.php';

class EnvironmentTest extends TestCase
{
    /** @dataProvider getEnvironmentTests */
    public function testEnvironment($file)
    {
        $parts = $this->parseTestFile($file);

        file_put_contents($file . '.haml', $parts['HAML']);
        file_put_contents($file . '.php', $parts['FILE']);
        file_put_contents($file . '.exp', $parts['EXPECT']);

        try {
            ob_start();
            require $file . '.php';
            $out = ob_get_clean();
        } catch (\Exception $e) {
            $this->assertException($parts, $e);
            $this->cleanup($file);

            return;
        }
        $this->assertException($parts);

        file_put_contents($file . '.out', $out);

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

        $this->cleanup($file);
    }

    protected function cleanup($file)
    {
        if (file_exists($file . '.out')) {
            unlink($file . '.out');
        }
        unlink($file . '.haml');
        unlink($file . '.php');
        unlink($file . '.exp');
    }

    public function getEnvironmentTests()
    {
        if (false !== $tests = getenv('ENV_TESTS')) {
            $files = explode(' ', $tests);
        } else {
            $files = glob(__DIR__ . '/fixtures/environment/*.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/EnvironmentTest.php
guard-mthaml-0.3.1 vendor/mthaml/mthaml/test/MtHaml/Tests/EnvironmentTest.php
guard-mthaml-0.3.0 vendor/mthaml/mthaml/test/MtHaml/Tests/EnvironmentTest.php
guard-mthaml-0.2.5 vendor/mthaml/mthaml/test/MtHaml/Tests/EnvironmentTest.php
guard-mthaml-0.2.4 vendor/mthaml/mthaml/test/MtHaml/Tests/EnvironmentTest.php
guard-mthaml-0.2.3 vendor/mthaml/mthaml/test/MtHaml/Tests/EnvironmentTest.php
guard-mthaml-0.2.2 vendor/mthaml/mthaml/test/MtHaml/Tests/EnvironmentTest.php
guard-mthaml-0.2.1 vendor/mthaml/mthaml/test/MtHaml/Tests/EnvironmentTest.php
guard-mthaml-0.2.0 vendor/mthaml/mthaml/test/MtHaml/Tests/EnvironmentTest.php
guard-mthaml-0.1.0 vendor/mthaml/mthaml/test/MtHaml/Tests/EnvironmentTest.php