Skip to content

Commit 6a22ec3

Browse files
author
Zoe Slattery
committed
More tests from 2009 testfest
1 parent 94039c3 commit 6a22ec3

34 files changed

+1017
-31
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
--TEST--
2+
Tests DOMDocument::documentURI read and write
3+
--CREDITS--
4+
Chris Snyder <chsnyder@gmail.com>
5+
# TestFest 2009 NYPHP
6+
--SKIPIF--
7+
<?php require_once('skipif.inc'); ?>
8+
--FILE--
9+
<?php
10+
// create dom document
11+
$dom = new DOMDocument;
12+
$xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
13+
<!DOCTYPE s1 PUBLIC "http://www.ibm.com/example.dtd" "example.dtd">
14+
<s1>foo</s1>';
15+
$dom->loadXML($xml);
16+
if(!$dom) {
17+
echo "Error while parsing the document\n";
18+
exit;
19+
}
20+
echo "DOMDocument created\n";
21+
22+
$test = $dom->documentURI;
23+
echo "Read initial documentURI:\n";
24+
echo $test."\n";
25+
26+
$dom->documentURI = 'http://dom.example.org/example.xml';
27+
$test = $dom->documentURI;
28+
echo "Set documentURI to a URL, reading again:\n";
29+
var_dump( $test );
30+
31+
echo "Done\n";
32+
?>
33+
--EXPECTF--
34+
DOMDocument created
35+
Read initial documentURI:
36+
%s
37+
Set documentURI to a URL, reading again:
38+
string(34) "http://dom.example.org/example.xml"
39+
Done
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
DomDocument::schemaValidateSource() - string that is not a schema
3+
--CREDITS--
4+
Daniel Convissor <danielc@php.net>
5+
# TestFest 2009 NYPHP
6+
--SKIPIF--
7+
<?php require_once('skipif.inc'); ?>
8+
--FILE--
9+
<?php
10+
11+
$doc = new DOMDocument;
12+
13+
$doc->load(dirname(__FILE__)."/book.xml");
14+
15+
$result = $doc->schemaValidateSource('string that is not a schema');
16+
var_dump($result);
17+
18+
?>
19+
--EXPECTF--
20+
Warning: DOMDocument::schemaValidateSource(): Entity: line 1: parser error : Start tag expected, '<' not found in %s.php on line %d
21+
22+
Warning: DOMDocument::schemaValidateSource(): string that is not a schema in %s.php on line %d
23+
24+
Warning: DOMDocument::schemaValidateSource(): ^ in %s.php on line %d
25+
26+
Warning: DOMDocument::schemaValidateSource(): Failed to parse the XML resource 'in_memory_buffer'. in %s.php on line %d
27+
28+
Warning: DOMDocument::schemaValidateSource(): Invalid Schema in %s.php on line %d
29+
bool(false)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
--TEST--
2+
Tests DOMDocument::standalone get, set, and functionality
3+
--CREDITS--
4+
Chris Snyder <chsnyder@gmail.com>
5+
# TestFest 2009 NYPHP
6+
--SKIPIF--
7+
<?php require_once('skipif.inc'); ?>
8+
--FILE--
9+
<?php
10+
// create dom document
11+
$dom = new DOMDocument;
12+
$xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
13+
<!DOCTYPE s1 PUBLIC "http://www.ibm.com/example.dtd" "example.dtd">
14+
<s1>foo</s1>';
15+
$dom->loadXML($xml);
16+
if(!$dom) {
17+
echo "Error while parsing the document\n";
18+
exit;
19+
}
20+
echo "Standalone DOMDocument created\n";
21+
22+
$test = $dom->standalone;
23+
echo "Read initial standalone:\n";
24+
var_dump( $test );
25+
26+
$dom->standalone = FALSE;
27+
$test = $dom->standalone;
28+
echo "Set standalone to FALSE, reading again:\n";
29+
var_dump( $test );
30+
31+
$test = $dom->saveXML();
32+
echo "Document is no longer standalone\n";
33+
var_dump( $test );
34+
35+
echo "Done";
36+
?>
37+
--EXPECT--
38+
Standalone DOMDocument created
39+
Read initial standalone:
40+
bool(true)
41+
Set standalone to FALSE, reading again:
42+
bool(false)
43+
Document is no longer standalone
44+
string(136) "<?xml version="1.0" encoding="UTF-8" standalone="no"?>
45+
<!DOCTYPE s1 PUBLIC "http://www.ibm.com/example.dtd" "example.dtd">
46+
<s1>foo</s1>
47+
"
48+
Done

