Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial tests for current bug reports

git-svn-id: http://svn.php.net/repository/pear/packages/XML_Beautifier/trunk@266673 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
commit 861ce0f567b0e6cd3f5369f8d882c02883e17199 1 parent ff2c3ba
Chuck Burgess authored
Showing with 124 additions and 0 deletions.
  1. +30 −0 tests/bug-2144.phpt
  2. +22 −0 tests/bug-5450.phpt
  3. +72 −0 tests/bug-5591.phpt
View
30 tests/bug-2144.phpt
@@ -0,0 +1,30 @@
+--TEST--
+XML Beautifier - Bug #2144: High-UTF entities in attributed decoded as ?
+--FILE--
+<?php
+/*
+ * The bug report complains of entities being changed to '?" marks,
+ * but I cannot duplicate it here. Instead, this test case
+ * fails because the XML tag is not being included in the output.
+ * That problem is already reported in Bug #5450. This test case
+ * should begin passing after #5450 is fixed.
+ */
+
+require_once 'XML/Beautifier.php';
+
+$xml = <<<EOF
+<?xml version="1.0" encoding="UTF-8"?>
+ <bogustag
+attribute="&#x418;&#x43D;&#x43D;&#x43E;&#x432;&#x430;&#x446;&#x438;&#x43E;&#x43D;&#x43D;&#x44B;&#x439;&#x434;&#x430;&#x439;&#x434;&#x436;&#x435;&#x441;&#x442;">
+ <content />
+ </bogustag>
+EOF;
+
+$bf = new XML_Beautifier();
+echo $bf->formatString( $xml);
+?>
+--EXPECT--
+<?xml version="1.0" encoding="UTF-8"?>
+<bogustag attribute="Инновационный дайджест">
+ <content />
+</bogustag>
View
22 tests/bug-5450.phpt
@@ -0,0 +1,22 @@
+--TEST--
+XML Beautifer - Bug #5450: Parser strip many tags
+--FILE--
+<?php
+require_once 'XML/Beautifier.php';
+
+$string = <<<EOF
+<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE bookmark SYSTEM "bookmark.dtd"><bookmark><category><![CDATA[ this cdata will be stripped ]]></category></bookmark>
+EOF;
+
+$xml = new XML_Beautifier();
+echo $xml->formatString($string);
+?>
+--EXPECT--
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE bookmark SYSTEM "bookmark.dtd">
+<bookmark>
+ <category>
+ <![CDATA[ this cdata will be stripped ]]>
+ </category>
+</bookmark>
+
View
72 tests/bug-5591.phpt
@@ -0,0 +1,72 @@
+--TEST--
+XML Beautifier - Bug #5591: Undefined variable notice when parsing DOCTYPE
+--FILE--
+<?php
+/*
+ * The bug report complains of a Notice being printed,
+ * but I cannot duplicate it here. Instead, this test case
+ * fails because the XML and DOCTYPE tags are not being
+ * included in the output. That problem is already
+ * reported in Bug #5450. This test case should begin
+ * passing after #5450 is fixed.
+ */
+
+error_reporting(E_ALL);
+require_once 'XML/Beautifier.php';
+
+/**
+ * XML is from http://www.samalyse.com/ln/0015.php
+ */
+$xml = <<<EOF
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
+<meta http-equiv="Content-Language" content="fr"/>
+<meta name="Description" content="Samalyse SARL - Solutions informatiques"/>
+<meta name="Keywords" content="informatique,linux,d.veloppement,gestion,audio,r.seau,maintenance"/>
+<meta name="Author" content="Olivier Guilyardi"/>
+<meta name="Revisit-after" content="5 days"/>
+<meta name="Robots" content="all"/>
+<link rel="stylesheet" href="/css/samalyse.css.php?rand=8044&amp;r_bar_size=17" type="text/css" />
+
+<title> Samalyse </title>
+
+</head>
+
+<body>
+<div style="background: white; "><a name="top" href="/index.php"><img src="/pico/logo4.gif" alt="Samalyse" border="0" width="558" height="60" /></a></div>
+</body>
+</html>
+EOF;
+
+$fmt = new XML_Beautifier();
+echo $fmt->formatString($xml);
+?>
+--EXPECT--
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html lang="fr" xml:lang="fr" xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type" />
+ <meta content="fr" http-equiv="Content-Language" />
+ <meta content="Samalyse SARL - Solutions informatiques" name="Description" />
+ <meta content="informatique,linux,d.veloppement,gestion,audio,r.seau,maintenance" name="Keywords" />
+ <meta content="Olivier Guilyardi" name="Author" />
+ <meta content="5 days" name="Revisit-after" />
+ <meta content="all" name="Robots" />
+ <link href="/css/samalyse.css.php?rand=8044&amp;r_bar_size=17" rel="stylesheet" type="text/css" />
+ <title>Samalyse</title>
+ </head>
+ <body>
+ <div style="background: white; ">
+ <a href="/index.php" name="top">
+ <img alt="Samalyse" border="0" height="60" src="/pico/logo4.gif" width="558" />
+ </a>
+ </div>
+ </body>
+</html>
Please sign in to comment.
Something went wrong with that request. Please try again.