mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-07-31 19:30:21 +02:00
Handle CRLF discrepancies
Signed-off-by: Edward Z. Yang <edwardzyang@thewritingpot.com>
This commit is contained in:
@@ -1,37 +1,37 @@
|
||||
<?php
|
||||
|
||||
class HTMLPurifier_HTMLModule_ObjectTest extends HTMLPurifier_HTMLModuleHarness
|
||||
{
|
||||
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$this->config->set('HTML', 'Trusted', true);
|
||||
}
|
||||
|
||||
function testDefaultRemoval() {
|
||||
$this->config->set('HTML', 'Trusted', false);
|
||||
$this->assertResult(
|
||||
'<object></object>', ''
|
||||
);
|
||||
}
|
||||
|
||||
function testMinimal() {
|
||||
$this->assertResult('<object></object>');
|
||||
}
|
||||
|
||||
function testStandardUseCase() {
|
||||
$this->assertResult(
|
||||
'<object type="video/x-ms-wmv" data="http://domain.com/video.wmv" width="320" height="256">
|
||||
<param name="src" value="http://domain.com/video.wmv" />
|
||||
<param name="autostart" value="false" />
|
||||
<param name="controller" value="true" />
|
||||
<param name="pluginurl" value="http://www.microsoft.com/Windows/MediaPlayer/" />
|
||||
<a href="http://www.microsoft.com/Windows/MediaPlayer/">Windows Media player required</a>
|
||||
</object>'
|
||||
);
|
||||
}
|
||||
|
||||
// more test-cases?
|
||||
|
||||
}
|
||||
|
||||
<?php
|
||||
|
||||
class HTMLPurifier_HTMLModule_ObjectTest extends HTMLPurifier_HTMLModuleHarness
|
||||
{
|
||||
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$this->config->set('HTML', 'Trusted', true);
|
||||
}
|
||||
|
||||
function testDefaultRemoval() {
|
||||
$this->config->set('HTML', 'Trusted', false);
|
||||
$this->assertResult(
|
||||
'<object></object>', ''
|
||||
);
|
||||
}
|
||||
|
||||
function testMinimal() {
|
||||
$this->assertResult('<object></object>');
|
||||
}
|
||||
|
||||
function testStandardUseCase() {
|
||||
$this->assertResult(
|
||||
'<object type="video/x-ms-wmv" data="http://domain.com/video.wmv" width="320" height="256">
|
||||
<param name="src" value="http://domain.com/video.wmv" />
|
||||
<param name="autostart" value="false" />
|
||||
<param name="controller" value="true" />
|
||||
<param name="pluginurl" value="http://www.microsoft.com/Windows/MediaPlayer/" />
|
||||
<a href="http://www.microsoft.com/Windows/MediaPlayer/">Windows Media player required</a>
|
||||
</object>'
|
||||
);
|
||||
}
|
||||
|
||||
// more test-cases?
|
||||
|
||||
}
|
||||
|
||||
|
@@ -1,12 +1,12 @@
|
||||
--TEST--
|
||||
HTMLPurifier.safe-includes.php loading test
|
||||
--FILE--
|
||||
<?php
|
||||
require_once '../library/HTMLPurifier.php'; // Tests for require_once
|
||||
require_once '../library/HTMLPurifier.safe-includes.php';
|
||||
require 'HTMLPurifier/PHPT/loading/_no-autoload.inc';
|
||||
$config = HTMLPurifier_Config::createDefault();
|
||||
$purifier = new HTMLPurifier($config);
|
||||
echo $purifier->purify('<b>Salsa!');
|
||||
--EXPECT--
|
||||
<b>Salsa!</b>
|
||||
--TEST--
|
||||
HTMLPurifier.safe-includes.php loading test
|
||||
--FILE--
|
||||
<?php
|
||||
require_once '../library/HTMLPurifier.php'; // Tests for require_once
|
||||
require_once '../library/HTMLPurifier.safe-includes.php';
|
||||
require 'HTMLPurifier/PHPT/loading/_no-autoload.inc';
|
||||
$config = HTMLPurifier_Config::createDefault();
|
||||
$purifier = new HTMLPurifier($config);
|
||||
echo $purifier->purify('<b>Salsa!');
|
||||
--EXPECT--
|
||||
<b>Salsa!</b>
|
||||
|
@@ -1,95 +1,95 @@
|
||||
<?php
|
||||
|
||||
class HTMLPurifier_Strategy_MakeWellFormed_InjectorTest extends HTMLPurifier_StrategyHarness
|
||||
{
|
||||
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$this->obj = new HTMLPurifier_Strategy_MakeWellFormed();
|
||||
$this->config->set('AutoFormat', 'AutoParagraph', true);
|
||||
$this->config->set('AutoFormat', 'Linkify', true);
|
||||
generate_mock_once('HTMLPurifier_Injector');
|
||||
}
|
||||
|
||||
function testEndNotification() {
|
||||
$mock = new HTMLPurifier_InjectorMock();
|
||||
$mock->skip = false;
|
||||
$mock->expectAt(0, 'notifyEnd', array(new HTMLPurifier_Token_End('b')));
|
||||
$mock->expectAt(1, 'notifyEnd', array(new HTMLPurifier_Token_End('i')));
|
||||
$mock->expectCallCount('notifyEnd', 2);
|
||||
$this->config->set('AutoFormat', 'AutoParagraph', false);
|
||||
$this->config->set('AutoFormat', 'Linkify', false);
|
||||
$this->config->set('AutoFormat', 'Custom', array($mock));
|
||||
$this->assertResult('<i><b>asdf</b>', '<i><b>asdf</b></i>');
|
||||
}
|
||||
|
||||
function testErrorRequiredElementNotAllowed() {
|
||||
$this->config->set('HTML', 'Allowed', '');
|
||||
$this->expectError('Cannot enable AutoParagraph injector because p is not allowed');
|
||||
$this->expectError('Cannot enable Linkify injector because a is not allowed');
|
||||
$this->assertResult('Foobar');
|
||||
}
|
||||
|
||||
function testErrorRequiredAttributeNotAllowed() {
|
||||
$this->config->set('HTML', 'Allowed', 'a,p');
|
||||
$this->expectError('Cannot enable Linkify injector because a.href is not allowed');
|
||||
$this->assertResult('<p>http://example.com</p>');
|
||||
}
|
||||
|
||||
function testOnlyAutoParagraph() {
|
||||
$this->assertResult(
|
||||
'Foobar',
|
||||
'<p>Foobar</p>'
|
||||
);
|
||||
}
|
||||
|
||||
function testParagraphWrappingOnlyLink() {
|
||||
$this->assertResult(
|
||||
'http://example.com',
|
||||
'<p><a href="http://example.com">http://example.com</a></p>'
|
||||
);
|
||||
}
|
||||
|
||||
function testParagraphWrappingNodeContainingLink() {
|
||||
$this->assertResult(
|
||||
'<b>http://example.com</b>',
|
||||
'<p><b><a href="http://example.com">http://example.com</a></b></p>'
|
||||
);
|
||||
}
|
||||
|
||||
function testParagraphWrappingPoorlyFormedNodeContainingLink() {
|
||||
$this->assertResult(
|
||||
'<b>http://example.com',
|
||||
'<p><b><a href="http://example.com">http://example.com</a></b></p>'
|
||||
);
|
||||
}
|
||||
|
||||
function testTwoParagraphsContainingOnlyOneLink() {
|
||||
$this->assertResult(
|
||||
"http://example.com\n\nhttp://dev.example.com",
|
||||
'<p><a href="http://example.com">http://example.com</a></p><p><a href="http://dev.example.com">http://dev.example.com</a></p>'
|
||||
);
|
||||
}
|
||||
|
||||
function testParagraphNextToDivWithLinks() {
|
||||
$this->assertResult(
|
||||
'http://example.com <div>http://example.com</div>',
|
||||
'<p><a href="http://example.com">http://example.com</a> </p><div><a href="http://example.com">http://example.com</a></div>'
|
||||
);
|
||||
}
|
||||
|
||||
function testRealisticLinkInSentence() {
|
||||
$this->assertResult(
|
||||
'This URL http://example.com is what you need',
|
||||
'<p>This URL <a href="http://example.com">http://example.com</a> is what you need</p>'
|
||||
);
|
||||
}
|
||||
|
||||
function testParagraphAfterLinkifiedURL() {
|
||||
$this->assertResult(
|
||||
"http://google.com\n\n<b>b</b>",
|
||||
"<p><a href=\"http://google.com\">http://google.com</a></p><p><b>b</b></p>"
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
<?php
|
||||
|
||||
class HTMLPurifier_Strategy_MakeWellFormed_InjectorTest extends HTMLPurifier_StrategyHarness
|
||||
{
|
||||
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$this->obj = new HTMLPurifier_Strategy_MakeWellFormed();
|
||||
$this->config->set('AutoFormat', 'AutoParagraph', true);
|
||||
$this->config->set('AutoFormat', 'Linkify', true);
|
||||
generate_mock_once('HTMLPurifier_Injector');
|
||||
}
|
||||
|
||||
function testEndNotification() {
|
||||
$mock = new HTMLPurifier_InjectorMock();
|
||||
$mock->skip = false;
|
||||
$mock->expectAt(0, 'notifyEnd', array(new HTMLPurifier_Token_End('b')));
|
||||
$mock->expectAt(1, 'notifyEnd', array(new HTMLPurifier_Token_End('i')));
|
||||
$mock->expectCallCount('notifyEnd', 2);
|
||||
$this->config->set('AutoFormat', 'AutoParagraph', false);
|
||||
$this->config->set('AutoFormat', 'Linkify', false);
|
||||
$this->config->set('AutoFormat', 'Custom', array($mock));
|
||||
$this->assertResult('<i><b>asdf</b>', '<i><b>asdf</b></i>');
|
||||
}
|
||||
|
||||
function testErrorRequiredElementNotAllowed() {
|
||||
$this->config->set('HTML', 'Allowed', '');
|
||||
$this->expectError('Cannot enable AutoParagraph injector because p is not allowed');
|
||||
$this->expectError('Cannot enable Linkify injector because a is not allowed');
|
||||
$this->assertResult('Foobar');
|
||||
}
|
||||
|
||||
function testErrorRequiredAttributeNotAllowed() {
|
||||
$this->config->set('HTML', 'Allowed', 'a,p');
|
||||
$this->expectError('Cannot enable Linkify injector because a.href is not allowed');
|
||||
$this->assertResult('<p>http://example.com</p>');
|
||||
}
|
||||
|
||||
function testOnlyAutoParagraph() {
|
||||
$this->assertResult(
|
||||
'Foobar',
|
||||
'<p>Foobar</p>'
|
||||
);
|
||||
}
|
||||
|
||||
function testParagraphWrappingOnlyLink() {
|
||||
$this->assertResult(
|
||||
'http://example.com',
|
||||
'<p><a href="http://example.com">http://example.com</a></p>'
|
||||
);
|
||||
}
|
||||
|
||||
function testParagraphWrappingNodeContainingLink() {
|
||||
$this->assertResult(
|
||||
'<b>http://example.com</b>',
|
||||
'<p><b><a href="http://example.com">http://example.com</a></b></p>'
|
||||
);
|
||||
}
|
||||
|
||||
function testParagraphWrappingPoorlyFormedNodeContainingLink() {
|
||||
$this->assertResult(
|
||||
'<b>http://example.com',
|
||||
'<p><b><a href="http://example.com">http://example.com</a></b></p>'
|
||||
);
|
||||
}
|
||||
|
||||
function testTwoParagraphsContainingOnlyOneLink() {
|
||||
$this->assertResult(
|
||||
"http://example.com\n\nhttp://dev.example.com",
|
||||
'<p><a href="http://example.com">http://example.com</a></p><p><a href="http://dev.example.com">http://dev.example.com</a></p>'
|
||||
);
|
||||
}
|
||||
|
||||
function testParagraphNextToDivWithLinks() {
|
||||
$this->assertResult(
|
||||
'http://example.com <div>http://example.com</div>',
|
||||
'<p><a href="http://example.com">http://example.com</a> </p><div><a href="http://example.com">http://example.com</a></div>'
|
||||
);
|
||||
}
|
||||
|
||||
function testRealisticLinkInSentence() {
|
||||
$this->assertResult(
|
||||
'This URL http://example.com is what you need',
|
||||
'<p>This URL <a href="http://example.com">http://example.com</a> is what you need</p>'
|
||||
);
|
||||
}
|
||||
|
||||
function testParagraphAfterLinkifiedURL() {
|
||||
$this->assertResult(
|
||||
"http://google.com\n\n<b>b</b>",
|
||||
"<p><a href=\"http://google.com\">http://google.com</a></p><p><b>b</b></p>"
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,43 +1,43 @@
|
||||
<?php
|
||||
|
||||
class HTMLPurifier_Strategy_RemoveForeignElements_TidyTest
|
||||
extends HTMLPurifier_StrategyHarness
|
||||
{
|
||||
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$this->obj = new HTMLPurifier_Strategy_RemoveForeignElements();
|
||||
$this->config->set('HTML', 'TidyLevel', 'heavy');
|
||||
}
|
||||
|
||||
function testCenterTransform() {
|
||||
$this->assertResult(
|
||||
'<center>Look I am Centered!</center>',
|
||||
'<div style="text-align:center;">Look I am Centered!</div>'
|
||||
);
|
||||
}
|
||||
|
||||
function testFontTransform() {
|
||||
$this->assertResult(
|
||||
'<font color="red" face="Arial" size="6">Big Warning!</font>',
|
||||
'<span style="color:red;font-family:Arial;font-size:xx-large;">Big'.
|
||||
' Warning!</span>'
|
||||
);
|
||||
}
|
||||
|
||||
function testTransformToForbiddenElement() {
|
||||
$this->config->set('HTML', 'Allowed', 'div');
|
||||
$this->assertResult(
|
||||
'<font color="red" face="Arial" size="6">Big Warning!</font>',
|
||||
'Big Warning!'
|
||||
);
|
||||
}
|
||||
|
||||
function testMenuTransform() {
|
||||
$this->assertResult(
|
||||
'<menu><li>Item 1</li></menu>',
|
||||
'<ul><li>Item 1</li></ul>'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
<?php
|
||||
|
||||
class HTMLPurifier_Strategy_RemoveForeignElements_TidyTest
|
||||
extends HTMLPurifier_StrategyHarness
|
||||
{
|
||||
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$this->obj = new HTMLPurifier_Strategy_RemoveForeignElements();
|
||||
$this->config->set('HTML', 'TidyLevel', 'heavy');
|
||||
}
|
||||
|
||||
function testCenterTransform() {
|
||||
$this->assertResult(
|
||||
'<center>Look I am Centered!</center>',
|
||||
'<div style="text-align:center;">Look I am Centered!</div>'
|
||||
);
|
||||
}
|
||||
|
||||
function testFontTransform() {
|
||||
$this->assertResult(
|
||||
'<font color="red" face="Arial" size="6">Big Warning!</font>',
|
||||
'<span style="color:red;font-family:Arial;font-size:xx-large;">Big'.
|
||||
' Warning!</span>'
|
||||
);
|
||||
}
|
||||
|
||||
function testTransformToForbiddenElement() {
|
||||
$this->config->set('HTML', 'Allowed', 'div');
|
||||
$this->assertResult(
|
||||
'<font color="red" face="Arial" size="6">Big Warning!</font>',
|
||||
'Big Warning!'
|
||||
);
|
||||
}
|
||||
|
||||
function testMenuTransform() {
|
||||
$this->assertResult(
|
||||
'<menu><li>Item 1</li></menu>',
|
||||
'<ul><li>Item 1</li></ul>'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,62 +1,62 @@
|
||||
<?php
|
||||
|
||||
class HTMLPurifier_Strategy_ValidateAttributes_IDTest extends HTMLPurifier_StrategyHarness
|
||||
{
|
||||
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$this->obj = new HTMLPurifier_Strategy_ValidateAttributes();
|
||||
$this->config->set('Attr', 'EnableID', true);
|
||||
}
|
||||
|
||||
|
||||
function testPreserveIDWhenEnabled() {
|
||||
$this->assertResult('<div id="valid">Preserve the ID.</div>');
|
||||
}
|
||||
|
||||
function testRemoveInvalidID() {
|
||||
$this->assertResult(
|
||||
'<div id="0invalid">Kill the ID.</div>',
|
||||
'<div>Kill the ID.</div>'
|
||||
);
|
||||
}
|
||||
|
||||
function testRemoveDuplicateID() {
|
||||
$this->assertResult(
|
||||
'<div id="valid">Valid</div><div id="valid">Invalid</div>',
|
||||
'<div id="valid">Valid</div><div>Invalid</div>'
|
||||
);
|
||||
}
|
||||
|
||||
function testAttributeKeyCaseInsensitivity() {
|
||||
$this->assertResult(
|
||||
'<div ID="valid">Convert ID to lowercase.</div>',
|
||||
'<div id="valid">Convert ID to lowercase.</div>'
|
||||
);
|
||||
}
|
||||
|
||||
function testTrimWhitespace() {
|
||||
$this->assertResult(
|
||||
'<div id=" valid ">Trim whitespace.</div>',
|
||||
'<div id="valid">Trim whitespace.</div>'
|
||||
);
|
||||
}
|
||||
|
||||
function testIDBlacklist() {
|
||||
$this->config->set('Attr', 'IDBlacklist', array('invalid'));
|
||||
$this->assertResult(
|
||||
'<div id="invalid">Invalid</div>',
|
||||
'<div>Invalid</div>'
|
||||
);
|
||||
}
|
||||
|
||||
function testNameConvertedToID() {
|
||||
$this->config->set('HTML', 'TidyLevel', 'heavy');
|
||||
$this->assertResult(
|
||||
'<a name="foobar" />',
|
||||
'<a id="foobar" />'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
<?php
|
||||
|
||||
class HTMLPurifier_Strategy_ValidateAttributes_IDTest extends HTMLPurifier_StrategyHarness
|
||||
{
|
||||
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$this->obj = new HTMLPurifier_Strategy_ValidateAttributes();
|
||||
$this->config->set('Attr', 'EnableID', true);
|
||||
}
|
||||
|
||||
|
||||
function testPreserveIDWhenEnabled() {
|
||||
$this->assertResult('<div id="valid">Preserve the ID.</div>');
|
||||
}
|
||||
|
||||
function testRemoveInvalidID() {
|
||||
$this->assertResult(
|
||||
'<div id="0invalid">Kill the ID.</div>',
|
||||
'<div>Kill the ID.</div>'
|
||||
);
|
||||
}
|
||||
|
||||
function testRemoveDuplicateID() {
|
||||
$this->assertResult(
|
||||
'<div id="valid">Valid</div><div id="valid">Invalid</div>',
|
||||
'<div id="valid">Valid</div><div>Invalid</div>'
|
||||
);
|
||||
}
|
||||
|
||||
function testAttributeKeyCaseInsensitivity() {
|
||||
$this->assertResult(
|
||||
'<div ID="valid">Convert ID to lowercase.</div>',
|
||||
'<div id="valid">Convert ID to lowercase.</div>'
|
||||
);
|
||||
}
|
||||
|
||||
function testTrimWhitespace() {
|
||||
$this->assertResult(
|
||||
'<div id=" valid ">Trim whitespace.</div>',
|
||||
'<div id="valid">Trim whitespace.</div>'
|
||||
);
|
||||
}
|
||||
|
||||
function testIDBlacklist() {
|
||||
$this->config->set('Attr', 'IDBlacklist', array('invalid'));
|
||||
$this->assertResult(
|
||||
'<div id="invalid">Invalid</div>',
|
||||
'<div>Invalid</div>'
|
||||
);
|
||||
}
|
||||
|
||||
function testNameConvertedToID() {
|
||||
$this->config->set('HTML', 'TidyLevel', 'heavy');
|
||||
$this->assertResult(
|
||||
'<a name="foobar" />',
|
||||
'<a id="foobar" />'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -1,350 +1,350 @@
|
||||
<?php
|
||||
|
||||
class HTMLPurifier_Strategy_ValidateAttributes_TidyTest extends HTMLPurifier_StrategyHarness
|
||||
{
|
||||
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$this->obj = new HTMLPurifier_Strategy_ValidateAttributes();
|
||||
$this->config->set('HTML', 'TidyLevel', 'heavy');
|
||||
}
|
||||
|
||||
function testConvertCenterAlign() {
|
||||
$this->assertResult(
|
||||
'<h1 align="center">Centered Headline</h1>',
|
||||
'<h1 style="text-align:center;">Centered Headline</h1>'
|
||||
);
|
||||
}
|
||||
|
||||
function testConvertRightAlign() {
|
||||
$this->assertResult(
|
||||
'<h1 align="right">Right-aligned Headline</h1>',
|
||||
'<h1 style="text-align:right;">Right-aligned Headline</h1>'
|
||||
);
|
||||
}
|
||||
|
||||
function testConvertLeftAlign() {
|
||||
$this->assertResult(
|
||||
'<h1 align="left">Left-aligned Headline</h1>',
|
||||
'<h1 style="text-align:left;">Left-aligned Headline</h1>'
|
||||
);
|
||||
}
|
||||
|
||||
function testConvertJustifyAlign() {
|
||||
$this->assertResult(
|
||||
'<p align="justify">Justified Paragraph</p>',
|
||||
'<p style="text-align:justify;">Justified Paragraph</p>'
|
||||
);
|
||||
}
|
||||
|
||||
function testRemoveInvalidAlign() {
|
||||
$this->assertResult(
|
||||
'<h1 align="invalid">Invalid Headline</h1>',
|
||||
'<h1>Invalid Headline</h1>'
|
||||
);
|
||||
}
|
||||
|
||||
function testConvertTableLengths() {
|
||||
$this->assertResult(
|
||||
'<td width="5%" height="10" /><th width="10" height="5%" /><hr width="10" height="10" />',
|
||||
'<td style="width:5%;height:10px;" /><th style="width:10px;height:5%;" /><hr style="width:10px;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testTdConvertNowrap() {
|
||||
$this->assertResult(
|
||||
'<td nowrap />',
|
||||
'<td style="white-space:nowrap;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testCaptionConvertAlignLeft() {
|
||||
$this->assertResult(
|
||||
'<caption align="left" />',
|
||||
'<caption style="text-align:left;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testCaptionConvertAlignRight() {
|
||||
$this->assertResult(
|
||||
'<caption align="right" />',
|
||||
'<caption style="text-align:right;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testCaptionConvertAlignTop() {
|
||||
$this->assertResult(
|
||||
'<caption align="top" />',
|
||||
'<caption style="caption-side:top;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testCaptionConvertAlignBottom() {
|
||||
$this->assertResult(
|
||||
'<caption align="bottom" />',
|
||||
'<caption style="caption-side:bottom;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testCaptionRemoveInvalidAlign() {
|
||||
$this->assertResult(
|
||||
'<caption align="nonsense" />',
|
||||
'<caption />'
|
||||
);
|
||||
}
|
||||
|
||||
function testTableConvertAlignLeft() {
|
||||
$this->assertResult(
|
||||
'<table align="left" />',
|
||||
'<table style="float:left;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testTableConvertAlignCenter() {
|
||||
$this->assertResult(
|
||||
'<table align="center" />',
|
||||
'<table style="margin-left:auto;margin-right:auto;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testTableConvertAlignRight() {
|
||||
$this->assertResult(
|
||||
'<table align="right" />',
|
||||
'<table style="float:right;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testTableRemoveInvalidAlign() {
|
||||
$this->assertResult(
|
||||
'<table align="top" />',
|
||||
'<table />'
|
||||
);
|
||||
}
|
||||
|
||||
function testImgConvertAlignLeft() {
|
||||
$this->assertResult(
|
||||
'<img src="foobar.jpg" alt="foobar" align="left" />',
|
||||
'<img src="foobar.jpg" alt="foobar" style="float:left;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testImgConvertAlignRight() {
|
||||
$this->assertResult(
|
||||
'<img src="foobar.jpg" alt="foobar" align="right" />',
|
||||
'<img src="foobar.jpg" alt="foobar" style="float:right;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testImgConvertAlignBottom() {
|
||||
$this->assertResult(
|
||||
'<img src="foobar.jpg" alt="foobar" align="bottom" />',
|
||||
'<img src="foobar.jpg" alt="foobar" style="vertical-align:baseline;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testImgConvertAlignMiddle() {
|
||||
$this->assertResult(
|
||||
'<img src="foobar.jpg" alt="foobar" align="middle" />',
|
||||
'<img src="foobar.jpg" alt="foobar" style="vertical-align:middle;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testImgConvertAlignTop() {
|
||||
$this->assertResult(
|
||||
'<img src="foobar.jpg" alt="foobar" align="top" />',
|
||||
'<img src="foobar.jpg" alt="foobar" style="vertical-align:top;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testImgRemoveInvalidAlign() {
|
||||
$this->assertResult(
|
||||
'<img src="foobar.jpg" alt="foobar" align="outerspace" />',
|
||||
'<img src="foobar.jpg" alt="foobar" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testBorderConvertHVSpace() {
|
||||
$this->assertResult(
|
||||
'<img src="foo" alt="foo" hspace="1" vspace="3" />',
|
||||
'<img src="foo" alt="foo" style="margin-top:3px;margin-bottom:3px;margin-left:1px;margin-right:1px;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testHrConvertSize() {
|
||||
$this->assertResult(
|
||||
'<hr size="3" />',
|
||||
'<hr style="height:3px;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testHrConvertNoshade() {
|
||||
$this->assertResult(
|
||||
'<hr noshade />',
|
||||
'<hr style="color:#808080;background-color:#808080;border:0;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testHrConvertAlignLeft() {
|
||||
$this->assertResult(
|
||||
'<hr align="left" />',
|
||||
'<hr style="margin-left:0;margin-right:auto;text-align:left;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testHrConvertAlignCenter() {
|
||||
$this->assertResult(
|
||||
'<hr align="center" />',
|
||||
'<hr style="margin-left:auto;margin-right:auto;text-align:center;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testHrConvertAlignRight() {
|
||||
$this->assertResult(
|
||||
'<hr align="right" />',
|
||||
'<hr style="margin-left:auto;margin-right:0;text-align:right;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testHrRemoveInvalidAlign() {
|
||||
$this->assertResult(
|
||||
'<hr align="bottom" />',
|
||||
'<hr />'
|
||||
);
|
||||
}
|
||||
|
||||
function testBrConvertClearLeft() {
|
||||
$this->assertResult(
|
||||
'<br clear="left" />',
|
||||
'<br style="clear:left;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testBrConvertClearRight() {
|
||||
$this->assertResult(
|
||||
'<br clear="right" />',
|
||||
'<br style="clear:right;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testBrConvertClearAll() {
|
||||
$this->assertResult(
|
||||
'<br clear="all" />',
|
||||
'<br style="clear:both;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testBrConvertClearNone() {
|
||||
$this->assertResult(
|
||||
'<br clear="none" />',
|
||||
'<br style="clear:none;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testBrRemoveInvalidClear() {
|
||||
$this->assertResult(
|
||||
'<br clear="foo" />',
|
||||
'<br />'
|
||||
);
|
||||
}
|
||||
|
||||
function testUlConvertTypeDisc() {
|
||||
$this->assertResult(
|
||||
'<ul type="disc" />',
|
||||
'<ul style="list-style-type:disc;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testUlConvertTypeSquare() {
|
||||
$this->assertResult(
|
||||
'<ul type="square" />',
|
||||
'<ul style="list-style-type:square;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testUlConvertTypeCircle() {
|
||||
$this->assertResult(
|
||||
'<ul type="circle" />',
|
||||
'<ul style="list-style-type:circle;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testUlConvertTypeCaseInsensitive() {
|
||||
$this->assertResult(
|
||||
'<ul type="CIRCLE" />',
|
||||
'<ul style="list-style-type:circle;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testUlRemoveInvalidType() {
|
||||
$this->assertResult(
|
||||
'<ul type="a" />',
|
||||
'<ul />'
|
||||
);
|
||||
}
|
||||
|
||||
function testOlConvertType1() {
|
||||
$this->assertResult(
|
||||
'<ol type="1" />',
|
||||
'<ol style="list-style-type:decimal;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testOlConvertTypeLowerI() {
|
||||
$this->assertResult(
|
||||
'<ol type="i" />',
|
||||
'<ol style="list-style-type:lower-roman;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testOlConvertTypeUpperI() {
|
||||
$this->assertResult(
|
||||
'<ol type="I" />',
|
||||
'<ol style="list-style-type:upper-roman;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testOlConvertTypeLowerA() {
|
||||
$this->assertResult(
|
||||
'<ol type="a" />',
|
||||
'<ol style="list-style-type:lower-alpha;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testOlConvertTypeUpperA() {
|
||||
$this->assertResult(
|
||||
'<ol type="A" />',
|
||||
'<ol style="list-style-type:upper-alpha;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testOlRemoveInvalidType() {
|
||||
$this->assertResult(
|
||||
'<ol type="disc" />',
|
||||
'<ol />'
|
||||
);
|
||||
}
|
||||
|
||||
function testLiConvertTypeCircle() {
|
||||
$this->assertResult(
|
||||
'<li type="circle" />',
|
||||
'<li style="list-style-type:circle;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testLiConvertTypeA() {
|
||||
$this->assertResult(
|
||||
'<li type="A" />',
|
||||
'<li style="list-style-type:upper-alpha;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testLiConvertTypeCaseSensitive() {
|
||||
$this->assertResult(
|
||||
'<li type="CIRCLE" />',
|
||||
'<li />'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
<?php
|
||||
|
||||
class HTMLPurifier_Strategy_ValidateAttributes_TidyTest extends HTMLPurifier_StrategyHarness
|
||||
{
|
||||
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$this->obj = new HTMLPurifier_Strategy_ValidateAttributes();
|
||||
$this->config->set('HTML', 'TidyLevel', 'heavy');
|
||||
}
|
||||
|
||||
function testConvertCenterAlign() {
|
||||
$this->assertResult(
|
||||
'<h1 align="center">Centered Headline</h1>',
|
||||
'<h1 style="text-align:center;">Centered Headline</h1>'
|
||||
);
|
||||
}
|
||||
|
||||
function testConvertRightAlign() {
|
||||
$this->assertResult(
|
||||
'<h1 align="right">Right-aligned Headline</h1>',
|
||||
'<h1 style="text-align:right;">Right-aligned Headline</h1>'
|
||||
);
|
||||
}
|
||||
|
||||
function testConvertLeftAlign() {
|
||||
$this->assertResult(
|
||||
'<h1 align="left">Left-aligned Headline</h1>',
|
||||
'<h1 style="text-align:left;">Left-aligned Headline</h1>'
|
||||
);
|
||||
}
|
||||
|
||||
function testConvertJustifyAlign() {
|
||||
$this->assertResult(
|
||||
'<p align="justify">Justified Paragraph</p>',
|
||||
'<p style="text-align:justify;">Justified Paragraph</p>'
|
||||
);
|
||||
}
|
||||
|
||||
function testRemoveInvalidAlign() {
|
||||
$this->assertResult(
|
||||
'<h1 align="invalid">Invalid Headline</h1>',
|
||||
'<h1>Invalid Headline</h1>'
|
||||
);
|
||||
}
|
||||
|
||||
function testConvertTableLengths() {
|
||||
$this->assertResult(
|
||||
'<td width="5%" height="10" /><th width="10" height="5%" /><hr width="10" height="10" />',
|
||||
'<td style="width:5%;height:10px;" /><th style="width:10px;height:5%;" /><hr style="width:10px;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testTdConvertNowrap() {
|
||||
$this->assertResult(
|
||||
'<td nowrap />',
|
||||
'<td style="white-space:nowrap;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testCaptionConvertAlignLeft() {
|
||||
$this->assertResult(
|
||||
'<caption align="left" />',
|
||||
'<caption style="text-align:left;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testCaptionConvertAlignRight() {
|
||||
$this->assertResult(
|
||||
'<caption align="right" />',
|
||||
'<caption style="text-align:right;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testCaptionConvertAlignTop() {
|
||||
$this->assertResult(
|
||||
'<caption align="top" />',
|
||||
'<caption style="caption-side:top;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testCaptionConvertAlignBottom() {
|
||||
$this->assertResult(
|
||||
'<caption align="bottom" />',
|
||||
'<caption style="caption-side:bottom;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testCaptionRemoveInvalidAlign() {
|
||||
$this->assertResult(
|
||||
'<caption align="nonsense" />',
|
||||
'<caption />'
|
||||
);
|
||||
}
|
||||
|
||||
function testTableConvertAlignLeft() {
|
||||
$this->assertResult(
|
||||
'<table align="left" />',
|
||||
'<table style="float:left;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testTableConvertAlignCenter() {
|
||||
$this->assertResult(
|
||||
'<table align="center" />',
|
||||
'<table style="margin-left:auto;margin-right:auto;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testTableConvertAlignRight() {
|
||||
$this->assertResult(
|
||||
'<table align="right" />',
|
||||
'<table style="float:right;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testTableRemoveInvalidAlign() {
|
||||
$this->assertResult(
|
||||
'<table align="top" />',
|
||||
'<table />'
|
||||
);
|
||||
}
|
||||
|
||||
function testImgConvertAlignLeft() {
|
||||
$this->assertResult(
|
||||
'<img src="foobar.jpg" alt="foobar" align="left" />',
|
||||
'<img src="foobar.jpg" alt="foobar" style="float:left;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testImgConvertAlignRight() {
|
||||
$this->assertResult(
|
||||
'<img src="foobar.jpg" alt="foobar" align="right" />',
|
||||
'<img src="foobar.jpg" alt="foobar" style="float:right;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testImgConvertAlignBottom() {
|
||||
$this->assertResult(
|
||||
'<img src="foobar.jpg" alt="foobar" align="bottom" />',
|
||||
'<img src="foobar.jpg" alt="foobar" style="vertical-align:baseline;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testImgConvertAlignMiddle() {
|
||||
$this->assertResult(
|
||||
'<img src="foobar.jpg" alt="foobar" align="middle" />',
|
||||
'<img src="foobar.jpg" alt="foobar" style="vertical-align:middle;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testImgConvertAlignTop() {
|
||||
$this->assertResult(
|
||||
'<img src="foobar.jpg" alt="foobar" align="top" />',
|
||||
'<img src="foobar.jpg" alt="foobar" style="vertical-align:top;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testImgRemoveInvalidAlign() {
|
||||
$this->assertResult(
|
||||
'<img src="foobar.jpg" alt="foobar" align="outerspace" />',
|
||||
'<img src="foobar.jpg" alt="foobar" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testBorderConvertHVSpace() {
|
||||
$this->assertResult(
|
||||
'<img src="foo" alt="foo" hspace="1" vspace="3" />',
|
||||
'<img src="foo" alt="foo" style="margin-top:3px;margin-bottom:3px;margin-left:1px;margin-right:1px;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testHrConvertSize() {
|
||||
$this->assertResult(
|
||||
'<hr size="3" />',
|
||||
'<hr style="height:3px;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testHrConvertNoshade() {
|
||||
$this->assertResult(
|
||||
'<hr noshade />',
|
||||
'<hr style="color:#808080;background-color:#808080;border:0;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testHrConvertAlignLeft() {
|
||||
$this->assertResult(
|
||||
'<hr align="left" />',
|
||||
'<hr style="margin-left:0;margin-right:auto;text-align:left;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testHrConvertAlignCenter() {
|
||||
$this->assertResult(
|
||||
'<hr align="center" />',
|
||||
'<hr style="margin-left:auto;margin-right:auto;text-align:center;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testHrConvertAlignRight() {
|
||||
$this->assertResult(
|
||||
'<hr align="right" />',
|
||||
'<hr style="margin-left:auto;margin-right:0;text-align:right;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testHrRemoveInvalidAlign() {
|
||||
$this->assertResult(
|
||||
'<hr align="bottom" />',
|
||||
'<hr />'
|
||||
);
|
||||
}
|
||||
|
||||
function testBrConvertClearLeft() {
|
||||
$this->assertResult(
|
||||
'<br clear="left" />',
|
||||
'<br style="clear:left;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testBrConvertClearRight() {
|
||||
$this->assertResult(
|
||||
'<br clear="right" />',
|
||||
'<br style="clear:right;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testBrConvertClearAll() {
|
||||
$this->assertResult(
|
||||
'<br clear="all" />',
|
||||
'<br style="clear:both;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testBrConvertClearNone() {
|
||||
$this->assertResult(
|
||||
'<br clear="none" />',
|
||||
'<br style="clear:none;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testBrRemoveInvalidClear() {
|
||||
$this->assertResult(
|
||||
'<br clear="foo" />',
|
||||
'<br />'
|
||||
);
|
||||
}
|
||||
|
||||
function testUlConvertTypeDisc() {
|
||||
$this->assertResult(
|
||||
'<ul type="disc" />',
|
||||
'<ul style="list-style-type:disc;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testUlConvertTypeSquare() {
|
||||
$this->assertResult(
|
||||
'<ul type="square" />',
|
||||
'<ul style="list-style-type:square;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testUlConvertTypeCircle() {
|
||||
$this->assertResult(
|
||||
'<ul type="circle" />',
|
||||
'<ul style="list-style-type:circle;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testUlConvertTypeCaseInsensitive() {
|
||||
$this->assertResult(
|
||||
'<ul type="CIRCLE" />',
|
||||
'<ul style="list-style-type:circle;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testUlRemoveInvalidType() {
|
||||
$this->assertResult(
|
||||
'<ul type="a" />',
|
||||
'<ul />'
|
||||
);
|
||||
}
|
||||
|
||||
function testOlConvertType1() {
|
||||
$this->assertResult(
|
||||
'<ol type="1" />',
|
||||
'<ol style="list-style-type:decimal;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testOlConvertTypeLowerI() {
|
||||
$this->assertResult(
|
||||
'<ol type="i" />',
|
||||
'<ol style="list-style-type:lower-roman;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testOlConvertTypeUpperI() {
|
||||
$this->assertResult(
|
||||
'<ol type="I" />',
|
||||
'<ol style="list-style-type:upper-roman;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testOlConvertTypeLowerA() {
|
||||
$this->assertResult(
|
||||
'<ol type="a" />',
|
||||
'<ol style="list-style-type:lower-alpha;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testOlConvertTypeUpperA() {
|
||||
$this->assertResult(
|
||||
'<ol type="A" />',
|
||||
'<ol style="list-style-type:upper-alpha;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testOlRemoveInvalidType() {
|
||||
$this->assertResult(
|
||||
'<ol type="disc" />',
|
||||
'<ol />'
|
||||
);
|
||||
}
|
||||
|
||||
function testLiConvertTypeCircle() {
|
||||
$this->assertResult(
|
||||
'<li type="circle" />',
|
||||
'<li style="list-style-type:circle;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testLiConvertTypeA() {
|
||||
$this->assertResult(
|
||||
'<li type="A" />',
|
||||
'<li style="list-style-type:upper-alpha;" />'
|
||||
);
|
||||
}
|
||||
|
||||
function testLiConvertTypeCaseSensitive() {
|
||||
$this->assertResult(
|
||||
'<li type="CIRCLE" />',
|
||||
'<li />'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@@ -1,22 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Controller for PHPT that implements the SimpleTest unit-testing interface.
|
||||
*/
|
||||
class PHPT_Controller_SimpleTest extends SimpleTestCase
|
||||
{
|
||||
|
||||
protected $_path;
|
||||
|
||||
public function __construct($path) {
|
||||
$this->_path = $path;
|
||||
parent::__construct($path);
|
||||
}
|
||||
|
||||
public function testPhpt() {
|
||||
$suite = new PHPT_Suite(array($this->_path));
|
||||
$phpt_reporter = new PHPT_Reporter_SimpleTest($this->reporter);
|
||||
$suite->run($phpt_reporter);
|
||||
}
|
||||
|
||||
}
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Controller for PHPT that implements the SimpleTest unit-testing interface.
|
||||
*/
|
||||
class PHPT_Controller_SimpleTest extends SimpleTestCase
|
||||
{
|
||||
|
||||
protected $_path;
|
||||
|
||||
public function __construct($path) {
|
||||
$this->_path = $path;
|
||||
parent::__construct($path);
|
||||
}
|
||||
|
||||
public function testPhpt() {
|
||||
$suite = new PHPT_Suite(array($this->_path));
|
||||
$phpt_reporter = new PHPT_Reporter_SimpleTest($this->reporter);
|
||||
$suite->run($phpt_reporter);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,75 +1,75 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Proxies results from PHPT_Reporter to SimpleTest's reporter
|
||||
*/
|
||||
class PHPT_Reporter_SimpleTest implements PHPT_Reporter
|
||||
{
|
||||
|
||||
/** SimpleTest reporter to proxy results to */
|
||||
protected $reporter;
|
||||
|
||||
/** @param SimpleTest reporter */
|
||||
public function __construct($reporter) {
|
||||
$this->reporter = $reporter;
|
||||
}
|
||||
|
||||
// TODO: Figure out what the proper calls should be, since we've given
|
||||
// each Suite its own UnitTestCase controller
|
||||
|
||||
/**
|
||||
* Called when the Reporter is started from a PHPT_Suite
|
||||
* @todo Figure out if Suites can be named
|
||||
*/
|
||||
public function onSuiteStart(PHPT_Suite $suite) {
|
||||
//$this->reporter->paintGroupStart('PHPT Suite', $suite->count());
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the Reporter is finished in a PHPT_Suite
|
||||
*/
|
||||
public function onSuiteEnd(PHPT_Suite $suite) {
|
||||
//$this->reporter->paintGroupEnd('PHPT Suite');
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a Case is started
|
||||
*/
|
||||
public function onCaseStart(PHPT_Case $case) {
|
||||
//$this->reporter->paintCaseStart($case->name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a Case ends
|
||||
*/
|
||||
public function onCaseEnd(PHPT_Case $case) {
|
||||
//$this->reporter->paintCaseEnd($case->name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a Case runs without Exception
|
||||
*/
|
||||
public function onCasePass(PHPT_Case $case) {
|
||||
$this->reporter->paintPass("{$case->name} in {$case->filename}");
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a PHPT_Case_VetoException is thrown during a Case's run()
|
||||
*/
|
||||
public function onCaseSkip(PHPT_Case $case, PHPT_Case_VetoException $veto) {
|
||||
$this->reporter->paintSkip($veto->getMessage() . ' [' . $case->filename .']');
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when any Exception other than a PHPT_Case_VetoException is encountered
|
||||
* during a Case's run()
|
||||
*/
|
||||
public function onCaseFail(PHPT_Case $case, PHPT_Case_FailureException $failure) {
|
||||
$this->reporter->paintFail($failure->getReason());
|
||||
}
|
||||
|
||||
public function onParserError(Exception $exception) {
|
||||
$this->reporter->paintException($exception);
|
||||
}
|
||||
|
||||
}
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Proxies results from PHPT_Reporter to SimpleTest's reporter
|
||||
*/
|
||||
class PHPT_Reporter_SimpleTest implements PHPT_Reporter
|
||||
{
|
||||
|
||||
/** SimpleTest reporter to proxy results to */
|
||||
protected $reporter;
|
||||
|
||||
/** @param SimpleTest reporter */
|
||||
public function __construct($reporter) {
|
||||
$this->reporter = $reporter;
|
||||
}
|
||||
|
||||
// TODO: Figure out what the proper calls should be, since we've given
|
||||
// each Suite its own UnitTestCase controller
|
||||
|
||||
/**
|
||||
* Called when the Reporter is started from a PHPT_Suite
|
||||
* @todo Figure out if Suites can be named
|
||||
*/
|
||||
public function onSuiteStart(PHPT_Suite $suite) {
|
||||
//$this->reporter->paintGroupStart('PHPT Suite', $suite->count());
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the Reporter is finished in a PHPT_Suite
|
||||
*/
|
||||
public function onSuiteEnd(PHPT_Suite $suite) {
|
||||
//$this->reporter->paintGroupEnd('PHPT Suite');
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a Case is started
|
||||
*/
|
||||
public function onCaseStart(PHPT_Case $case) {
|
||||
//$this->reporter->paintCaseStart($case->name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a Case ends
|
||||
*/
|
||||
public function onCaseEnd(PHPT_Case $case) {
|
||||
//$this->reporter->paintCaseEnd($case->name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a Case runs without Exception
|
||||
*/
|
||||
public function onCasePass(PHPT_Case $case) {
|
||||
$this->reporter->paintPass("{$case->name} in {$case->filename}");
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a PHPT_Case_VetoException is thrown during a Case's run()
|
||||
*/
|
||||
public function onCaseSkip(PHPT_Case $case, PHPT_Case_VetoException $veto) {
|
||||
$this->reporter->paintSkip($veto->getMessage() . ' [' . $case->filename .']');
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when any Exception other than a PHPT_Case_VetoException is encountered
|
||||
* during a Case's run()
|
||||
*/
|
||||
public function onCaseFail(PHPT_Case $case, PHPT_Case_FailureException $failure) {
|
||||
$this->reporter->paintFail($failure->getReason());
|
||||
}
|
||||
|
||||
public function onParserError(Exception $exception) {
|
||||
$this->reporter->paintException($exception);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user