ext/ftp/tests/ftp_alloc_basic1.phpt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Testing ftp_alloc returns true
3+
--CREDITS--
4+
Rodrigo Moyle <eu [at] rodrigorm [dot] com [dot] br>
5+
#testfest PHPSP on 2009-06-20
6+
--SKIPIF--
7+
<?php
8+
require 'skipif.inc';
9+
?>
10+
--FILE--
11+
<?php
12+
require 'server.inc';
13+
14+
$ftp = ftp_connect('127.0.0.1', $port);
15+
if (!$ftp) die("Couldn't connect to the server");
16+
ftp_login($ftp, 'user', 'pass');
17+
18+
var_dump(ftp_alloc($ftp, 1024));
19+
?>
20+
--EXPECT--
21+
bool(true)

ext/ftp/tests/ftp_alloc_basic2.phpt

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
Testing ftp_alloc returns true
3+
--CREDITS--
4+
Rodrigo Moyle <eu [at] rodrigorm [dot] com [dot] br>
5+
#testfest PHPSP on 2009-06-20
6+
--SKIPIF--
7+
<?php
8+
require 'skipif.inc';
9+
?>
10+
--FILE--
11+
<?php
12+
require 'server.inc';
13+
14+
$ftp = ftp_connect('127.0.0.1', $port);
15+
if (!$ftp) die("Couldn't connect to the server");
16+
ftp_login($ftp, 'user', 'pass');
17+
18+
var_dump(ftp_alloc($ftp, 1024, $result));
19+
var_dump($result);
20+
?>
21+
--EXPECT--
22+
bool(true)
23+
string(20) "1024 bytes allocated"

ext/ftp/tests/ftp_chmod_basic.phpt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Testing ftp_chmod returns file mode
3+
--CREDITS--
4+
Rodrigo Moyle <eu [at] rodrigorm [dot] com [dot] br>
5+
#testfest PHPSP on 2009-06-20
6+
--SKIPIF--
7+
<?php
8+
require 'skipif.inc';
9+
?>
10+
--FILE--
11+
<?php
12+
require 'server.inc';
13+
14+
$ftp = ftp_connect('127.0.0.1', $port);
15+
if (!$ftp) die("Couldn't connect to the server");
16+
ftp_login($ftp, 'user', 'pass');
17+
18+
var_dump(ftp_chmod($ftp, 0644, 'test.txt'));
19+
?>
20+
--EXPECT--
21+
int(420)

ext/ftp/tests/ftp_exec_basic.phpt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Testing ftp_exec returns true
3+
--CREDITS--
4+
Rodrigo Moyle <eu [at] rodrigorm [dot] com [dot] br>
5+
#testfest PHPSP on 2009-06-20
6+
--SKIPIF--
7+
<?php
8+
require 'skipif.inc';
9+
?>
10+
--FILE--
11+
<?php
12+
require 'server.inc';
13+
14+
$ftp = ftp_connect('127.0.0.1', $port);
15+
ftp_login($ftp, 'user', 'pass');
16+
if (!$ftp) die("Couldn't connect to the server");
17+
18+
var_dump(ftp_exec($ftp, 'ls -al'));
19+
?>
20+
--EXPECT--
21+
bool(true)

ext/ftp/tests/ftp_fget_basic1.phpt

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--TEST--
2+
Testing ftp_fget ignore autoresume if autoseek is switched off
3+
--CREDITS--
4+
Rodrigo Moyle <eu [at] rodrigorm [dot] com [dot] br>
5+
#testfest PHPSP on 2009-06-20
6+
--SKIPIF--
7+
<?php
8+
require 'skipif.inc';
9+
?>
10+
--FILE--
11+
<?php
12+
require 'server.inc';
13+
14+
$ftp = ftp_connect('127.0.0.1', $port);
15+
ftp_login($ftp, 'user', 'pass');
16+
if (!$ftp) die("Couldn't connect to the server");
17+
ftp_set_option($ftp, FTP_AUTOSEEK, false);
18+
19+
$local_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . "localfile.txt";
20+
$handle = fopen($local_file, 'w');
21+
22+
var_dump(ftp_fget($ftp, $handle, 'fget.txt', FTP_ASCII, FTP_AUTORESUME));
23+
var_dump(file_get_contents($local_file));
24+
?>
25+
--CLEAN--
26+
<?php
27+
@unlink(dirname(__FILE__) . DIRECTORY_SEPARATOR . "localfile.txt");
28+
?>
29+
--EXPECT--
30+
bool(true)
31+
string(12) "ASCIIFooBar
32+
"

