mirror of
https://github.com/php/php-src.git
synced 2026-04-24 08:28:26 +02:00
- MFH: New tests (NorwayUG testfest)
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
--TEST--
|
||||
DOMDocument::createEntityReference() should create a new entity reference node
|
||||
--CREDITS--
|
||||
Knut Urdalen <knut@php.net>
|
||||
#PHPTestFest2009 Norway 2009-06-09 \o/
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once dirname(__FILE__) .'/skipif.inc';
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$dom = new DOMDocument('1.0');
|
||||
$ref = $dom->createEntityReference('nbsp');
|
||||
$dom->appendChild($ref);
|
||||
echo $dom->saveXML();
|
||||
?>
|
||||
--EXPECTF--
|
||||
<?xml version="1.0"?>
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
--TEST--
|
||||
DOMDocument::saveHTMLFile() should dump the internal document into a file using HTML formatting
|
||||
--CREDITS--
|
||||
Knut Urdalen <knut@php.net>
|
||||
#PHPTestFest2009 Norway 2009-06-09 \o/
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once dirname(__FILE__) .'/skipif.inc';
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$filename = dirname(__FILE__)."/tmp_savehtmlfile".time().".html";
|
||||
$doc = new DOMDocument('1.0');
|
||||
$root = $doc->createElement('html');
|
||||
$root = $doc->appendChild($root);
|
||||
$head = $doc->createElement('head');
|
||||
$head = $root->appendChild($head);
|
||||
$title = $doc->createElement('title');
|
||||
$title = $head->appendChild($title);
|
||||
$text = $doc->createTextNode('This is the title');
|
||||
$text = $title->appendChild($text);
|
||||
$bytes = $doc->saveHTMLFile($filename);
|
||||
var_dump($bytes);
|
||||
echo file_get_contents($filename);
|
||||
unlink($filename);
|
||||
?>
|
||||
--EXPECTF--
|
||||
int(126)
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>This is the title</title></head></html>
|
||||
@@ -0,0 +1,24 @@
|
||||
--TEST--
|
||||
DOMDocument::saveHTMLFile() should fail if no parameter is given
|
||||
--CREDITS--
|
||||
Knut Urdalen <knut@php.net>
|
||||
#PHPTestFest2009 Norway 2009-06-09 \o/
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once('skipif.inc');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$doc = new DOMDocument('1.0');
|
||||
$root = $doc->createElement('html');
|
||||
$root = $doc->appendChild($root);
|
||||
$head = $doc->createElement('head');
|
||||
$head = $root->appendChild($head);
|
||||
$title = $doc->createElement('title');
|
||||
$title = $head->appendChild($title);
|
||||
$text = $doc->createTextNode('This is the title');
|
||||
$text = $title->appendChild($text);
|
||||
$doc->saveHTMLFile();
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: DOMDocument::saveHTMLFile() expects exactly 1 parameter, 0 given in %s on line %d
|
||||
@@ -0,0 +1,15 @@
|
||||
--TEST--
|
||||
DOMDocument::saveHTMLFile() should fail if called statically
|
||||
--CREDITS--
|
||||
Knut Urdalen <knut@php.net>
|
||||
#PHPTestFest2009 Norway 2009-06-09 \o/
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once dirname(__FILE__) .'/skipif.inc';
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
DOMDocument::saveHTMLFile();
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Non-static method DOMDocument::saveHTMLFile() cannot be called statically in %s on line %d
|
||||
@@ -0,0 +1,33 @@
|
||||
--TEST--
|
||||
DOMDocument::saveHTMLFile() should format output on demand
|
||||
--CREDITS--
|
||||
Knut Urdalen <knut@php.net>
|
||||
#PHPTestFest2009 Norway 2009-06-09 \o/
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once dirname(__FILE__) .'/skipif.inc';
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$filename = dirname(__FILE__)."/tmp_savehtmlfile".time().".html";
|
||||
$doc = new DOMDocument('1.0');
|
||||
$doc->formatOutput = true;
|
||||
$root = $doc->createElement('html');
|
||||
$root = $doc->appendChild($root);
|
||||
$head = $doc->createElement('head');
|
||||
$head = $root->appendChild($head);
|
||||
$title = $doc->createElement('title');
|
||||
$title = $head->appendChild($title);
|
||||
$text = $doc->createTextNode('This is the title');
|
||||
$text = $title->appendChild($text);
|
||||
$bytes = $doc->saveHTMLFile($filename);
|
||||
var_dump($bytes);
|
||||
echo file_get_contents($filename);
|
||||
unlink($filename);
|
||||
?>
|
||||
--EXPECTF--
|
||||
int(129)
|
||||
<html><head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>This is the title</title>
|
||||
</head></html>
|
||||
@@ -0,0 +1,25 @@
|
||||
--TEST--
|
||||
DOMDocument::saveHTMLFile() should fail with invalid filename
|
||||
--CREDITS--
|
||||
Knut Urdalen <knut@php.net>
|
||||
#PHPTestFest2009 Norway 2009-06-09 \o/
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once dirname(__FILE__) .'/skipif.inc';
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$filename = null;
|
||||
$doc = new DOMDocument('1.0');
|
||||
$root = $doc->createElement('html');
|
||||
$root = $doc->appendChild($root);
|
||||
$head = $doc->createElement('head');
|
||||
$head = $root->appendChild($head);
|
||||
$title = $doc->createElement('title');
|
||||
$title = $head->appendChild($title);
|
||||
$text = $doc->createTextNode('This is the title');
|
||||
$text = $title->appendChild($text);
|
||||
$bytes = $doc->saveHTMLFile($filename);
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: DOMDocument::saveHTMLFile(): Invalid Filename in %s on line %d
|
||||
@@ -0,0 +1,24 @@
|
||||
--TEST--
|
||||
DOMDocument::saveHTML() should dump the internal document into a string using HTML formatting
|
||||
--CREDITS--
|
||||
Knut Urdalen <knut@php.net>
|
||||
#PHPTestFest2009 Norway 2009-06-09 \o/
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once dirname(__FILE__) .'/skipif.inc';
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$doc = new DOMDocument('1.0');
|
||||
$root = $doc->createElement('html');
|
||||
$root = $doc->appendChild($root);
|
||||
$head = $doc->createElement('head');
|
||||
$head = $root->appendChild($head);
|
||||
$title = $doc->createElement('title');
|
||||
$title = $head->appendChild($title);
|
||||
$text = $doc->createTextNode('This is the title');
|
||||
$text = $title->appendChild($text);
|
||||
echo $doc->saveHTML();
|
||||
?>
|
||||
--EXPECTF--
|
||||
<html><head><title>This is the title</title></head></html>
|
||||
@@ -0,0 +1,24 @@
|
||||
--TEST--
|
||||
DOMDocument::saveHTML() should fail if a parameter is given
|
||||
--CREDITS--
|
||||
Knut Urdalen <knut@php.net>
|
||||
#PHPTestFest2009 Norway 2009-06-09 \o/
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once('skipif.inc');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$doc = new DOMDocument('1.0');
|
||||
$root = $doc->createElement('html');
|
||||
$root = $doc->appendChild($root);
|
||||
$head = $doc->createElement('head');
|
||||
$head = $root->appendChild($head);
|
||||
$title = $doc->createElement('title');
|
||||
$title = $head->appendChild($title);
|
||||
$text = $doc->createTextNode('This is the title');
|
||||
$text = $title->appendChild($text);
|
||||
echo $doc->saveHTML(true);
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: DOMDocument::saveHTML() expects exactly 0 parameters, 1 given in %s on line %d
|
||||
@@ -0,0 +1,15 @@
|
||||
--TEST--
|
||||
DOMDocument::saveHTML() should fail if called statically
|
||||
--CREDITS--
|
||||
Knut Urdalen <knut@php.net>
|
||||
#PHPTestFest2009 Norway 2009-06-09 \o/
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once dirname(__FILE__) .'/skipif.inc';
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
DOMDocument::saveHTML(true);
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Non-static method DOMDocument::saveHTML() cannot be called statically in %s on line %d
|
||||
@@ -0,0 +1,31 @@
|
||||
--TEST--
|
||||
DOMDocument::validate() should validate an internal DTD declaration
|
||||
--CREDITS--
|
||||
Knut Urdalen <knut@php.net>
|
||||
#PHPTestFest2009 Norway 2009-06-09 \o/
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once dirname(__FILE__) .'/skipif.inc';
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$xml = "<?xml version=\"1.0\"?>
|
||||
<!DOCTYPE note [
|
||||
<!ELEMENT note (to,from,heading,body)>
|
||||
<!ELEMENT to (#PCDATA)>
|
||||
<!ELEMENT from (#PCDATA)>
|
||||
<!ELEMENT heading (#PCDATA)>
|
||||
<!ELEMENT body (#PCDATA)>
|
||||
]>
|
||||
<note>
|
||||
<to>Tove</to>
|
||||
<from>Jani</from>
|
||||
<heading>Reminder</heading>
|
||||
<body>Don't forget me this weekend</body>
|
||||
</note>";
|
||||
$dom = new DOMDocument('1.0');
|
||||
$dom->loadXML($xml);
|
||||
var_dump($dom->validate());
|
||||
?>
|
||||
--EXPECTF--
|
||||
bool(true)
|
||||
@@ -0,0 +1,16 @@
|
||||
--TEST--
|
||||
DOMDocument::validate() should fail if any parameter is given
|
||||
--CREDITS--
|
||||
Knut Urdalen <knut@php.net>
|
||||
#PHPTestFest2009 Norway 2009-06-09 \o/
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once dirname(__FILE__) .'/skipif.inc';
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$dom = new DOMDocument('1.0');
|
||||
$dom->validate(true);
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: DOMDocument::validate() expects exactly 0 parameters, 1 given in %s on line %d
|
||||
@@ -0,0 +1,15 @@
|
||||
--TEST--
|
||||
DOMDocument::validate() should fail if called statically
|
||||
--CREDITS--
|
||||
Knut Urdalen <knut@php.net>
|
||||
#PHPTestFest2009 Norway 2009-06-09 \o/
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once dirname(__FILE__) .'/skipif.inc';
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
DOMDocument::validate();
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Non-static method DOMDocument::validate() cannot be called statically in %s on line %d
|
||||
@@ -0,0 +1,19 @@
|
||||
--TEST--
|
||||
DOMDocument::validate() should validate an external DTD declaration
|
||||
--CREDITS--
|
||||
Knut Urdalen <knut@php.net>
|
||||
#PHPTestFest2009 Norway 2009-06-09 \o/
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once dirname(__FILE__) .'/skipif.inc';
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
// reusing existing xml: http://cvs.php.net/viewvc.cgi/php-src/ext/dom/tests/dom.xml?view=co&content-type=text%2Fplain
|
||||
// reusing existing dtd: http://cvs.php.net/viewvc.cgi/php-src/ext/dom/tests/dom.ent?view=co&content-type=text%2Fplain
|
||||
$dom = new DOMDocument('1.0');
|
||||
$dom->load(dirname(__FILE__).'/dom.xml');
|
||||
var_dump($dom->validate());
|
||||
?>
|
||||
--EXPECTF--
|
||||
bool(true)
|
||||
Reference in New Issue
Block a user