Sha256: 7b29b56f164d2c2281c6257ad305ac744ba9220f72c08c8d98ac2e1e30d79b2e

Contents?: true

Size: 1.74 KB

Versions: 10

Compression:

Stored size: 1.74 KB

Contents

<?php

namespace MtHaml\Tests\Node;

use MtHaml\Node\Doctype;

class DoctypeTest extends \PHPUnit_Framework_TestCase
{
    /** @dataProvider getGetDoctypeReturnsDefaultOneWhenInvalidData */
    public function testGetDoctypeReturnsDefaultOneWhenInvalid($format, $doctype)
    {
        $node = new Doctype(array('lineno' => 0, 'column' => 0), 'invalid', null);

        $result = @$node->getDoctype($format);
        $this->assertSame($doctype, $result);
    }

    public function getGetDoctypeReturnsDefaultOneWhenInvalidData()
    {
        return array(
            array('html5', '<!DOCTYPE html>'),
            array('xhtml', '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'),
        );
    }

    /** @dataProvider getGetDoctypeTriggersWarningWhenInvalidData */
    public function testGetDoctypeTriggersWarningWhenInvalid($format, $msg)
    {
        $node = new Doctype(array('lineno' => 0, 'column' => 0), 'invalid', null);

        $e = null;

        try {
            $node->getDoctype($format);
        } catch (\Exception $e) {
        }

        $this->assertNotNull($e);
        $this->assertInstanceOf('PHPUnit_Framework_Error_Warning', $e);
        $this->assertSame($msg, $e->getMessage());

    }

    public function getGetDoctypeTriggersWarningWhenInvalidData()
    {
        return array(
            array('html5', "No such doctype '!!! invalid' for the format 'html5'. Available doctypes for the current format are: '!!!', '!!! 5'"),
            array('xhtml', "No such doctype '!!! invalid' for the format 'xhtml'. Available doctypes for the current format are: '!!!', '!!! strict', '!!! frameset', '!!! 5', '!!! 1.1', '!!! basic', '!!! mobile', '!!! rdfa'"),
        );
    }
}

Version data entries

10 entries across 10 versions & 1 rubygems

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