Skip to content

Commit

Permalink
improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul M. Jones committed Mar 16, 2015
1 parent b2b6d17 commit b912b4b
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/unit/src/Escaper/AbstractEscaperTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<?php
namespace Aura\Html\Escaper;

use Aura\Html\FakePhp;

// trick PHP into using this function instead of the native function
function function_exists($name)
{
return FakePhp::function_exists($name);
}

/**
*
* Based almost entirely on Zend\Escaper by Padraic Brady et al. and modified
Expand All @@ -15,6 +23,21 @@ abstract class AbstractEscaperTest extends \PHPUnit_Framework_TestCase

abstract public function test__construct();

protected function setUp()
{
FakePhp::$function_exists['iconv'] = \function_exists('iconv');
FakePhp::$function_exists['mb_convert_encoding'] = \function_exists('mb_convert_encoding');
}

public function testMissingExtensions()
{
FakePhp::$function_exists['iconv'] = false;
FakePhp::$function_exists['mb_convert_encoding'] = false;
$this->escaper->setEncoding('iso8859-1');
$this->setExpectedException('Aura\Html\Exception\ExtensionNotInstalled');
$this->escaper->toUtf8('x');
}

public function testSetAndGetEncoding()
{
$this->escaper->setEncoding('macroman');
Expand Down
1 change: 1 addition & 0 deletions tests/unit/src/Escaper/AttrEscaperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class AttrEscaperTest extends AbstractEscaperTest
{
public function setUp()
{
parent::setUp();
$this->escaper = new AttrEscaper(new HtmlEscaper);
}

Expand Down
1 change: 1 addition & 0 deletions tests/unit/src/Escaper/CssEscaperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class CssEscaperTest extends AbstractEscaperTest
{
public function setUp()
{
parent::setUp();
$this->escaper = new CssEscaper;
}

Expand Down
1 change: 1 addition & 0 deletions tests/unit/src/Escaper/HtmlEscaperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class HtmlEscaperTest extends AbstractEscaperTest
{
public function setUp()
{
parent::setUp();
$this->escaper = new HtmlEscaper;
}

Expand Down
1 change: 1 addition & 0 deletions tests/unit/src/Escaper/JsEscaperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class JsEscaperTest extends AbstractEscaperTest
{
public function setUp()
{
parent::setUp();
$this->escaper = new JsEscaper;
}

Expand Down
12 changes: 12 additions & 0 deletions tests/unit/src/FakePhp.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
namespace Aura\Html;

class FakePhp
{
static public $function_exists = array();

static public function function_exists($name)
{
return self::$function_exists[$name];
}
}

0 comments on commit b912b4b

Please sign in to comment.