Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPTests for the DOMDocument::loadHTMLfile #340

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions ext/dom/tests/DOMDocument_loadHTMLfile.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--TEST--
Test DOMDocument::loadHTMLFile
--DESCRIPTION--
Verifies the basic behaviour of the method
--CREDITS--
Antonio Diaz Ruiz <[email protected]>
--INI--
assert.bail=true
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php
$doc = new DOMDocument();
$result = $doc->loadHTMLFile(dirname(__FILE__) . "/test.html");
assert('$result === true');
?>
--EXPECT--
18 changes: 18 additions & 0 deletions ext/dom/tests/DOMDocument_loadHTMLfile_error1.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--TEST--
Test DOMDocument::loadHTMLFile when the file doesn't exist
--DESCRIPTION--
Verifies that an error message is showed if the file doesn't exist
--CREDITS--
Antonio Diaz Ruiz <[email protected]>
--INI--
assert.bail=true
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php
$doc = new DOMDocument();
$result = $doc->loadHTMLFile(dirname(__FILE__) . "/ffff/test.html");
assert('$result === false');
?>
--EXPECTF--
%r(PHP ){0,1}%rWarning: DOMDocument::loadHTMLFile(): I/O warning : failed to load external entity %s
18 changes: 18 additions & 0 deletions ext/dom/tests/DOMDocument_loadHTMLfile_error2.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--TEST--
Test DOMDocument::loadHTMLFile when an empty string is passed
--DESCRIPTION--
Verifies that an error message is showed if an empty string is passed as argument
--CREDITS--
Antonio Diaz Ruiz <[email protected]>
--INI--
assert.bail=true
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php
$doc = new DOMDocument();
$result = $doc->loadHTMLFile("");
assert('$result === false');
?>
--EXPECTF--
%r(PHP ){0,1}%rWarning: DOMDocument::loadHTMLFile(): Empty string supplied as input %s
18 changes: 18 additions & 0 deletions ext/dom/tests/DOMDocument_loadHTMLfile_variation1.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--TEST--
Test DOMDocument::loadHTMLFile when an empty document is loaded
--DESCRIPTION--
Verifies that an warning message is showed if an empty document is loaded
--CREDITS--
Antonio Diaz Ruiz <[email protected]>
--INI--
assert.bail=true
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php
$doc = new DOMDocument();
$result = $doc->loadHTMLFile(dirname(__FILE__) . "/empty.html");
assert('$result === true');
?>
--EXPECTF--
%r(PHP ){0,1}%rWarning: DOMDocument::loadHTMLFile(): Document is empty %s
17 changes: 17 additions & 0 deletions ext/dom/tests/DOMDocument_loadHTMLfile_variation2.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--TEST--
Test DOMDocument::loadHTMLFile when a not-well formed document is loaded
--DESCRIPTION--
Verifies the behavior if a not-well formed document is loaded
--CREDITS--
Antonio Diaz Ruiz <[email protected]>
--INI--
assert.bail=true
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php
$doc = new DOMDocument();
$result = $doc->loadHTMLFile(dirname(__FILE__) . "/not_well.html");
assert('$result === true');
?>
--EXPECT--
Empty file added ext/dom/tests/empty.html
Empty file.
8 changes: 8 additions & 0 deletions ext/dom/tests/not_well.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<head>
<title>Hello world</title>
</head>
<body>
This is a not well-formed<br>
html files with undeclared entities&nbsp;
</body>
</html>