Sha256: 832fffe1172da9aaba6e9e43bce9eab170d7c60467362bd6bd6ad15bb2c3b08a

Contents?: true

Size: 1.21 KB

Versions: 9

Compression:

Stored size: 1.21 KB

Contents

<?php

namespace MtHaml\Tests;

class TestCase extends \PHPUnit_Framework_TestCase
{
    public function assertException($parts, \Exception $e = null)
    {
        if (empty($parts['EXCEPTION'])) {
            if (null !== $e) {
                throw $e;
            }

            return;
        }

        list($class, $message) = explode("\n", $parts['EXCEPTION'], 2);

        if (!empty($class)) {
            if (null === $e) {
                $this->assertThat(
                    NULL,
                    new \PHPUnit_Framework_Constraint_Exception($class)
                );
            }
            if (get_class($e) !== $class) {
                throw $e;
            }
        }
        if (!empty($message)) {
            $re = addcslashes($message, '~');
            $re = "~^($re)$~";
            $this->assertRegexp($re, $e->getMessage());
        }
    }

    public function parseTestFile($file)
    {
        $contents = file_get_contents($file);
        $splits = preg_split('#^--(.*)--$#m', $contents, -1, PREG_SPLIT_DELIM_CAPTURE);
        $parts = array();

        while (false !== $key = next($splits)) {
            $parts[$key] = substr(next($splits), 1, -1);
        }

        return $parts;
    }
}

Version data entries

9 entries across 9 versions & 1 rubygems

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