ext/ftp/tests/ftp_fget_basic2.phpt

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--TEST--
2+
Testing ftp_fget autoresume
3+
--CREDITS--
4+
Rodrigo Moyle <eu [at] rodrigorm [dot] com [dot] br>
5+
#testfest PHPSP on 2009-06-20
6+
--SKIPIF--
7+
<?php
8+
require 'skipif.inc';
9+
?>
10+
--FILE--
11+
<?php
12+
require 'server.inc';
13+
14+
$ftp = ftp_connect('127.0.0.1', $port);
15+
ftp_login($ftp, 'user', 'pass');
16+
if (!$ftp) die("Couldn't connect to the server");
17+
18+
$local_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . "localfile.txt";
19+
file_put_contents($local_file, 'ASCIIFoo');
20+
$handle = fopen($local_file, 'a');
21+
22+
var_dump(ftp_fget($ftp, $handle, 'fgetresume.txt', FTP_ASCII, FTP_AUTORESUME));
23+
var_dump(file_get_contents($local_file));
24+
?>
25+
--CLEAN--
26+
<?php
27+
@unlink(dirname(__FILE__) . DIRECTORY_SEPARATOR . "localfile.txt");
28+
?>
29+
--EXPECT--
30+
bool(true)
31+
string(12) "ASCIIFooBar
32+
"

ext/ftp/tests/ftp_fget_basic3.phpt

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--TEST--
2+
Testing ftp_fget resume parameter
3+
--CREDITS--
4+
Rodrigo Moyle <eu [at] rodrigorm [dot] com [dot] br>
5+
#testfest PHPSP on 2009-06-20
6+
--SKIPIF--
7+
<?php
8+
require 'skipif.inc';
9+
?>
10+
--FILE--
11+
<?php
12+
require 'server.inc';
13+
14+
$ftp = ftp_connect('127.0.0.1', $port);
15+
ftp_login($ftp, 'user', 'pass');
16+
if (!$ftp) die("Couldn't connect to the server");
17+
18+
$local_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . "localfile.txt";
19+
file_put_contents($local_file, 'ASCIIFoo');
20+
$handle = fopen($local_file, 'a');
21+
22+
var_dump(ftp_fget($ftp, $handle, 'fgetresume.txt', FTP_ASCII, 8));
23+
var_dump(file_get_contents($local_file));
24+
?>
25+
--CLEAN--
26+
<?php
27+
@unlink(dirname(__FILE__) . DIRECTORY_SEPARATOR . "localfile.txt");
28+
?>
29+
--EXPECT--
30+
bool(true)
31+
string(12) "ASCIIFooBar
32+
"

ext/ftp/tests/ftp_nb_fget_basic1.phpt

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--TEST--
2+
Testing ftp_nb_fget ignore autoresume if autoseek is switched off
3+
--CREDITS--
4+
Rodrigo Moyle <eu [at] rodrigorm [dot] com [dot] br>
5+
#testfest PHPSP on 2009-06-20
6+
--SKIPIF--
7+
<?php
8+
require 'skipif.inc';
9+
?>
10+
--FILE--
11+
<?php
12+
require 'server.inc';
13+
14+
$ftp = ftp_connect('127.0.0.1', $port);
15+
ftp_login($ftp, 'user', 'pass');
16+
if (!$ftp) die("Couldn't connect to the server");
17+
ftp_set_option($ftp, FTP_AUTOSEEK, false);
18+
19+
$local_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . "localfile.txt";
20+
$handle = fopen($local_file, 'w');
21+
22+
var_dump(ftp_nb_fget($ftp, $handle, 'fget.txt', FTP_ASCII, FTP_AUTORESUME));
23+
var_dump(file_get_contents($local_file));
24+
?>
25+
--CLEAN--
26+
<?php
27+
@unlink(dirname(__FILE__) . DIRECTORY_SEPARATOR . "localfile.txt");
28+
?>
29+
--EXPECT--
30+
int(2)
31+
string(12) "ASCIIFooBar
32+
"

ext/ftp/tests/ftp_nb_fget_basic2.phpt

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--TEST--
2+
Testing ftp_nb_fget autoresume
3+
--CREDITS--
4+
Rodrigo Moyle <eu [at] rodrigorm [dot] com [dot] br>
5+
#testfest PHPSP on 2009-06-20
6+
--SKIPIF--
7+
<?php
8+
require 'skipif.inc';
9+
?>
10+
--FILE--
11+
<?php
12+
require 'server.inc';
13+
14+
$ftp = ftp_connect('127.0.0.1', $port);
15+
ftp_login($ftp, 'user', 'pass');
16+
if (!$ftp) die("Couldn't connect to the server");
17+
18+
$local_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . "localfile.txt";
19+
file_put_contents($local_file, 'ASCIIFoo');
20+
$handle = fopen($local_file, 'a');
21+
22+
var_dump(ftp_nb_fget($ftp, $handle, 'fgetresume.txt', FTP_ASCII, FTP_AUTORESUME));
23+
var_dump(file_get_contents($local_file));
24+
?>
25+
--CLEAN--
26+
<?php
27+
@unlink(dirname(__FILE__) . DIRECTORY_SEPARATOR . "localfile.txt");
28+
?>
29+
--EXPECT--
30+
int(2)
31+
string(12) "ASCIIFooBar
32+
"

0 commit comments

Comments
 (0)