diff options
author | Zoe Slattery <zoe@php.net> | 2009-08-26 17:17:58 +0000 |
---|---|---|
committer | Zoe Slattery <zoe@php.net> | 2009-08-26 17:17:58 +0000 |
commit | 1c98e49afd36a73c01edf1124fc69bc38370c7e4 (patch) | |
tree | c92d8655bff4a3e09850b0cacd1113ff7d3daa0e | |
parent | c7167ced0bc5da4703c29f03a586988a97bff299 (diff) | |
download | php-git-1c98e49afd36a73c01edf1124fc69bc38370c7e4.tar.gz |
Test from 2009 testfest
150 files changed, 4276 insertions, 0 deletions
diff --git a/Zend/tests/get_required_files.phpt b/Zend/tests/get_required_files.phpt new file mode 100644 index 0000000000..c2ba368884 --- /dev/null +++ b/Zend/tests/get_required_files.phpt @@ -0,0 +1,16 @@ +--TEST-- +Check if get_required_files works +--CREDITS-- +Sebastian Schürmann +sschuermann@chip.de +Testfest 2009 Munich +--FILE-- +<?php +$files = get_required_files(); +var_dump($files); +?> +--EXPECTF-- +array(1) { + [0]=> + %string|unicode%(%d)%s +} diff --git a/ext/curl/tests/curl_copy_handle_basic.phpt b/ext/curl/tests/curl_copy_handle_basic.phpt new file mode 100644 index 0000000000..1a6ff41699 --- /dev/null +++ b/ext/curl/tests/curl_copy_handle_basic.phpt @@ -0,0 +1,30 @@ +--TEST-- +Test curl_copy_handle() function with basic functionality +--CREDITS-- +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("curl")) exit("skip curl extension not loaded"); +?> +--FILE-- +<?php +echo "*** Testing curl_copy_handle(): basic ***\n"; + +// create a new cURL resource +$ch = curl_init(); + +// set URL and other appropriate options +curl_setopt($ch, CURLOPT_URL, 'http://www.example.com/'); +curl_setopt($ch, CURLOPT_HEADER, 0); + +// copy the handle +$ch2 = curl_copy_handle($ch); + +var_dump(curl_getinfo($ch) === curl_getinfo($ch2)); +?> +===DONE=== +--EXPECTF-- +*** Testing curl_copy_handle(): basic *** +bool(true) +===DONE=== diff --git a/ext/curl/tests/curl_copy_handle_variation1.phpt b/ext/curl/tests/curl_copy_handle_variation1.phpt new file mode 100644 index 0000000000..da4522192d --- /dev/null +++ b/ext/curl/tests/curl_copy_handle_variation1.phpt @@ -0,0 +1,32 @@ +--TEST-- +Test curl_copy_handle() change options in one handle +--CREDITS-- +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("curl")) exit("skip curl extension not loaded"); +?> +--FILE-- +<?php +echo "*** Testing curl_copy_handle(): basic ***\n"; + +// create a new cURL resource +$ch = curl_init(); + +// set URL and other appropriate options +curl_setopt($ch, CURLOPT_URL, 'http://www.example.com/'); + +// copy the handle +$ch2 = curl_copy_handle($ch); + +// change the CURLOPT_URL for the second handle +curl_setopt($ch2, CURLOPT_URL, 'http://www.bar.com/'); + +var_dump(curl_getinfo($ch) === curl_getinfo($ch2)); +?> +===DONE=== +--EXPECTF-- +*** Testing curl_copy_handle(): basic *** +bool(false) +===DONE=== diff --git a/ext/curl/tests/curl_copy_handle_variation2.phpt b/ext/curl/tests/curl_copy_handle_variation2.phpt new file mode 100644 index 0000000000..924bf6a470 --- /dev/null +++ b/ext/curl/tests/curl_copy_handle_variation2.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test curl_copy_handle() add options to the handles +--CREDITS-- +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("curl")) exit("skip curl extension not loaded"); +?> +--COMMENT-- +the only way to test if a option is setten on a curl handle is using the curl_getinfo() function. +but this can only check on a limited amount of options... +--FILE-- +<?php +echo "*** Testing curl_copy_handle(): add options after copy ***\n"; + +// create a new cURL resource +$ch = curl_init(); + +// copy the handle +$ch2 = curl_copy_handle($ch); +var_dump(curl_getinfo($ch) === curl_getinfo($ch2)); + +// add some CURLOPT to the second handle +curl_setopt($ch2, CURLOPT_URL, 'http://www.example.com/'); + +var_dump(curl_getinfo($ch) === curl_getinfo($ch2)); + +// add same CURLOPT to the first handle +curl_setopt($ch, CURLOPT_URL, 'http://www.example.com/'); +var_dump(curl_getinfo($ch) === curl_getinfo($ch2)); + +// change a CURLOPT in the second handle +curl_setopt($ch2, CURLOPT_URL, 'http://www.bar.com/'); +var_dump(curl_getinfo($ch) === curl_getinfo($ch2)); +?> +===DONE=== +--EXPECTF-- +*** Testing curl_copy_handle(): add options after copy *** +bool(true) +bool(false) +bool(true) +bool(false) +===DONE=== diff --git a/ext/dom/tests/DOMAttr_value_basic_001.phpt b/ext/dom/tests/DOMAttr_value_basic_001.phpt new file mode 100755 index 0000000000..2a2b52121d --- /dev/null +++ b/ext/dom/tests/DOMAttr_value_basic_001.phpt @@ -0,0 +1,11 @@ +--TEST-- +Read empty $value. +--CREDIT-- +Jason Bouffard <jbouffard1@yahoo.com> +# TestFest Atlanta 2009-05-14 +--FILE-- +<?php +$attr = new DOMAttr('category'); +print $attr->value."\n"; +?> +--EXPECTF-- diff --git a/ext/dom/tests/DOMCharacterData_data_basic_002.phpt b/ext/dom/tests/DOMCharacterData_data_basic_002.phpt new file mode 100644 index 0000000000..394b316fa3 --- /dev/null +++ b/ext/dom/tests/DOMCharacterData_data_basic_002.phpt @@ -0,0 +1,28 @@ +--TEST-- +Create CDATA section and change it using DOMcreateCDATASection +--CREDITS-- +Nic Rosental nicrosental@gmail.com +# TestFest Atlanta 2009-5-28 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +$document = new DOMDocument; +$root = $document->createElement('root'); +$document->appendChild($root); + +$cdata = $document->createCDATASection('t'); +$root->appendChild($cdata); +print $document->saveXML()."\n"; + +$cdata->data = 100; +print $document->saveXML()."\n"; + +?> +--EXPECT-- +<?xml version="1.0"?> +<root><![CDATA[t]]></root> + +<?xml version="1.0"?> +<root><![CDATA[100]]></root> diff --git a/ext/dom/tests/DOMCharacterData_length_error_001.phpt b/ext/dom/tests/DOMCharacterData_length_error_001.phpt new file mode 100755 index 0000000000..87c9377b3d --- /dev/null +++ b/ext/dom/tests/DOMCharacterData_length_error_001.phpt @@ -0,0 +1,12 @@ +--TEST-- +Invalid State Error when getting length on DOMCharacterData out of content. +--CREDIT-- +Jason Bouffard <jbouffard1@yahoo.com> +# TestFest Atlanta 2009-05-14 +--FILE-- +<?php +$character_data = new DOMCharacterData(); +print $character_data->length; +?> +--EXPECTF-- +Warning: main(): Invalid State Error in %s
\ No newline at end of file diff --git a/ext/dom/tests/DOMCharacterData_substringData_basic_001.phpt b/ext/dom/tests/DOMCharacterData_substringData_basic_001.phpt new file mode 100644 index 0000000000..b9d73e1819 --- /dev/null +++ b/ext/dom/tests/DOMCharacterData_substringData_basic_001.phpt @@ -0,0 +1,21 @@ +--TEST-- +__DOMCharacterData::substringData pull mid section of string +--CREDITS-- +Nic Rosental nicrosental@gmail.com +# TestFest Atlanta 2009-5-28 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +$document = new DOMDocument; +$root = $document->createElement('root'); +$document->appendChild($root); + +$cdata = $document->createCDATASection('testfest'); +$root->appendChild($cdata); +print $cdata->substringData(1, 6); + +?> +--EXPECT-- +estfes
\ No newline at end of file diff --git a/ext/dom/tests/DOMDocument_config_basic.phpt b/ext/dom/tests/DOMDocument_config_basic.phpt new file mode 100644 index 0000000000..947743abe6 --- /dev/null +++ b/ext/dom/tests/DOMDocument_config_basic.phpt @@ -0,0 +1,26 @@ +--TEST-- +Tests DOMDocument::config read +--CREDITS-- +Chris Snyder <chsnyder@gmail.com> +# TestFest 2009 NYPHP +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +// create dom document +$dom = new DOMDocument; +echo "DOMDocument created\n"; + +$test = $dom->config; +echo "Read config:\n"; +var_dump( $test ); + +// note -- will always be null as DOMConfiguration is not implemented in PHP + +echo "Done\n"; +?> +--EXPECT-- +DOMDocument created +Read config: +NULL +Done diff --git a/ext/dom/tests/DOMDocument_encoding_basic.phpt b/ext/dom/tests/DOMDocument_encoding_basic.phpt new file mode 100644 index 0000000000..9fc099bfe2 --- /dev/null +++ b/ext/dom/tests/DOMDocument_encoding_basic.phpt @@ -0,0 +1,52 @@ +--TEST-- +DOMDocument::$encoding - read/write tests (dom_document_encoding_read/dom_document_encoding_write) +--CREDITS-- +Hans Zaunere +# TestFest 2009 NYPHP +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +require_once('dom_test.inc'); + +$dom = new DOMDocument; +$dom->loadXML($xmlstr); + +if( !$dom ) +{ + echo "Error while parsing the document\n"; + exit; +} + +echo "Empty Encoding Read: {$dom->encoding}\n"; + +$ret = $dom->encoding = 'NYPHP DOMinatrix'; +echo "Adding invalid encoding: $ret\n"; + +$ret = $dom->encoding = 'ISO-8859-1'; +echo "Adding ISO-8859-1 encoding: $ret\n"; +echo "ISO-8859-1 Encoding Read: {$dom->encoding}\n"; + +$ret = $dom->encoding = 'UTF-8'; +echo "Adding UTF-8 encoding: $ret\n"; +echo "UTF-8 Encoding Read: {$dom->encoding}\n"; + +$ret = $dom->encoding = 'UTF-16'; +echo "Adding UTF-16 encoding: $ret\n"; +echo "UTF-16 Encoding Read: {$dom->encoding}\n"; + + +?> +--EXPECTF-- +Empty Encoding Read: + +Warning: main(): Invalid Document Encoding in %s on line %d +Adding invalid encoding: NYPHP DOMinatrix +Adding ISO-8859-1 encoding: ISO-8859-1 +ISO-8859-1 Encoding Read: ISO-8859-1 +Adding UTF-8 encoding: UTF-8 +UTF-8 Encoding Read: UTF-8 +Adding UTF-16 encoding: UTF-16 +UTF-16 Encoding Read: UTF-16 + diff --git a/ext/dom/tests/DOMDocument_implementationRead_basic.phpt b/ext/dom/tests/DOMDocument_implementationRead_basic.phpt new file mode 100644 index 0000000000..17daddf38b --- /dev/null +++ b/ext/dom/tests/DOMDocument_implementationRead_basic.phpt @@ -0,0 +1,21 @@ +--TEST-- +DOMDocument::DOMImplementation - basic test for DomDocument::DOMImplementation +--CREDITS-- +Lev Radin <prokurator@gmail.com> +# TestFest 2009 NYPHP +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +$doc = new DOMDocument; +$doc->load(dirname(__FILE__)."/book.xml"); + +var_dump($doc->implementation); + + +?> +--EXPECTF-- +object(DOMImplementation)#%d (0) { +} + diff --git a/ext/dom/tests/DOMDocument_preserveWhiteSpace_basic.phpt b/ext/dom/tests/DOMDocument_preserveWhiteSpace_basic.phpt new file mode 100644 index 0000000000..a772bc8569 --- /dev/null +++ b/ext/dom/tests/DOMDocument_preserveWhiteSpace_basic.phpt @@ -0,0 +1,23 @@ +--TEST-- +DOMDocument::$preserveWhiteSpace - test ability to read and write property +--CREDITS-- +Lev Radin <prokurator@gmail.com> +# TestFest 2009 NYPHP +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +$doc = new DOMDocument; +$doc->load(dirname(__FILE__)."/book.xml"); + +var_dump($doc->preserveWhiteSpace); + +$doc->preserveWhiteSpace = false; +var_dump($doc->preserveWhiteSpace); + +?> +--EXPECT-- +bool(true) +bool(false) + diff --git a/ext/dom/tests/DOMDocument_preserveWhiteSpace_variations.phpt b/ext/dom/tests/DOMDocument_preserveWhiteSpace_variations.phpt new file mode 100644 index 0000000000..e467f56aa3 --- /dev/null +++ b/ext/dom/tests/DOMDocument_preserveWhiteSpace_variations.phpt @@ -0,0 +1,40 @@ +--TEST-- +DOMDocument::$preserveWhiteSpace - test ability to read and write property +--CREDITS-- +Lev Radin <prokurator@gmail.com> +# TestFest 2009 NYPHP +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +echo "Load document with preserveWhiteSpace on\n"; +$doc = new DOMDocument; +$doc->load(dirname(__FILE__)."/book.xml"); +echo $doc->saveXML(); + + +echo "\nLoad document with preserveWhiteSpace off\n"; +$doc = new DOMDocument; +$doc->preserveWhiteSpace = false; +$doc->load(dirname(__FILE__)."/book.xml"); +echo $doc->saveXML(); + +?> +--EXPECT-- +Load document with preserveWhiteSpace on +<?xml version="1.0"?> +<books> + <book> + <title>The Grapes of Wrath</title> + <author>John Steinbeck</author> + </book> + <book> + <title>The Pearl</title> + <author>John Steinbeck</author> + </book> +</books> + +Load document with preserveWhiteSpace off +<?xml version="1.0"?> +<books><book><title>The Grapes of Wrath</title><author>John Steinbeck</author></book><book><title>The Pearl</title><author>John Steinbeck</author></book></books> diff --git a/ext/dom/tests/DOMDocument_resolveExternals_basic.phpt b/ext/dom/tests/DOMDocument_resolveExternals_basic.phpt new file mode 100644 index 0000000000..ccada3fe99 --- /dev/null +++ b/ext/dom/tests/DOMDocument_resolveExternals_basic.phpt @@ -0,0 +1,49 @@ +--TEST-- +Tests DOMDocument::resoleExternals get and set +--CREDITS-- +Chris Snyder <chsnyder@gmail.com> +# TestFest 2009 NYPHP +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +// create dom document +$dom = new DOMDocument; +$xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" + "http://www.w3.org/TR/html4/strict.dtd"> +<h1>"Foo"</h1>'; +$dom->loadXML($xml); +if(!$dom) { + echo "Error while parsing the document\n"; + exit; +} +echo "DOMDocument with external entities created\n"; + +$test = $dom->resolveExternals; +echo "Read initial resolveExternals:\n"; +var_dump( $test ); + +$dom->resolveExternals = TRUE; +$test = $dom->resolveExternals; +echo "Set resolveExternals to TRUE, reading again:\n"; +var_dump( $test ); + +/** + * Don't bother testing the resolveExternals functionality here, it throws warnings on html dtd + * +echo "Reloading xml with resolveExternals turned on\n"; +$dom->loadXML($xml); +$test = $dom->saveXML(); +var_dump( $test ); + */ + +echo "Done"; +?> +--EXPECT-- +DOMDocument with external entities created +Read initial resolveExternals: +bool(false) +Set resolveExternals to TRUE, reading again: +bool(true) +Done
\ No newline at end of file diff --git a/ext/dom/tests/DOMDocument_schemaValidateSource_basic.phpt b/ext/dom/tests/DOMDocument_schemaValidateSource_basic.phpt new file mode 100755 index 0000000000..38bc3fa3cc --- /dev/null +++ b/ext/dom/tests/DOMDocument_schemaValidateSource_basic.phpt @@ -0,0 +1,22 @@ +--TEST-- +DomDocument::schemaValidateSource() - basic +--CREDITS-- +Daniel Convissor <danielc@php.net> +# TestFest 2009 NYPHP +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +$doc = new DOMDocument; + +$doc->load(dirname(__FILE__)."/book.xml"); + +$xsd = file_get_contents(dirname(__FILE__)."/book.xsd"); + +$result = $doc->schemaValidateSource($xsd); +var_dump($result); + +?> +--EXPECT-- +bool(true) diff --git a/ext/dom/tests/DOMDocument_schemaValidateSource_error2.phpt b/ext/dom/tests/DOMDocument_schemaValidateSource_error2.phpt new file mode 100755 index 0000000000..41a833b5aa --- /dev/null +++ b/ext/dom/tests/DOMDocument_schemaValidateSource_error2.phpt @@ -0,0 +1,23 @@ +--TEST-- +DomDocument::schemaValidateSource() - non-conforming schema +--CREDITS-- +Daniel Convissor <danielc@php.net> +# TestFest 2009 NYPHP +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +$doc = new DOMDocument; + +$doc->load(dirname(__FILE__)."/book.xml"); + +$xsd = file_get_contents(dirname(__FILE__)."/book-non-conforming-schema.xsd"); + +$result = $doc->schemaValidateSource($xsd); +var_dump($result); + +?> +--EXPECTF-- +Warning: DOMDocument::schemaValidateSource(): Element 'books': No matching global declaration available for the validation root. in %s.php on line %d +bool(false) diff --git a/ext/dom/tests/DOMDocument_schemaValidateSource_error3.phpt b/ext/dom/tests/DOMDocument_schemaValidateSource_error3.phpt new file mode 100755 index 0000000000..93dd792609 --- /dev/null +++ b/ext/dom/tests/DOMDocument_schemaValidateSource_error3.phpt @@ -0,0 +1,21 @@ +--TEST-- +DomDocument::schemaValidateSource() - empty string for schema string +--CREDITS-- +Daniel Convissor <danielc@php.net> +# TestFest 2009 NYPHP +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +$doc = new DOMDocument; + +$doc->load(dirname(__FILE__)."/book.xml"); + +$result = $doc->schemaValidateSource(''); +var_dump($result); + +?> +--EXPECTF-- +Warning: DOMDocument::schemaValidateSource(): Invalid Schema source in %s.php on line %d +bool(false) diff --git a/ext/dom/tests/DOMDocument_schemaValidateSource_error4.phpt b/ext/dom/tests/DOMDocument_schemaValidateSource_error4.phpt new file mode 100755 index 0000000000..65c8d8678f --- /dev/null +++ b/ext/dom/tests/DOMDocument_schemaValidateSource_error4.phpt @@ -0,0 +1,21 @@ +--TEST-- +DomDocument::schemaValidateSource() - pass no parameters +--CREDITS-- +Daniel Convissor <danielc@php.net> +# TestFest 2009 NYPHP +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +$doc = new DOMDocument; + +$doc->load(dirname(__FILE__)."/book.xml"); + +$result = $doc->schemaValidateSource(); +var_dump($result); + +?> +--EXPECTF-- +Warning: DOMDocument::schemaValidateSource() expects exactly 1 parameter, 0 given in %s.php on line %d +NULL diff --git a/ext/dom/tests/DOMDocument_schemaValidate_basic.phpt b/ext/dom/tests/DOMDocument_schemaValidate_basic.phpt new file mode 100755 index 0000000000..eec790de6f --- /dev/null +++ b/ext/dom/tests/DOMDocument_schemaValidate_basic.phpt @@ -0,0 +1,20 @@ +--TEST-- +DomDocument::schemaValidate() - basic +--CREDITS-- +Daniel Convissor <danielc@php.net> +# TestFest 2009 NYPHP +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +$doc = new DOMDocument; + +$doc->load(dirname(__FILE__)."/book.xml"); + +$result = $doc->schemaValidate(dirname(__FILE__)."/book.xsd"); +var_dump($result); + +?> +--EXPECT-- +bool(true) diff --git a/ext/dom/tests/DOMDocument_schemaValidate_error1.phpt b/ext/dom/tests/DOMDocument_schemaValidate_error1.phpt new file mode 100755 index 0000000000..594c3c4291 --- /dev/null +++ b/ext/dom/tests/DOMDocument_schemaValidate_error1.phpt @@ -0,0 +1,29 @@ +--TEST-- +DomDocument::schemaValidate() - file that is not a schema +--CREDITS-- +Daniel Convissor <danielc@php.net> +# TestFest 2009 NYPHP +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +$doc = new DOMDocument; + +$doc->load(dirname(__FILE__)."/book.xml"); + +$result = $doc->schemaValidate(dirname(__FILE__)."/book-not-a-schema.xsd"); +var_dump($result); + +?> +--EXPECTF-- +Warning: DOMDocument::schemaValidate(): %sbook-not-a-schema.xsd:1: parser error : Start tag expected, '<' not found in %s.php on line %d + +Warning: DOMDocument::schemaValidate(): Let's see what happens upon parsing a file that doesn't contain a schema. in %s.php on line %d + +Warning: DOMDocument::schemaValidate(): ^ in %s.php on line %d + +Warning: DOMDocument::schemaValidate(): Failed to parse the XML resource '%sbook-not-a-schema.xsd'. in %s.php on line %d + +Warning: DOMDocument::schemaValidate(): Invalid Schema in %s.php on line %d +bool(false) diff --git a/ext/dom/tests/DOMDocument_schemaValidate_error2.phpt b/ext/dom/tests/DOMDocument_schemaValidate_error2.phpt new file mode 100755 index 0000000000..5ffd533652 --- /dev/null +++ b/ext/dom/tests/DOMDocument_schemaValidate_error2.phpt @@ -0,0 +1,21 @@ +--TEST-- +DomDocument::schemaValidate() - non-conforming schema file +--CREDITS-- +Daniel Convissor <danielc@php.net> +# TestFest 2009 NYPHP +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +$doc = new DOMDocument; + +$doc->load(dirname(__FILE__)."/book.xml"); + +$result = $doc->schemaValidate(dirname(__FILE__)."/book-non-conforming-schema.xsd"); +var_dump($result); + +?> +--EXPECTF-- +Warning: DOMDocument::schemaValidate(): Element 'books': No matching global declaration available for the validation root. in %s.php on line %d +bool(false) diff --git a/ext/dom/tests/DOMDocument_schemaValidate_error3.phpt b/ext/dom/tests/DOMDocument_schemaValidate_error3.phpt new file mode 100755 index 0000000000..275204f920 --- /dev/null +++ b/ext/dom/tests/DOMDocument_schemaValidate_error3.phpt @@ -0,0 +1,21 @@ +--TEST-- +DomDocument::schemaValidate() - empty string for schema file name +--CREDITS-- +Daniel Convissor <danielc@php.net> +# TestFest 2009 NYPHP +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +$doc = new DOMDocument; + +$doc->load(dirname(__FILE__)."/book.xml"); + +$result = $doc->schemaValidate(''); +var_dump($result); + +?> +--EXPECTF-- +Warning: DOMDocument::schemaValidate(): Invalid Schema source in %s.php on line %d +bool(false) diff --git a/ext/dom/tests/DOMDocument_schemaValidate_error4.phpt b/ext/dom/tests/DOMDocument_schemaValidate_error4.phpt new file mode 100755 index 0000000000..d4817deca0 --- /dev/null +++ b/ext/dom/tests/DOMDocument_schemaValidate_error4.phpt @@ -0,0 +1,21 @@ +--TEST-- +DomDocument::schemaValidate() - pass no parameters +--CREDITS-- +Daniel Convissor <danielc@php.net> +# TestFest 2009 NYPHP +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +$doc = new DOMDocument; + +$doc->load(dirname(__FILE__)."/book.xml"); + +$result = $doc->schemaValidate(); +var_dump($result); + +?> +--EXPECTF-- +Warning: DOMDocument::schemaValidate() expects exactly 1 parameter, 0 given in %s.php on line %d +NULL diff --git a/ext/dom/tests/DOMDocument_schemaValidate_error5.phpt b/ext/dom/tests/DOMDocument_schemaValidate_error5.phpt new file mode 100755 index 0000000000..d3f0658c1f --- /dev/null +++ b/ext/dom/tests/DOMDocument_schemaValidate_error5.phpt @@ -0,0 +1,25 @@ +--TEST-- +DomDocument::schemaValidate() - non-existant schema file +--CREDITS-- +Daniel Convissor <danielc@php.net> +# TestFest 2009 NYPHP +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +$doc = new DOMDocument; + +$doc->load(dirname(__FILE__)."/book.xml"); + +$result = $doc->schemaValidate(dirname(__FILE__)."/non-existant-file"); +var_dump($result); + +?> +--EXPECTF-- +Warning: DOMDocument::schemaValidate(): I/O warning : failed to load external entity "%snon-existant-file" in %s.php on line %d + +Warning: DOMDocument::schemaValidate(): Failed to locate the main schema resource at '%s/non-existant-file'. in %s.php on line %d + +Warning: DOMDocument::schemaValidate(): Invalid Schema in %s.php on line %d +bool(false) diff --git a/ext/dom/tests/DOMDocument_strictErrorChecking_basic.phpt b/ext/dom/tests/DOMDocument_strictErrorChecking_basic.phpt new file mode 100644 index 0000000000..9ad55a4ad6 --- /dev/null +++ b/ext/dom/tests/DOMDocument_strictErrorChecking_basic.phpt @@ -0,0 +1,22 @@ +--TEST-- +DomDocument::$strictErrorChecking - basic test +--CREDITS-- +Vincent Tsao <notes4vincent@gmail.com> +# TestFest 2009 NYPHP +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +$doc = new DOMDocument; +$doc->load(dirname(__FILE__)."/book.xml"); + +var_dump($doc->strictErrorChecking); + +$doc->strictErrorChecking = false; +var_dump($doc->strictErrorChecking); + +?> +--EXPECT-- +bool(true) +bool(false) diff --git a/ext/dom/tests/DOMDocument_validate_on_parse_basic.phpt b/ext/dom/tests/DOMDocument_validate_on_parse_basic.phpt new file mode 100644 index 0000000000..a95b0a3043 --- /dev/null +++ b/ext/dom/tests/DOMDocument_validate_on_parse_basic.phpt @@ -0,0 +1,38 @@ +--TEST-- +DOMDocument::$validateOnParse - read/write tests (dom_document_validate_on_parse_read/dom_document_validate_on_parse_write) +--CREDITS-- +Hans Zaunere +# TestFest 2009 NYPHP +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +require_once('dom_test.inc'); + +$dom = new DOMDocument; +$dom->loadXML($xmlstr); + +if( !$dom ) +{ + echo "Error while parsing the document\n"; + exit; +} + +echo "Checking documented default value: "; +var_dump($dom->validateOnParse); + +$dom->validateOnParse = TRUE; +echo "Setting validateOnParse to TRUE: "; +var_dump($dom->validateOnParse); + +$dom->validateOnParse = FALSE; +echo "Setting validateOnParse to FALSE: "; +var_dump($dom->validateOnParse); + +?> +--EXPECT-- +Checking documented default value: bool(false) +Setting validateOnParse to TRUE: bool(true) +Setting validateOnParse to FALSE: bool(false) + diff --git a/ext/dom/tests/DOMDocument_validate_on_parse_variation.phpt b/ext/dom/tests/DOMDocument_validate_on_parse_variation.phpt new file mode 100644 index 0000000000..6aa390ca90 --- /dev/null +++ b/ext/dom/tests/DOMDocument_validate_on_parse_variation.phpt @@ -0,0 +1,49 @@ +--TEST-- +DOMDocument::$validateOnParse - effectual determination (dom_document_validate_on_parse_read/dom_document_validate_on_parse_write) +--CREDITS-- +Hans Zaunere +# TestFest 2009 NYPHP +--SKIPIF-- +<?php +require_once('skipif.inc'); + +// need external DTD/XML docs +if( @file_get_contents('http://www.php.net/') === FALSE ) + exit('skip network not available'); +?> +--FILE-- +<?php + +require_once('dom_test.inc'); + +$XMLStringGood = file_get_contents('http://www.php.net/'); + +$dom = new DOMDocument; +$dom->resolveExternals = TRUE; + +$dom->validateOnParse = FALSE; +echo "validateOnParse set to FALSE: \n"; +$dom->loadXML($XMLStringGood); +echo "No Error Report Above\n"; + +$BogusElement = $dom->createElement('NYPHP','DOMinatrix'); +$Body = $dom->getElementsByTagName('body')->item(0); +$Body->appendChild($BogusElement); +$XMLStringBad = $dom->saveXML(); + +echo "validateOnParse set to TRUE: \n"; +$dom->validateOnParse = TRUE; +$dom->loadXML($XMLStringBad); +echo "Error Report Above\n"; + +?> +--EXPECTF-- +validateOnParse set to FALSE: +No Error Report Above +validateOnParse set to TRUE: + +Warning: DOMDocument::loadXML(): No declaration for element NYPHP in Entity, line: %d in %s on line %d + +Warning: DOMDocument::loadXML(): Element body content does not follow the DTD, expecting (p | h1 | h2 | h3 | h4 | h5 | h6 | div | ul | ol | dl | pre | hr | blockquote | address | fieldset | table | form | noscript | ins | del | script)*, got (div div div div div NYPHP) in Entity, line: %d in %s on line %d +Error Report Above + diff --git a/ext/dom/tests/book-non-conforming-schema.xsd b/ext/dom/tests/book-non-conforming-schema.xsd new file mode 100755 index 0000000000..d1ecbef01a --- /dev/null +++ b/ext/dom/tests/book-non-conforming-schema.xsd @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> + <xs:element name="make_it_fail"> + <xs:complexType> + <xs:sequence> + <xs:element name="book" minOccurs="1" maxOccurs="unbounded"> + <xs:complexType> + <xs:sequence> + <xs:element name="title" type="xs:string"/> + <xs:element name="author" type="xs:string"/> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> +</xs:schema> diff --git a/ext/dom/tests/book-not-a-schema.xsd b/ext/dom/tests/book-not-a-schema.xsd new file mode 100755 index 0000000000..d89e3bbac6 --- /dev/null +++ b/ext/dom/tests/book-not-a-schema.xsd @@ -0,0 +1 @@ +Let's see what happens upon parsing a file that doesn't contain a schema. diff --git a/ext/dom/tests/book.xsd b/ext/dom/tests/book.xsd new file mode 100755 index 0000000000..45986fc4b3 --- /dev/null +++ b/ext/dom/tests/book.xsd @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> + <xs:element name="books"> + <xs:complexType> + <xs:sequence> + <xs:element name="book" minOccurs="1" maxOccurs="unbounded"> + <xs:complexType> + <xs:sequence> + <xs:element name="title" type="xs:string"/> + <xs:element name="author" type="xs:string"/> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> +</xs:schema> diff --git a/ext/dom/tests/domdocument_createcomment_error_001.phpt b/ext/dom/tests/domdocument_createcomment_error_001.phpt new file mode 100644 index 0000000000..5df4e20473 --- /dev/null +++ b/ext/dom/tests/domdocument_createcomment_error_001.phpt @@ -0,0 +1,11 @@ +--TEST-- +DomDocument::CreateComment() - Incorrect Parameters +--CREDITS-- +Clint Priest @ PhpTek09 +--FILE-- +<?php + $x = new DomDocument(); + $x->createComment(); +?> +--EXPECTF-- +Warning: DOMDocument::createComment() expects exactly 1 parameter, 0 given in %s
\ No newline at end of file diff --git a/ext/dom/tests/domdocument_createentityreference_001.phpt b/ext/dom/tests/domdocument_createentityreference_001.phpt new file mode 100644 index 0000000000..15f7df1881 --- /dev/null +++ b/ext/dom/tests/domdocument_createentityreference_001.phpt @@ -0,0 +1,13 @@ +--TEST-- +DomDocument::CreateEntityReference() - Creates an entity reference with the appropriate name +--CREDITS-- +Clint Priest @ PhpTek09 +--FILE-- +<?php + $objDoc = new DomDocument(); + + $objRef = $objDoc->createEntityReference('Test'); + echo $objRef->nodeName; +?> +--EXPECT-- +Test
\ No newline at end of file diff --git a/ext/dom/tests/domdocument_createentityreference_002.phpt b/ext/dom/tests/domdocument_createentityreference_002.phpt new file mode 100644 index 0000000000..21d79aa4bb --- /dev/null +++ b/ext/dom/tests/domdocument_createentityreference_002.phpt @@ -0,0 +1,12 @@ +--TEST-- +DomDocument::CreateEntityReference() - Empty Arguments +--CREDITS-- +Clint Priest @ PhpTek09 +--FILE-- +<?php + $objDoc = new DomDocument(); + + $objRef = $objDoc->createEntityReference(); +?> +--EXPECTF-- +Warning: DOMDocument::createEntityReference() expects exactly 1 parameter, 0 given in %s
\ No newline at end of file diff --git a/ext/gd/tests/imagegammacorrect_variation1.phpt b/ext/gd/tests/imagegammacorrect_variation1.phpt new file mode 100644 index 0000000000..cda96c6287 --- /dev/null +++ b/ext/gd/tests/imagegammacorrect_variation1.phpt @@ -0,0 +1,32 @@ +--TEST-- +Testing imagegammacorrect() of GD library with non TrueColor image +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreate(150, 150); + +$grey = imagecolorallocate($image,6,6,6); +$gray = imagecolorallocate($image,15,15,15); + +$half = imagefilledarc ( $image, 75, 75, 70, 70, 0, 180, $grey, IMG_ARC_PIE ); +$half2 = imagefilledarc ( $image, 75, 75, 70, 70, 0, -180, $gray, IMG_ARC_PIE ); + +$gamma = imagegammacorrect($image, 1, 5); + +if ($gamma){ + ob_start(); + imagepng($image, null, 9); + $img = ob_get_contents(); + ob_end_clean(); +} + +echo md5(base64_encode($img)); +?> +--EXPECT-- +7716c0905ae08bd84b4d6cba8969a42e diff --git a/ext/gd/tests/imagerectangle_basic.phpt b/ext/gd/tests/imagerectangle_basic.phpt new file mode 100755 index 0000000000..0574ad35cb --- /dev/null +++ b/ext/gd/tests/imagerectangle_basic.phpt @@ -0,0 +1,27 @@ +--TEST--
+Testing imagerectangle() of GD library
+--CREDITS--
+Ivan Rosolen <contato [at] ivanrosolen [dot] com>
+#testfest PHPSP on 2009-06-30
+--SKIPIF--
+<?php
+if ( ! extension_loaded('gd') ) die( 'GD not present; skipping test' );
+?>
+--FILE--
+<?php
+// Create a image
+$image = imagecreatetruecolor( 100, 100 );
+
+// Draw a rectangle
+imagerectangle( $image, 0, 0, 50, 50, imagecolorallocate($image, 255, 255, 255) );
+
+ob_start();
+imagepng( $image, null, 9 );
+$img = ob_get_contents();
+ob_end_clean();
+
+echo md5(base64_encode($img));
+
+?>
+--EXPECT--
+282aaecfdd50091821d63093d9bb1bb9
\ No newline at end of file diff --git a/ext/gd/tests/imagerectangle_error2.phpt b/ext/gd/tests/imagerectangle_error2.phpt new file mode 100755 index 0000000000..c6e740214a --- /dev/null +++ b/ext/gd/tests/imagerectangle_error2.phpt @@ -0,0 +1,19 @@ +--TEST--
+Testing wrong param passing imagerectangle() of GD library
+--CREDITS--
+Ivan Rosolen <contato [at] ivanrosolen [dot] com>
+#testfest PHPSP on 2009-06-30
+--SKIPIF--
+<?php
+if ( ! extension_loaded('gd') ) die( 'GD not present; skipping test' );
+?>
+--FILE--
+<?php
+// Create a resource
+$image = tmpfile();
+
+// Draw a rectangle
+imagerectangle( $image, 0, 0, 50, 50, 2 );
+?>
+--EXPECTF--
+Warning: imagerectangle(): supplied resource is not a valid Image resource in %s on line %d
\ No newline at end of file diff --git a/ext/iconv/tests/iconv_get_encoding_basic.phpt b/ext/iconv/tests/iconv_get_encoding_basic.phpt new file mode 100644 index 0000000000..83efd1586d --- /dev/null +++ b/ext/iconv/tests/iconv_get_encoding_basic.phpt @@ -0,0 +1,76 @@ +--TEST-- +iconv_get_encoding() parameter tests +--CREDITS-- +Oystein Rose <orose@redpill-linpro.com> +#PHPTestFest2009 Norway 2009-06-09 \o/ +--SKIPIF-- +<?php if (!extension_loaded("iconv")) { echo 'skip extension not available'; } ?> +--FILE-- +<?php + +iconv_set_encoding("internal_encoding", "UTF-8"); +iconv_set_encoding("output_encoding", "UTF-8"); +iconv_set_encoding("input_encoding", "UTF-8"); + +var_dump( iconv_get_encoding('internal_encoding') ); +var_dump( iconv_get_encoding('output_encoding') ); +var_dump( iconv_get_encoding('input_encoding') ); +var_dump( iconv_get_encoding('all') ); +var_dump( iconv_get_encoding('foo') ); +var_dump( iconv_get_encoding() ); + + + +iconv_set_encoding("internal_encoding", "ISO-8859-1"); +iconv_set_encoding("output_encoding", "ISO-8859-1"); +iconv_set_encoding("input_encoding", "ISO-8859-1"); + +var_dump( iconv_get_encoding('internal_encoding') ); +var_dump( iconv_get_encoding('output_encoding') ); +var_dump( iconv_get_encoding('input_encoding') ); +var_dump( iconv_get_encoding('all') ); +var_dump( iconv_get_encoding('foo') ); +var_dump( iconv_get_encoding() ); + +?> +--EXPECT-- +string(5) "UTF-8" +string(5) "UTF-8" +string(5) "UTF-8" +array(3) { + ["input_encoding"]=> + string(5) "UTF-8" + ["output_encoding"]=> + string(5) "UTF-8" + ["internal_encoding"]=> + string(5) "UTF-8" +} +bool(false) +array(3) { + ["input_encoding"]=> + string(5) "UTF-8" + ["output_encoding"]=> + string(5) "UTF-8" + ["internal_encoding"]=> + string(5) "UTF-8" +} +string(10) "ISO-8859-1" +string(10) "ISO-8859-1" +string(10) "ISO-8859-1" +array(3) { + ["input_encoding"]=> + string(10) "ISO-8859-1" + ["output_encoding"]=> + string(10) "ISO-8859-1" + ["internal_encoding"]=> + string(10) "ISO-8859-1" +} +bool(false) +array(3) { + ["input_encoding"]=> + string(10) "ISO-8859-1" + ["output_encoding"]=> + string(10) "ISO-8859-1" + ["internal_encoding"]=> + string(10) "ISO-8859-1" +} diff --git a/ext/pcntl/tests/pcntl_fork_basic.phpt b/ext/pcntl/tests/pcntl_fork_basic.phpt new file mode 100644 index 0000000000..82759ba327 --- /dev/null +++ b/ext/pcntl/tests/pcntl_fork_basic.phpt @@ -0,0 +1,27 @@ +--TEST-- +Test function pcntl_fork() by calling it with its expected arguments +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded('pcntl')) die('skip pcntl extension not available'); + elseif (!extension_loaded('posix')) die('skip posix extension not available'); +?> +--FILE-- +<?php +echo "*** Test by calling method or function with its expected arguments, first print the child PID and the the father ***\n"; + +$pid = pcntl_fork(); +if ($pid > 0) { + pcntl_wait($status); + var_dump($pid); +} else { + var_dump($pid); +} +?> +--EXPECTF-- +*** Test by calling method or function with its expected arguments, first print the child PID and the the father *** +int(0) +int(%d) diff --git a/ext/pcntl/tests/pcntl_fork_variation.phpt b/ext/pcntl/tests/pcntl_fork_variation.phpt new file mode 100644 index 0000000000..4eea07181c --- /dev/null +++ b/ext/pcntl/tests/pcntl_fork_variation.phpt @@ -0,0 +1,48 @@ +--TEST-- +Test function pcntl_fork() by testing the process isolation in the forking hierarchy father -> son -> grandson where father can not knows his grandson +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded('pcntl')) die('skip pcntl extension not available'); + elseif (!extension_loaded('posix')) die('skip posix extension not available'); +?> +--FILE-- +<?php +echo "*** Testing the process isolations between a process and its forks ***\n"; + +$pid = pcntl_fork(); + +if ($pid > 0) { + pcntl_wait($status); + echo "father is $pid\n"; + + if (!isset($pid2)) + { + echo "father ($pid) doesn't know its grandsons\n"; + } +} +else +{ + echo "son ($pid)\n"; + $pid2 = pcntl_fork(); + if ($pid2 > 0) + { + pcntl_wait($status2); + echo "son is father of $pid2\n"; + } + else + { + echo "grandson ($pid2)\n"; + } +} +?> +--EXPECTF-- +*** Testing the process isolations between a process and its forks *** +son (0) +grandson (0) +son is father of %d +father is %d +father (%d) doesn't know its grandsons diff --git a/ext/posix/tests/posix_ctermid_basic.phpt b/ext/posix/tests/posix_ctermid_basic.phpt new file mode 100644 index 0000000000..d1d46943ba --- /dev/null +++ b/ext/posix/tests/posix_ctermid_basic.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test function posix_ctermid() by calling it with its expected arguments +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--FILE-- +<?php + +var_dump( posix_ctermid() ); + +?> +--EXPECTF-- +string(%d) %s diff --git a/ext/posix/tests/posix_errno_basic.phpt b/ext/posix/tests/posix_errno_basic.phpt new file mode 100644 index 0000000000..cd94a97515 --- /dev/null +++ b/ext/posix/tests/posix_errno_basic.phpt @@ -0,0 +1,22 @@ +--TEST-- +Test function posix_errno() by calling it with its expected arguments +--CREDITS-- +Morten Amundsen mor10am@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--FILE-- +<?php + +echo "*** Test by calling method or function with its expected arguments ***\n"; + +// test without any error +var_dump(posix_errno()); + +?> +--EXPECTF-- +*** Test by calling method or function with its expected arguments *** +int(0) diff --git a/ext/posix/tests/posix_errno_variation1.phpt b/ext/posix/tests/posix_errno_variation1.phpt new file mode 100644 index 0000000000..aa9889f7fe --- /dev/null +++ b/ext/posix/tests/posix_errno_variation1.phpt @@ -0,0 +1,22 @@ +--TEST-- +Test function posix_errno() by calling it with with permission error +--CREDITS-- +Morten Amundsen mor10am@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--FILE-- +<?php + +echo "*** Test by calling function with permission error ***\n"; + +posix_setuid(0); +var_dump(posix_errno()); + +?> +--EXPECTF-- +*** Test by calling function with permission error *** +int(1) diff --git a/ext/posix/tests/posix_errno_variation2.phpt b/ext/posix/tests/posix_errno_variation2.phpt new file mode 100644 index 0000000000..f463d78759 --- /dev/null +++ b/ext/posix/tests/posix_errno_variation2.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test function posix_errno() by calling it with its expected arguments +--CREDITS-- +Morten Amundsen mor10am@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--FILE-- +<?php + +echo "*** Test by calling function with pid error ***\n"; + +$pid = 10000; + +do { + $pid += 1; + $result = shell_exec("ps -p " . $pid); +} while (strstr($pid, $result)); + +posix_kill($pid, SIGKILL); +var_dump(posix_errno()); + +?> +--EXPECTF-- +*** Test by calling function with pid error *** +int(3) diff --git a/ext/posix/tests/posix_geteuid_basic.phpt b/ext/posix/tests/posix_geteuid_basic.phpt new file mode 100644 index 0000000000..76e9028043 --- /dev/null +++ b/ext/posix/tests/posix_geteuid_basic.phpt @@ -0,0 +1,16 @@ +--TEST-- +Test function posix_geteuid() by calling it with its expected arguments +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--FILE-- +<?php +var_dump(posix_geteuid()); +?> +--EXPECTF-- +int(%d) diff --git a/ext/posix/tests/posix_seteuid_basic.phpt b/ext/posix/tests/posix_seteuid_basic.phpt new file mode 100644 index 0000000000..204ebe8d07 --- /dev/null +++ b/ext/posix/tests/posix_seteuid_basic.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test function posix_seteuid() by calling it with its expected arguments +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--FILE-- +<?php + +$myuid = posix_geteuid(); +$uid = var_dump(posix_seteuid( $myuid ) ); + +?> +--EXPECTF-- +bool(true) diff --git a/ext/posix/tests/posix_seteuid_error.phpt b/ext/posix/tests/posix_seteuid_error.phpt new file mode 100644 index 0000000000..b10e41075e --- /dev/null +++ b/ext/posix/tests/posix_seteuid_error.phpt @@ -0,0 +1,32 @@ +--TEST-- +Test function posix_seteuid() by calling it more than or less than its expected arguments +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test by calling method or function with incorrect numbers of arguments ***\n"; + +$uid = '123'; +$extra_arg = '12312'; + +var_dump(posix_seteuid( $uid, $extra_arg ) ); +var_dump(posix_seteuid( ) ); + + +?> +--EXPECTF-- +*** Test by calling method or function with incorrect numbers of arguments *** + +Warning: posix_seteuid() expects exactly 1 parameter, 2 given in %s on line 9 +bool(false) + +Warning: posix_seteuid() expects exactly 1 parameter, 0 given in %s on line 10 +bool(false) diff --git a/ext/posix/tests/posix_seteuid_error2.phpt b/ext/posix/tests/posix_seteuid_error2.phpt new file mode 100644 index 0000000000..808f2d32d1 --- /dev/null +++ b/ext/posix/tests/posix_seteuid_error2.phpt @@ -0,0 +1,55 @@ +--TEST-- +Test function posix_seteuid() by substituting argument 1 with object values. +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with object values ***\n"; + + + +function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) { + if (error_reporting() != 0) { + // report non-silenced errors + echo "Error: $err_no - $err_msg, $filename($linenum)\n"; + } +} +set_error_handler('test_error_handler'); + + + +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +$variation_array = array( + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + ); + + +foreach ( $variation_array as $var ) { + var_dump(posix_seteuid( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with object values *** +Error: 2 - posix_seteuid() expects parameter 1 to be long, object given, %s +bool(false) +Error: 2 - posix_seteuid() expects parameter 1 to be long, object given, %s +bool(false) diff --git a/ext/posix/tests/posix_seteuid_variation1.phpt b/ext/posix/tests/posix_seteuid_variation1.phpt new file mode 100644 index 0000000000..841bfe0db8 --- /dev/null +++ b/ext/posix/tests/posix_seteuid_variation1.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test function posix_seteuid() by substituting argument 1 with array values. +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + +$index_array = array(1, 2, 3); +$assoc_array = array(1 => 'one', 2 => 'two'); + +$variation_array = array( + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + ); + + +foreach ( $variation_array as $var ) { + var_dump(posix_seteuid( $var ) ); +} + +?> +--EXPECTF-- +Warning: posix_seteuid() expects parameter 1 to be long, array given in %s on line 15 +bool(false) + +Warning: posix_seteuid() expects parameter 1 to be long, array given in %s on line 15 +bool(false) + +Warning: posix_seteuid() expects parameter 1 to be long, array given in %s on line 15 +bool(false) + +Warning: posix_seteuid() expects parameter 1 to be long, array given in %s on line 15 +bool(false) diff --git a/ext/posix/tests/posix_seteuid_variation2.phpt b/ext/posix/tests/posix_seteuid_variation2.phpt new file mode 100644 index 0000000000..2ab7302ce7 --- /dev/null +++ b/ext/posix/tests/posix_seteuid_variation2.phpt @@ -0,0 +1,36 @@ +--TEST-- +Test function posix_seteuid() by substituting argument 1 with boolean values. +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with boolean values ***\n"; + + + +$variation_array = array( + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + ); + + +foreach ( $variation_array as $var ) { + var_dump(posix_seteuid( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with boolean values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/posix/tests/posix_seteuid_variation4.phpt b/ext/posix/tests/posix_seteuid_variation4.phpt new file mode 100644 index 0000000000..65291417e7 --- /dev/null +++ b/ext/posix/tests/posix_seteuid_variation4.phpt @@ -0,0 +1,40 @@ +--TEST-- +Test function posix_seteuid() by substituting argument 1 with float values. +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with float values ***\n"; + +$myUid = posix_getuid(); + +$myUid = $myUid - 1.1; + +$variation_array = array( + 'float '.$myUid => $myUid, + 'float -'.$myUid => -$myUid, + 'float 12.3456789000e10' => 12.3456789000e10, + 'float -12.3456789000e10' => -12.3456789000e10, + 'float .5' => .5, + ); + + +foreach ( $variation_array as $var ) { + var_dump(posix_seteuid( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with float values *** +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/posix/tests/posix_seteuid_variation5.phpt b/ext/posix/tests/posix_seteuid_variation5.phpt new file mode 100644 index 0000000000..91d3a72e96 --- /dev/null +++ b/ext/posix/tests/posix_seteuid_variation5.phpt @@ -0,0 +1,34 @@ +--TEST-- +Test function posix_seteuid() by substituting argument 1 with int values. +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with int values ***\n"; + + + +$variation_array = array ( + 'int 0' => 0, + 'int 1' => 1, + 'int -12345' => -12345, + ); + + +foreach ( $variation_array as $var ) { + var_dump(posix_seteuid( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with int values *** +bool(false) +bool(false) +bool(false) diff --git a/ext/posix/tests/posix_setgid_basic.phpt b/ext/posix/tests/posix_setgid_basic.phpt new file mode 100644 index 0000000000..5762d2b13c --- /dev/null +++ b/ext/posix/tests/posix_setgid_basic.phpt @@ -0,0 +1,20 @@ +--TEST-- +Test function posix_setgid() by calling it with its expected arguments +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test by calling method or function with its expected arguments ***\n"; + +$gid = posix_getgid(); +var_dump(posix_setgid( $gid ) ); + + +?> +--EXPECTF-- +*** Test by calling method or function with its expected arguments *** +bool(true) diff --git a/ext/posix/tests/posix_setgid_error.phpt b/ext/posix/tests/posix_setgid_error.phpt new file mode 100644 index 0000000000..121b0403c8 --- /dev/null +++ b/ext/posix/tests/posix_setgid_error.phpt @@ -0,0 +1,27 @@ +--TEST-- +Test function posix_setgid() by calling it more than or less than its expected arguments. +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test by calling method or function with incorrect numbers of arguments ***\n"; + +$gid = posix_getgid(); +$extra_arg = '123'; + +var_dump(posix_setgid( $gid, $extra_arg ) ); +var_dump(posix_setgid( ) ); + +?> +--EXPECTF-- +*** Test by calling method or function with incorrect numbers of arguments *** + +Warning: posix_setgid() expects exactly 1 parameter, 2 given in %s on line %d +bool(false) + +Warning: posix_setgid() expects exactly 1 parameter, 0 given in %s on line %d +bool(false) diff --git a/ext/posix/tests/posix_setgid_variation1.phpt b/ext/posix/tests/posix_setgid_variation1.phpt new file mode 100644 index 0000000000..9125327aa9 --- /dev/null +++ b/ext/posix/tests/posix_setgid_variation1.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test function posix_setgid() by substituting argument 1 with array values. +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with array values ***\n"; + +$index_array = array(1, 2, 3); +$assoc_array = array(1 => 'one', 2 => 'two'); + +$variation_array = array( + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + ); + + +foreach ( $variation_array as $var ) { + var_dump(posix_setgid( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with array values *** + +Warning: posix_setgid() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Warning: posix_setgid() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Warning: posix_setgid() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Warning: posix_setgid() expects parameter 1 to be long, array given in %s on line %d +bool(false) diff --git a/ext/posix/tests/posix_setgid_variation2.phpt b/ext/posix/tests/posix_setgid_variation2.phpt new file mode 100644 index 0000000000..77d614f05c --- /dev/null +++ b/ext/posix/tests/posix_setgid_variation2.phpt @@ -0,0 +1,32 @@ +--TEST-- +Test function posix_setgid() by substituting argument 1 with boolean values. +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with boolean values ***\n"; + + + +$variation_array = array( + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + ); + + +foreach ( $variation_array as $var ) { + var_dump(posix_setgid( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with boolean values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/posix/tests/posix_setgid_variation4.phpt b/ext/posix/tests/posix_setgid_variation4.phpt new file mode 100644 index 0000000000..62acf23f39 --- /dev/null +++ b/ext/posix/tests/posix_setgid_variation4.phpt @@ -0,0 +1,34 @@ +--TEST-- +Test function posix_setgid() by substituting argument 1 with float values. +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with float values ***\n"; + + + +$variation_array = array( + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float 12.3456789000e10' => 12.3456789000e10, + 'float -12.3456789000e10' => -12.3456789000e10, + 'float .5' => .5, + ); + + +foreach ( $variation_array as $var ) { + var_dump(posix_setgid( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with float values *** +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/posix/tests/posix_setgid_variation5.phpt b/ext/posix/tests/posix_setgid_variation5.phpt new file mode 100644 index 0000000000..f7e60a4a84 --- /dev/null +++ b/ext/posix/tests/posix_setgid_variation5.phpt @@ -0,0 +1,30 @@ +--TEST-- +Test function posix_setgid() by substituting argument 1 with int values. +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with int values ***\n"; + + + +$variation_array = array ( + 'long 0' => 0, + 'long 1' => 1, + 'int -12345' => -2345, + ); + + +foreach ( $variation_array as $var ) { + var_dump(posix_setgid( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with int values *** +bool(false) +bool(false) +bool(false) diff --git a/ext/posix/tests/posix_setgid_variation6.phpt b/ext/posix/tests/posix_setgid_variation6.phpt new file mode 100644 index 0000000000..e1bdfb131a --- /dev/null +++ b/ext/posix/tests/posix_setgid_variation6.phpt @@ -0,0 +1,51 @@ +--TEST-- +Test function posix_setgid() by substituting argument 1 with object values. +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with object values ***\n"; + + + +function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) { + if (error_reporting() != 0) { + // report non-silenced errors + echo "Error: $err_no - $err_msg, $filename($linenum)\n"; + } +} +set_error_handler('test_error_handler'); + + + +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +$variation_array = array( + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + ); + + +foreach ( $variation_array as $var ) { + var_dump(posix_setgid( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with object values *** +Error: 2 - posix_setgid() expects parameter 1 to be long, object given, %s +bool(false) +Error: 2 - posix_setgid() expects parameter 1 to be long, object given, %s +bool(false) diff --git a/ext/posix/tests/posix_setuid_basic.phpt b/ext/posix/tests/posix_setuid_basic.phpt new file mode 100644 index 0000000000..986b0be62c --- /dev/null +++ b/ext/posix/tests/posix_setuid_basic.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test function posix_setuid() by calling it with its expected arguments +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--FILE-- +<?php + +$myuid = posix_getuid(); +$uid = var_dump(posix_setuid( $myuid ) ); + +?> +--EXPECTF-- +bool(true) diff --git a/ext/posix/tests/posix_setuid_error.phpt b/ext/posix/tests/posix_setuid_error.phpt new file mode 100644 index 0000000000..8aa51586a4 --- /dev/null +++ b/ext/posix/tests/posix_setuid_error.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test function posix_setuid() by calling it more than or less than its expected arguments +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test by calling method or function with incorrect numbers of arguments ***\n"; + +$uid = '123'; + + +$extra_arg = '12312'; + +var_dump(posix_setuid( $uid, $extra_arg ) ); + +var_dump(posix_setuid( ) ); + + +?> +--EXPECTF-- +*** Test by calling method or function with incorrect numbers of arguments *** + +Warning: posix_setuid() expects exactly 1 parameter, 2 given in %s on line 11 +bool(false) + +Warning: posix_setuid() expects exactly 1 parameter, 0 given in %s on line 13 +bool(false) diff --git a/ext/posix/tests/posix_setuid_error2.phpt b/ext/posix/tests/posix_setuid_error2.phpt new file mode 100644 index 0000000000..6ec0aa9af4 --- /dev/null +++ b/ext/posix/tests/posix_setuid_error2.phpt @@ -0,0 +1,55 @@ +--TEST-- +Test function posix_setuid() by substituting argument 1 with object values. +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with object values ***\n"; + + + +function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) { + if (error_reporting() != 0) { + // report non-silenced errors + echo "Error: $err_no - $err_msg, $filename($linenum)\n"; + } +} +set_error_handler('test_error_handler'); + + + +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +$variation_array = array( + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + ); + + +foreach ( $variation_array as $var ) { + var_dump(posix_setuid( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with object values *** +Error: 2 - posix_setuid() expects parameter 1 to be long, object given, %s +bool(false) +Error: 2 - posix_setuid() expects parameter 1 to be long, object given, %s +bool(false) diff --git a/ext/posix/tests/posix_setuid_variation1.phpt b/ext/posix/tests/posix_setuid_variation1.phpt new file mode 100644 index 0000000000..bf6d4376cd --- /dev/null +++ b/ext/posix/tests/posix_setuid_variation1.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test function posix_setuid() by substituting argument 1 with array values. +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + +$index_array = array(1, 2, 3); +$assoc_array = array(1 => 'one', 2 => 'two'); + +$variation_array = array( + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + ); + + +foreach ( $variation_array as $var ) { + var_dump(posix_setuid( $var ) ); +} + +?> +--EXPECTF-- +Warning: posix_setuid() expects parameter 1 to be long, array given in %s on line 15 +bool(false) + +Warning: posix_setuid() expects parameter 1 to be long, array given in %s on line 15 +bool(false) + +Warning: posix_setuid() expects parameter 1 to be long, array given in %s on line 15 +bool(false) + +Warning: posix_setuid() expects parameter 1 to be long, array given in %s on line 15 +bool(false) diff --git a/ext/posix/tests/posix_setuid_variation2.phpt b/ext/posix/tests/posix_setuid_variation2.phpt new file mode 100644 index 0000000000..c8ef92827f --- /dev/null +++ b/ext/posix/tests/posix_setuid_variation2.phpt @@ -0,0 +1,36 @@ +--TEST-- +Test function posix_setuid() by substituting argument 1 with boolean values. +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with boolean values ***\n"; + + + +$variation_array = array( + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + ); + + +foreach ( $variation_array as $var ) { + var_dump(posix_setuid( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with boolean values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/posix/tests/posix_setuid_variation4.phpt b/ext/posix/tests/posix_setuid_variation4.phpt new file mode 100644 index 0000000000..1675964920 --- /dev/null +++ b/ext/posix/tests/posix_setuid_variation4.phpt @@ -0,0 +1,40 @@ +--TEST-- +Test function posix_setuid() by substituting argument 1 with float values. +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with float values ***\n"; + +$myUid = posix_getuid(); + +$myUid = $myUid - 1.1; + +$variation_array = array( + 'float '.$myUid => $myUid, + 'float -'.$myUid => -$myUid, + 'float 12.3456789000e10' => 12.3456789000e10, + 'float -12.3456789000e10' => -12.3456789000e10, + 'float .5' => .5, + ); + + +foreach ( $variation_array as $var ) { + var_dump(posix_setuid( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with float values *** +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/posix/tests/posix_setuid_variation5.phpt b/ext/posix/tests/posix_setuid_variation5.phpt new file mode 100644 index 0000000000..e1b7c05e0e --- /dev/null +++ b/ext/posix/tests/posix_setuid_variation5.phpt @@ -0,0 +1,34 @@ +--TEST-- +Test function posix_setuid() by substituting argument 1 with int values. +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with int values ***\n"; + + + +$variation_array = array ( + 'int 0' => 0, + 'int 1' => 1, + 'int -12345' => -12345, + ); + + +foreach ( $variation_array as $var ) { + var_dump(posix_setuid( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with int values *** +bool(false) +bool(false) +bool(false) diff --git a/ext/posix/tests/posix_ttyname_error.phpt b/ext/posix/tests/posix_ttyname_error.phpt new file mode 100644 index 0000000000..e3ec695e54 --- /dev/null +++ b/ext/posix/tests/posix_ttyname_error.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test function posix_ttyname() by calling it more than or less than its expected arguments +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test by calling method or function with incorrect numbers of arguments ***\n"; + +$fd = 'foo'; +$extra_arg = 'bar'; + +var_dump(posix_ttyname( $fd, $extra_arg ) ); + +var_dump(posix_ttyname( ) ); + + +?> +--EXPECTF-- +*** Test by calling method or function with incorrect numbers of arguments *** + +Warning: posix_ttyname() expects exactly 1 parameter, 2 given in %s on line %d +bool(false) + +Warning: posix_ttyname() expects exactly 1 parameter, 0 given in %s on line %d +bool(false) diff --git a/ext/posix/tests/posix_ttyname_variation1.phpt b/ext/posix/tests/posix_ttyname_variation1.phpt new file mode 100644 index 0000000000..072b9fa672 --- /dev/null +++ b/ext/posix/tests/posix_ttyname_variation1.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test function posix_ttyname() by substituting argument 1 with array values. +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with array values ***\n"; + + + +$index_array = array(1, 2, 3); +$assoc_array = array(1 => 'one', 2 => 'two'); + +$variation_array = array( + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + ); + + +foreach ( $variation_array as $var ) { + var_dump(posix_ttyname( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with array values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/posix/tests/posix_ttyname_variation2.phpt b/ext/posix/tests/posix_ttyname_variation2.phpt new file mode 100644 index 0000000000..f46821b0cc --- /dev/null +++ b/ext/posix/tests/posix_ttyname_variation2.phpt @@ -0,0 +1,32 @@ +--TEST-- +Test function posix_ttyname() by substituting argument 1 with boolean values. +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with boolean values ***\n"; + + + +$variation_array = array( + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + ); + + +foreach ( $variation_array as $var ) { + var_dump(posix_ttyname( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with boolean values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/posix/tests/posix_ttyname_variation3.phpt b/ext/posix/tests/posix_ttyname_variation3.phpt new file mode 100644 index 0000000000..30054265a0 --- /dev/null +++ b/ext/posix/tests/posix_ttyname_variation3.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test function posix_ttyname() by substituting argument 1 with emptyUnsetUndefNull values. +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with emptyUnsetUndefNull values ***\n"; + + + +$unset_var = 10; +unset($unset_var); + +$variation_array = array( + 'unset var' => @$unset_var, + 'undefined var' => @$undefined_var, + 'empty string DQ' => "", + 'empty string SQ' => '', + 'uppercase NULL' => NULL, + 'lowercase null' => null, + ); + + +foreach ( $variation_array as $var ) { + var_dump(posix_ttyname( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with emptyUnsetUndefNull values *** +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/posix/tests/posix_ttyname_variation4.phpt b/ext/posix/tests/posix_ttyname_variation4.phpt new file mode 100644 index 0000000000..3215492793 --- /dev/null +++ b/ext/posix/tests/posix_ttyname_variation4.phpt @@ -0,0 +1,34 @@ +--TEST-- +Test function posix_ttyname() by substituting argument 1 with float values. +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with float values ***\n"; + + + +$variation_array = array( + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float 12.3456789000e10' => 12.3456789000e10, + 'float -12.3456789000e10' => -12.3456789000e10, + 'float .5' => .5, + ); + + +foreach ( $variation_array as $var ) { + var_dump(posix_ttyname( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with float values *** +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/posix/tests/posix_ttyname_variation5.phpt b/ext/posix/tests/posix_ttyname_variation5.phpt new file mode 100644 index 0000000000..661dd606f9 --- /dev/null +++ b/ext/posix/tests/posix_ttyname_variation5.phpt @@ -0,0 +1,28 @@ +--TEST-- +Test function posix_ttyname() by substituting argument 1 with int values. +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with int values ***\n"; + + + +$variation_array = array ( + 'int 12345' => 12345, + 'int -12345' => -2345, + ); + + +foreach ( $variation_array as $var ) { + var_dump(posix_ttyname( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with int values *** +bool(false) +bool(false) diff --git a/ext/posix/tests/posix_ttyname_variation6.phpt b/ext/posix/tests/posix_ttyname_variation6.phpt new file mode 100644 index 0000000000..020aef1156 --- /dev/null +++ b/ext/posix/tests/posix_ttyname_variation6.phpt @@ -0,0 +1,51 @@ +--TEST-- +Test function posix_ttyname() by substituting argument 1 with object values. +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with object values ***\n"; + + + +function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) { + if (error_reporting() != 0) { + // report non-silenced errors + echo "Error: $err_no - $err_msg, $filename($linenum)\n"; + } +} +set_error_handler('test_error_handler'); + + + +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +$variation_array = array( + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + ); + + +foreach ( $variation_array as $var ) { + var_dump(posix_ttyname( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with object values *** +Error: 8 - Object of class classWithToString could not be converted to int, %s(%d) +bool(false) +Error: 8 - Object of class classWithoutToString could not be converted to int, %s(%d) +bool(false) diff --git a/ext/posix/tests/posix_ttyname_variation7.phpt b/ext/posix/tests/posix_ttyname_variation7.phpt new file mode 100644 index 0000000000..b39916c5bc --- /dev/null +++ b/ext/posix/tests/posix_ttyname_variation7.phpt @@ -0,0 +1,36 @@ +--TEST-- +Test function posix_ttyname() by substituting argument 1 with string values. +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with string values ***\n"; + + + +$heredoc = <<<EOT +hello world +EOT; + +$variation_array = array( + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + ); + + +foreach ( $variation_array as $var ) { + var_dump(posix_ttyname( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with string values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/reflection/tests/ReflectionClass_CannotClone_basic.phpt b/ext/reflection/tests/ReflectionClass_CannotClone_basic.phpt new file mode 100644 index 0000000000..6b440cfe06 --- /dev/null +++ b/ext/reflection/tests/ReflectionClass_CannotClone_basic.phpt @@ -0,0 +1,15 @@ +--TEST-- +Reflection class can not be cloned +--CREDITS-- +Stefan Koopmanschap <stefan@phpgg.nl> +TestFest PHP|Tek +--SKIPIF-- +<?php +if (!extension_loaded('reflection)) print 'skip'; +?> +--FILE-- +<?php +$rc = new ReflectionClass("stdClass"); +$rc2 = clone($rc); +--EXPECTF-- +Fatal error: Trying to clone an uncloneable object of class ReflectionClass in %s on line %d diff --git a/ext/reflection/tests/ReflectionFunction_isDisabled_basic.phpt b/ext/reflection/tests/ReflectionFunction_isDisabled_basic.phpt new file mode 100644 index 0000000000..c71b96b8ef --- /dev/null +++ b/ext/reflection/tests/ReflectionFunction_isDisabled_basic.phpt @@ -0,0 +1,17 @@ +--TEST-- +ReflectionFunction::isDisabled +--CREDITS-- +Stefan Koopmanschap <stefan@phpgg.nl> +TestFest PHP|Tek +--SKIPIF-- +<?php +if (!extension_loaded('reflection')) print 'skip'; +?> +--INI-- +disable_functions=is_file +--FILE-- +<?php +$rc = new ReflectionFunction('is_file'); +echo var_dump($rc->isDisabled()); +--EXPECTF-- +bool(true) diff --git a/ext/reflection/tests/bug47254.phpt b/ext/reflection/tests/bug47254.phpt new file mode 100644 index 0000000000..4bcce1bb72 --- /dev/null +++ b/ext/reflection/tests/bug47254.phpt @@ -0,0 +1,42 @@ +--TEST-- +Bug #47254 +--CREDITS-- +Sebastian Schürmann +sebs@php.net +Testfest 2009 Munich +--FILE-- +<?php +class A +{ + protected function a() {} + +} + +class B extends A +{ + public function b() {} +} + +$B = new B(); +$R = new ReflectionObject($B); +$m = $R->getMethods(); +print_r($m); + +?> +--CLEAN-- +--EXPECT-- +Array +( + [0] => ReflectionMethod Object + ( + [name] => b + [class] => B + ) + + [1] => ReflectionMethod Object + ( + [name] => a + [class] => A + ) + +) diff --git a/ext/simplexml/tests/SimpleXMLElement_addAttribute_required_attribute_name.phpt b/ext/simplexml/tests/SimpleXMLElement_addAttribute_required_attribute_name.phpt new file mode 100644 index 0000000000..22ea4488e6 --- /dev/null +++ b/ext/simplexml/tests/SimpleXMLElement_addAttribute_required_attribute_name.phpt @@ -0,0 +1,18 @@ +--TEST-- +SimpleXMLElement: Test to ensure that the required attribute name correctly is giving a warning +--CREDITS-- +Havard Eide <nucleuz@gmail.com> +#PHPTestFest2009 Norway 2009-06-09 \o/ +--SKIPIF-- +<?php if (!extension_loaded("simplexml")) { echo "skip extension not available"; } ?> +--FILE-- +<?php +$a = new SimpleXMLElement("<php>testfest</php>"); +$a->addAttribute( "", "" ); +echo $a->asXML(); +?> +--EXPECTF-- +Warning: SimpleXMLElement::addAttribute(): Attribute name is required in %s on line %d +<?xml version="1.0"?> +<php>testfest</php> + diff --git a/ext/sockets/tests/socket_bind.phpt b/ext/sockets/tests/socket_bind.phpt new file mode 100644 index 0000000000..15181e68a6 --- /dev/null +++ b/ext/sockets/tests/socket_bind.phpt @@ -0,0 +1,38 @@ +--TEST-- +ext/sockets - socket_bind - basic test +--CREDITS-- +Florian Anderiasch +fa@php.net +--SKIPIF-- +<?php + if (!extension_loaded('sockets')) { + die('skip - sockets extension not available.'); + } +?> +--FILE-- +<?php + $rand = rand(1,999); + $s_c = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); + $s_bind = socket_bind($s_c, '0.0.0.0', 31330+$rand); + var_dump($s_bind); + + // Connect to destination address + $s_conn = socket_connect($s_c, 'www.php.net', 80); + var_dump($s_conn); + + // Write + $request = 'GET / HTTP/1.1' . "\r\n"; + $s_write = socket_write($s_c, $request); + var_dump($s_write); + + // Close + $s_close = socket_close($s_c); + var_dump($s_close); +?> + +--EXPECTF-- +bool(true) +bool(true) +int(16) +NULL + diff --git a/ext/sockets/tests/socket_bind_params.phpt b/ext/sockets/tests/socket_bind_params.phpt new file mode 100644 index 0000000000..d68a62a474 --- /dev/null +++ b/ext/sockets/tests/socket_bind_params.phpt @@ -0,0 +1,29 @@ +--TEST-- +ext/sockets - socket_bind - test with empty parameters +--CREDITS-- +Florian Anderiasch +fa@php.net +--SKIPIF-- +<?php + if (!extension_loaded('sockets')) { + die('skip - sockets extension not available.'); + } +?> +--FILE-- +<?php + $rand = rand(1,999); + $s_c = socket_create_listen(31330+$rand); + $s_w = socket_bind(); + var_dump($s_w); + $s_w = socket_bind($s_c); + var_dump($s_w); + socket_close($s_c); + +?> +--EXPECTF-- + +Warning: socket_bind() expects at least 2 parameters, 0 given in %s on line %i +NULL + +Warning: socket_bind() expects at least 2 parameters, 1 given in %s on line %i +NULL diff --git a/ext/sockets/tests/socket_close_params.phpt b/ext/sockets/tests/socket_close_params.phpt new file mode 100644 index 0000000000..a00330f5e5 --- /dev/null +++ b/ext/sockets/tests/socket_close_params.phpt @@ -0,0 +1,21 @@ +--TEST-- +ext/sockets - socket_close - test with empty parameters +--CREDITS-- +Florian Anderiasch +fa@php.net +--SKIPIF-- +<?php + if (!extension_loaded('sockets')) { + die('skip - sockets extension not available.'); + } +?> +--FILE-- +<?php + // wrong parameter count + $s_c = socket_close(); + var_dump($s_c); +?> +--EXPECTF-- + +Warning: socket_close() expects exactly 1 parameter, 0 given in %s on line %i +NULL diff --git a/ext/sockets/tests/socket_connect_error.phpt b/ext/sockets/tests/socket_connect_error.phpt new file mode 100644 index 0000000000..33e60f3d54 --- /dev/null +++ b/ext/sockets/tests/socket_connect_error.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test error cases when creating a socket +--CREDITS-- +Russell Flynn <russ@redpill-linpro.com> +#PHPTestFest2009 Norway 2009-06-09 \o/ +--INI-- +error_reporting=E_ALL +display_errors=1 +--SKIPIF-- +<?php + if (!extension_loaded('sockets')) { + echo 'skip sockets extension not available.'; +} +?> +--FILE-- +<?php + // Test with no arguments + $server = socket_create(); + + // Test with less arguments than required + $server = socket_create(SOCK_STREAM, getprotobyname('tcp')); + + // Test with non integer parameters + $server = socket_create(array(), 1, 1); + +?> +--EXPECTF-- +Warning: socket_create() expects exactly 3 parameters, 0 given in %s on line %d + +Warning: socket_create() expects exactly 3 parameters, 2 given in %s on line %d + +Warning: socket_create() expects parameter 1 to be long, array given in %s on line %d + diff --git a/ext/sockets/tests/socket_connect_params.phpt b/ext/sockets/tests/socket_connect_params.phpt new file mode 100644 index 0000000000..c8dff06e8e --- /dev/null +++ b/ext/sockets/tests/socket_connect_params.phpt @@ -0,0 +1,33 @@ +--TEST-- +ext/sockets - socket_connect - test with empty parameters +--CREDITS-- +Florian Anderiasch +fa@php.net +--SKIPIF-- +<?php + if (!extension_loaded('sockets')) { + die('skip - sockets extension not available.'); + } +?> +--FILE-- +<?php + $rand = rand(1,999); + $s_c = socket_create_listen(31330+$rand); + // wrong parameter count + $s_w = socket_connect(); + $s_w = socket_connect($s_c); + $s_w = socket_connect($s_c, '0.0.0.0'); + $s_w = socket_connect($s_c, '0.0.0.0', 31330+$rand); + + socket_close($s_c); + +?> +--EXPECTF-- + +Warning: socket_connect() expects at least 2 parameters, 0 given in %s on line %i + +Warning: socket_connect() expects at least 2 parameters, 1 given in %s on line %i + +Warning: socket_connect(): Socket of type AF_INET requires 3 arguments in %s on line %i + +Warning: socket_connect(): unable to connect [%i]: Transport endpoint is already connected in %s on line %i diff --git a/ext/sockets/tests/socket_create_listen_params.phpt b/ext/sockets/tests/socket_create_listen_params.phpt new file mode 100644 index 0000000000..56a9c8de23 --- /dev/null +++ b/ext/sockets/tests/socket_create_listen_params.phpt @@ -0,0 +1,23 @@ +--TEST-- +ext/sockets - socket_create_listen - test for empty parameters +--CREDITS-- +Florian Anderiasch +fa@php.net +--SKIPIF-- +<?php + if (!extension_loaded('sockets')) { + die('skip - sockets extension not available.'); + } +?> +--FILE-- +<?php + $rand = rand(1,999); + $s_c_l = socket_create_listen(); + var_dump($s_c_l); + if ($s_c_l !== false) { + @socket_close($s_c_l); + } +?> +--EXPECTF-- +Warning: socket_create_listen() expects at least 1 parameter, 0 given in %s on line %i +NULL diff --git a/ext/sockets/tests/socket_create_listen_used.phpt b/ext/sockets/tests/socket_create_listen_used.phpt new file mode 100644 index 0000000000..d89f1b70e8 --- /dev/null +++ b/ext/sockets/tests/socket_create_listen_used.phpt @@ -0,0 +1,30 @@ +--TEST-- +ext/sockets - socket_create_listen - test for used socket +--CREDITS-- +Florian Anderiasch +fa@php.net +--SKIPIF-- +<?php + if (!extension_loaded('sockets')) { + die('skip - sockets extension not available.'); + } +?> +--FILE-- +<?php + $rand = rand(1,999); + // wrong parameter count + $s_c_l = socket_create_listen(31330+$rand); + var_dump($s_c_l); + // default invocation + $s_c_l2 = socket_create_listen(31330+$rand); + var_dump($s_c_l2); + socket_close($s_c_l2); + socket_close($s_c_l); +?> +--EXPECTF-- +resource(%i) of type (Socket) + +Warning: socket_create_listen(): unable to bind to given address [%i]: Address already in use in %s on line %i +bool(false) + +Warning: socket_close() expects parameter 1 to be resource, boolean given in %s on line %i diff --git a/ext/sockets/tests/socket_create_params.phpt b/ext/sockets/tests/socket_create_params.phpt new file mode 100644 index 0000000000..13a1c73eee --- /dev/null +++ b/ext/sockets/tests/socket_create_params.phpt @@ -0,0 +1,24 @@ +--TEST-- +ext/sockets - socket_create - test with empty parameters +--CREDITS-- +Florian Anderiasch +fa@php.net +--SKIPIF-- +<?php + if (!extension_loaded('sockets')) { + die('skip sockets extension not available.'); + } +?> +--FILE-- +<?php + $s_w = socket_create(); + $s_w = socket_create(AF_INET); + $s_w = socket_create(AF_INET, SOCK_STREAM); +?> +--EXPECTF-- + +Warning: socket_create() expects exactly 3 parameters, 0 given in %s on line %i + +Warning: socket_create() expects exactly 3 parameters, 1 given in %s on line %i + +Warning: socket_create() expects exactly 3 parameters, 2 given in %s on line %i diff --git a/ext/sockets/tests/socket_getpeername.phpt b/ext/sockets/tests/socket_getpeername.phpt new file mode 100644 index 0000000000..2252992c02 --- /dev/null +++ b/ext/sockets/tests/socket_getpeername.phpt @@ -0,0 +1,33 @@ +--TEST-- +ext/sockets - socket_getsockname - basic test +--CREDITS-- +Florian Anderiasch +fa@php.net +--SKIPIF-- +<?php + if (!extension_loaded('sockets')) { + die('skip sockets extension not available.'); + } +?> +--FILE-- +<?php + $rand = rand(1,999); + $s_c = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); + $s_bind = socket_bind($s_c, '0.0.0.0', 31330+$rand); + var_dump($s_bind); + + // Connect to destination address + $s_peer = socket_getpeername($s_c, $ip, $port); + var_dump($s_peer); + var_dump($ip); + var_dump($port); + socket_close($s_c); +?> + +--EXPECTF-- +bool(true) + +Warning: socket_getpeername(): unable to retrieve peer name [%i]: Transport endpoint is not connected in %s on line %i +bool(false) +NULL +NULL diff --git a/ext/sockets/tests/socket_getpeername_ipv4loop.phpt b/ext/sockets/tests/socket_getpeername_ipv4loop.phpt new file mode 100644 index 0000000000..aa59abb8da --- /dev/null +++ b/ext/sockets/tests/socket_getpeername_ipv4loop.phpt @@ -0,0 +1,59 @@ +--TEST-- +ext/sockets - socket_getpeername_ipv4loop - basic test +--CREDITS-- +# TestFest 2009 - NorwayUG +# $Id: socket_getpeername_ipv4loop.phpt 494 2009-06-09 20:38:05Z tatjana.andersen@redpill-linpro.com $ +--SKIPIF-- +<?php + if (!extension_loaded('sockets')) { + die('skip sockets extension not available.'); + } +?> +--FILE-- +<?php + /* Bind and connect sockets to localhost */ + $localhost = '127.0.0.1'; + + /* Hold the port associated to address */ + $port = 31337; + + /* Setup socket server */ + $server = socket_create(AF_INET, SOCK_STREAM, getprotobyname('tcp')); + if (!$server) { + die('Unable to create AF_INET socket [server]'); + } + + if (!socket_bind($server, $localhost, $port)) { + die('Unable to bind to '.$localhost.':'.$port); + } + if (!socket_listen($server, 2)) { + die('Unable to listen on socket'); + } + + /* Connect to it */ + $client = socket_create(AF_INET, SOCK_STREAM, getprotobyname('tcp')); + if (!$client) { + die('Unable to create AF_INET socket [client]'); + } + if (!socket_connect($client, $localhost, $port)) { + die('Unable to connect to server socket'); + } + + /* Accept that connection */ + $socket = socket_accept($server); + if (!$socket) { + die('Unable to accept connection'); + } + + if (!socket_getpeername($client, $address, $port)) { + die('Unable to retrieve peer name'); + } + var_dump($address, $port); + + socket_close($client); + socket_close($socket); + socket_close($server); +?> +--EXPECT-- +string(9) "127.0.0.1" +int(31337) diff --git a/ext/sockets/tests/socket_getsockname.phpt b/ext/sockets/tests/socket_getsockname.phpt new file mode 100644 index 0000000000..877bef5016 --- /dev/null +++ b/ext/sockets/tests/socket_getsockname.phpt @@ -0,0 +1,32 @@ +--TEST-- +ext/sockets - socket_getsockname - basic test +--CREDITS-- +Florian Anderiasch +fa@php.net +--SKIPIF-- +<?php + if (!extension_loaded('sockets')) { + die('skip sockets extension not available.'); + } +?> +--FILE-- +<?php + $rand = rand(1,999); + $s_c = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); + $s_bind = socket_bind($s_c, '0.0.0.0', 31330+$rand); + var_dump($s_bind); + + // Connect to destination address + $s_conn = socket_getsockname($s_c, $ip, $port); + var_dump($s_conn); + var_dump($ip); + var_dump($port); + socket_close($s_c); +?> + +--EXPECTF-- +bool(true) +bool(true) +string(7) "0.0.0.0" +int(%i) + diff --git a/ext/sockets/tests/socket_listen_params.phpt b/ext/sockets/tests/socket_listen_params.phpt new file mode 100644 index 0000000000..65c11170fe --- /dev/null +++ b/ext/sockets/tests/socket_listen_params.phpt @@ -0,0 +1,21 @@ +--TEST-- +ext/sockets - socket_listen - test with empty parameters +--CREDITS-- +Florian Anderiasch +fa@php.net +--SKIPIF-- +<?php + if (!extension_loaded('sockets')) { + die('skip sockets extension not available.'); + } +?> +--FILE-- +<?php + // wrong parameter count + $s_c = socket_listen(); + var_dump($s_c); +?> +--EXPECTF-- + +Warning: socket_listen() expects at least 1 parameter, 0 given in %s on line %i +NULL diff --git a/ext/sockets/tests/socket_read_params.phpt b/ext/sockets/tests/socket_read_params.phpt new file mode 100644 index 0000000000..69af710ca6 --- /dev/null +++ b/ext/sockets/tests/socket_read_params.phpt @@ -0,0 +1,28 @@ +--TEST-- +ext/sockets - socket_read- test with empty parameters +--CREDITS-- +Florian Anderiasch +fa@php.net +--SKIPIF-- +<?php + if (!extension_loaded('sockets')) { + die('skip sockets extension not available.'); + } +?> +--FILE-- +<?php + $rand = rand(1,999); + // wrong parameter count + $s_c = socket_read(); + $s_c = socket_read(14); + $s_c_l = socket_create_listen(31330+$rand); + $s_c = socket_read($s_c_l, 25); + socket_close($s_c_l); +?> +--EXPECTF-- + +Warning: socket_read() expects at least 2 parameters, 0 given in %s on line %i + +Warning: socket_read() expects at least 2 parameters, 1 given in %s on line %i + +Warning: socket_read(): unable to read from socket [%i]: Transport endpoint is not connected in %s on line %i diff --git a/ext/sockets/tests/socket_set_nonblock.phpt b/ext/sockets/tests/socket_set_nonblock.phpt new file mode 100644 index 0000000000..55137d3582 --- /dev/null +++ b/ext/sockets/tests/socket_set_nonblock.phpt @@ -0,0 +1,24 @@ +--TEST-- +ext/sockets - socket_set_block - basic test +--CREDITS-- +Florian Anderiasch +fa@php.net +--SKIPIF-- +<?php + if (!extension_loaded('sockets')) { + die('skip sockets extension not available.'); + } +?> +--FILE-- +<?php + $rand = rand(1,999); + $s_c_l = socket_create_listen(31330+$rand); + socket_set_nonblock($s_c_l); + var_dump($s_c_l); + #socket_accept($s_c_l); + socket_close($s_c_l); +?> + +--EXPECTF-- +resource(%i) of type (Socket) + diff --git a/ext/sockets/tests/socket_write_params.phpt b/ext/sockets/tests/socket_write_params.phpt new file mode 100644 index 0000000000..e23766ea62 --- /dev/null +++ b/ext/sockets/tests/socket_write_params.phpt @@ -0,0 +1,28 @@ +--TEST-- +ext/sockets - socket_write - test with empty parameters +--CREDITS-- +Florian Anderiasch +fa@php.net +--SKIPIF-- +<?php + if (!extension_loaded('sockets')) { + die('skip sockets extension not available.'); + } +?> +--FILE-- +<?php + $rand = rand(1,999); + // wrong parameter count + $s_w = socket_write(); + $s_c = socket_create_listen(31330+$rand); + $s_w = socket_write($s_c); + $s_w = socket_write($s_c, "foo"); + socket_close($s_c); +?> +--EXPECTF-- + +Warning: socket_write() expects at least 2 parameters, 0 given in %s on line %i + +Warning: socket_write() expects at least 2 parameters, 1 given in %s on line %i + +Warning: socket_write(): unable to write to socket [%i]: Broken pipe in %s on line %i diff --git a/ext/spl/tests/DirectoryIterator_by_reference.phpt b/ext/spl/tests/DirectoryIterator_by_reference.phpt new file mode 100644 index 0000000000..5352a5df18 --- /dev/null +++ b/ext/spl/tests/DirectoryIterator_by_reference.phpt @@ -0,0 +1,14 @@ +--TEST-- +DirectoryIterator: test that you cannot use iterator with reference +--CREDITS-- +Havard Eide <nucleuz@gmail.com> +#PHPTestFest2009 Norway 2009-06-09 \o/ +--FILE-- +<?php +$it = new DirectoryIterator("/tmp"); +foreach( $it as &$file ) { + echo $file . "\n"; +} +?> +--EXPECTF-- +Fatal error: An iterator cannot be used with foreach by reference in %s on line %d
\ No newline at end of file diff --git a/ext/spl/tests/DirectoryIterator_empty_constructor.phpt b/ext/spl/tests/DirectoryIterator_empty_constructor.phpt new file mode 100644 index 0000000000..da5276ccdc --- /dev/null +++ b/ext/spl/tests/DirectoryIterator_empty_constructor.phpt @@ -0,0 +1,15 @@ +--TEST-- +DirectoryIterator: Test empty value to DirectoryIterator constructor +--CREDITS-- +Havard Eide <nucleuz@gmail.com> +#PHPTestFest2009 Norway 2009-06-09 \o/ +--FILE-- +<?php +$it = new DirectoryIterator(""); +?> +--EXPECTF-- +Fatal error: Uncaught exception 'RuntimeException' with message 'Directory name must not be empty.' in %s:%d +Stack trace: +#0 %s(%d): DirectoryIterator->__construct('') +#1 {main} + thrown in %s on line %d
\ No newline at end of file diff --git a/ext/spl/tests/DirectoryIterator_getGroup_basic.phpt b/ext/spl/tests/DirectoryIterator_getGroup_basic.phpt new file mode 100644 index 0000000000..58387cccef --- /dev/null +++ b/ext/spl/tests/DirectoryIterator_getGroup_basic.phpt @@ -0,0 +1,30 @@ +--TEST--
+SPL: DirectoryIterator test getGroup
+--CREDITS--
+Cesare D'Amico <cesare.damico@gruppovolta.it> +Andrea Giorgini <agiorg@gmail.com> +Filippo De Santis <fd@ideato.it> +Daniel Londero <daniel.londero@gmail.com> +Francesco Trucchia <ft@ideato.it> +Jacopo Romei <jacopo@sviluppoagile.it> +#Test Fest Cesena (Italy) on 2009-06-20
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
+?>
+--FILE--
+<?php
+ +shell_exec('mkdir test_dir_ptfi'); +$dir = new DirectoryIterator('test_dir_ptfi'); +$result = shell_exec('ls -lnd test_dir_ptfi | cut -d" " -f 4'); + +var_dump($dir->getGroup() == $result); + +?> +--CLEAN-- +<?php +rmdir('test_dir_ptfi'); +?>
+--EXPECTF--
+bool(true) diff --git a/ext/spl/tests/DirectoryIterator_getInode_error.phpt b/ext/spl/tests/DirectoryIterator_getInode_error.phpt new file mode 100644 index 0000000000..c3641f9d89 --- /dev/null +++ b/ext/spl/tests/DirectoryIterator_getInode_error.phpt @@ -0,0 +1,28 @@ +--TEST--
+SPL: Spl File Info test getInode
+--CREDITS--
+Cesare D'Amico <cesare.damico@gruppovolta.it> +Andrea Giorgini <agiorg@gmail.com> +Filippo De Santis <fd@ideato.it> +Daniel Londero <daniel.londero@gmail.com> +Francesco Trucchia <ft@ideato.it> +Jacopo Romei <jacopo@sviluppoagile.it> +#Test Fest Cesena (Italy) on 2009-06-20
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
+?>
+--FILE--
+<?php
+ +//file +$fileInfo = new SplFileInfo('not_existing'); +var_dump($fileInfo->getInode()); +?> +
+--EXPECTF-- +Fatal error: Uncaught exception 'RuntimeException' with message 'SplFileInfo::getInode(): stat failed for %s' in %s +Stack trace: +#0 %s: SplFileInfo->getInode() +#1 {main} + thrown in %s diff --git a/ext/spl/tests/DirectoryIterator_getOwner_basic.phpt b/ext/spl/tests/DirectoryIterator_getOwner_basic.phpt new file mode 100644 index 0000000000..e342dcdb6f --- /dev/null +++ b/ext/spl/tests/DirectoryIterator_getOwner_basic.phpt @@ -0,0 +1,29 @@ +--TEST--
+SPL: Spl Directory Iterator test getOwner
+--CREDITS--
+Cesare D'Amico <cesare.damico@gruppovolta.it> +Andrea Giorgini <agiorg@gmail.com> +Filippo De Santis <fd@ideato.it> +Daniel Londero <daniel.londero@gmail.com> +Francesco Trucchia <ft@ideato.it> +Jacopo Romei <jacopo@sviluppoagile.it> +#Test Fest Cesena (Italy) on 2009-06-20
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
+?>
+--FILE--
+<?php
+ +shell_exec('mkdir test_dir_ptfi'); +$dir = new DirectoryIterator('test_dir_ptfi'); +$result = shell_exec('ls -lnd test_dir_ptfi | cut -d" " -f 3'); +var_dump($dir->getOwner() == $result); + +?> +--CLEAN-- +<?php +rmdir('test_dir_ptfi'); +?>
+--EXPECTF--
+bool(true) diff --git a/ext/spl/tests/SplFileInfo_getGroup_basic.phpt b/ext/spl/tests/SplFileInfo_getGroup_basic.phpt new file mode 100644 index 0000000000..7b0528d7d1 --- /dev/null +++ b/ext/spl/tests/SplFileInfo_getGroup_basic.phpt @@ -0,0 +1,30 @@ +--TEST--
+SPL: Spl File Info test getGroup
+--CREDITS--
+Cesare D'Amico <cesare.damico@gruppovolta.it> +Andrea Giorgini <agiorg@gmail.com> +Filippo De Santis <fd@ideato.it> +Daniel Londero <daniel.londero@gmail.com> +Francesco Trucchia <ft@ideato.it> +Jacopo Romei <jacopo@sviluppoagile.it> +#Test Fest Cesena (Italy) on 2009-06-20
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
+?>
+--FILE--
+<?php
+ +//file +touch ('test_file_ptfi'); +$fileInfo = new SplFileInfo('test_file_ptfi'); +$result = shell_exec('ls -ln test_file_ptfi | cut -d" " -f 4'); +var_dump($fileInfo->getGroup() == $result); + +?> +--CLEAN-- +<?php +unlink('test_file_ptfi'); +?>
+--EXPECTF--
+bool(true) diff --git a/ext/spl/tests/SplFileInfo_getGroup_error.phpt b/ext/spl/tests/SplFileInfo_getGroup_error.phpt new file mode 100644 index 0000000000..f0db00d9ed --- /dev/null +++ b/ext/spl/tests/SplFileInfo_getGroup_error.phpt @@ -0,0 +1,28 @@ +--TEST--
+SPL: Spl File Info test getGroup
+--CREDITS--
+Cesare D'Amico <cesare.damico@gruppovolta.it> +Andrea Giorgini <agiorg@gmail.com> +Filippo De Santis <fd@ideato.it> +Daniel Londero <daniel.londero@gmail.com> +Francesco Trucchia <ft@ideato.it> +Jacopo Romei <jacopo@sviluppoagile.it> +#Test Fest Cesena (Italy) on 2009-06-20
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
+?>
+--FILE--
+<?php
+ +//file +$fileInfo = new SplFileInfo('not_existing'); +var_dump($fileInfo->getGroup()); +?> +
+--EXPECTF-- +Fatal error: Uncaught exception 'RuntimeException' with message 'SplFileInfo::getGroup(): stat failed for not_existing' in %s +Stack trace: +#0 %s: SplFileInfo->getGroup() +#1 {main} + thrown in %s on line %d diff --git a/ext/spl/tests/SplFileInfo_getInode_basic.phpt b/ext/spl/tests/SplFileInfo_getInode_basic.phpt new file mode 100644 index 0000000000..902cbb31c6 --- /dev/null +++ b/ext/spl/tests/SplFileInfo_getInode_basic.phpt @@ -0,0 +1,30 @@ +--TEST--
+SPL: Spl File Info test getInode
+--CREDITS--
+Cesare D'Amico <cesare.damico@gruppovolta.it> +Andrea Giorgini <agiorg@gmail.com> +Filippo De Santis <fd@ideato.it> +Daniel Londero <daniel.londero@gmail.com> +Francesco Trucchia <ft@ideato.it> +Jacopo Romei <jacopo@sviluppoagile.it> +#Test Fest Cesena (Italy) on 2009-06-20
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
+?>
+--FILE--
+<?php
+ +//file +touch ('test_file_ptfi'); +$fileInfo = new SplFileInfo('test_file_ptfi'); +$result = shell_exec('ls -i test_file_ptfi'); +var_dump($fileInfo->getInode() == $result); + +?> +--CLEAN-- +<?php +unlink('test_file_ptfi'); +?>
+--EXPECTF--
+bool(true) diff --git a/ext/spl/tests/SplFileInfo_getInode_error.phpt b/ext/spl/tests/SplFileInfo_getInode_error.phpt new file mode 100644 index 0000000000..bf8efae4c9 --- /dev/null +++ b/ext/spl/tests/SplFileInfo_getInode_error.phpt @@ -0,0 +1,28 @@ +--TEST--
+SPL: Spl File Info test getPerms
+--CREDITS--
+Cesare D'Amico <cesare.damico@gruppovolta.it> +Andrea Giorgini <agiorg@gmail.com> +Filippo De Santis <fd@ideato.it> +Daniel Londero <daniel.londero@gmail.com> +Francesco Trucchia <ft@ideato.it> +Jacopo Romei <jacopo@sviluppoagile.it> +#Test Fest Cesena (Italy) on 2009-06-20
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
+?>
+--FILE--
+<?php
+ +//file +$fileInfo = new SplFileInfo('not_existing'); +var_dump($fileInfo->getInode()); +?> +
+--EXPECTF-- +Fatal error: Uncaught exception 'RuntimeException' with message 'SplFileInfo::getInode(): stat failed for not_existing' in %s +Stack trace: +#0 %s: SplFileInfo->getInode() +#1 {main} + thrown in %s on line %d diff --git a/ext/spl/tests/SplFileInfo_getOwner_basic.phpt b/ext/spl/tests/SplFileInfo_getOwner_basic.phpt new file mode 100644 index 0000000000..50f79430c9 --- /dev/null +++ b/ext/spl/tests/SplFileInfo_getOwner_basic.phpt @@ -0,0 +1,30 @@ +--TEST--
+SPL: Spl File Info test getOwner
+--CREDITS--
+Cesare D'Amico <cesare.damico@gruppovolta.it> +Andrea Giorgini <agiorg@gmail.com> +Filippo De Santis <fd@ideato.it> +Daniel Londero <daniel.londero@gmail.com> +Francesco Trucchia <ft@ideato.it> +Jacopo Romei <jacopo@sviluppoagile.it> +#Test Fest Cesena (Italy) on 2009-06-20
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
+?>
+--FILE--
+<?php
+ +//file +touch ('test_file_ptfi'); +$fileInfo = new SplFileInfo('test_file_ptfi'); +$result = shell_exec('ls -ln test_file_ptfi | cut -d" " -f 3'); +var_dump($fileInfo->getOwner() == $result); + +?> +--CLEAN-- +<?php +unlink('test_file_ptfi'); +?>
+--EXPECTF--
+bool(true) diff --git a/ext/spl/tests/SplFileInfo_getOwner_error.phpt b/ext/spl/tests/SplFileInfo_getOwner_error.phpt new file mode 100644 index 0000000000..d5d46781cc --- /dev/null +++ b/ext/spl/tests/SplFileInfo_getOwner_error.phpt @@ -0,0 +1,28 @@ +--TEST--
+SPL: Spl File Info test getOwner
+--CREDITS--
+Cesare D'Amico <cesare.damico@gruppovolta.it> +Andrea Giorgini <agiorg@gmail.com> +Filippo De Santis <fd@ideato.it> +Daniel Londero <daniel.londero@gmail.com> +Francesco Trucchia <ft@ideato.it> +Jacopo Romei <jacopo@sviluppoagile.it> +#Test Fest Cesena (Italy) on 2009-06-20
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
+?>
+--FILE--
+<?php
+ +//file +$fileInfo = new SplFileInfo('not_existing'); +var_dump($fileInfo->getOwner()); +?> +
+--EXPECTF-- +Fatal error: Uncaught exception 'RuntimeException' with message 'SplFileInfo::getOwner(): stat failed for not_existing' in %s +Stack trace: +#0 %s: SplFileInfo->getOwner() +#1 {main} + thrown in %s on line %d diff --git a/ext/spl/tests/SplFileInfo_getPerms_basic.phpt b/ext/spl/tests/SplFileInfo_getPerms_basic.phpt new file mode 100644 index 0000000000..e9b7beaa97 --- /dev/null +++ b/ext/spl/tests/SplFileInfo_getPerms_basic.phpt @@ -0,0 +1,30 @@ +--TEST--
+SPL: Spl File Info test getPerms
+--CREDITS--
+Cesare D'Amico <cesare.damico@gruppovolta.it> +Andrea Giorgini <agiorg@gmail.com> +Filippo De Santis <fd@ideato.it> +Daniel Londero <daniel.londero@gmail.com> +Francesco Trucchia <ft@ideato.it> +Jacopo Romei <jacopo@sviluppoagile.it> +#Test Fest Cesena (Italy) on 2009-06-20
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
+?>
+--FILE--
+<?php
+ +//file +touch ('test_file_ptfi'); +chmod('test_file_ptfi', 0557); +$fileInfo = new SplFileInfo('test_file_ptfi'); +var_dump($fileInfo->getPerms() == 0100557); + +?> +--CLEAN-- +<?php +unlink('test_file_ptfi'); +?>
+--EXPECTF--
+bool(true) diff --git a/ext/spl/tests/SplFileInfo_getPerms_error.phpt b/ext/spl/tests/SplFileInfo_getPerms_error.phpt new file mode 100644 index 0000000000..8e05cdf8df --- /dev/null +++ b/ext/spl/tests/SplFileInfo_getPerms_error.phpt @@ -0,0 +1,28 @@ +--TEST--
+SPL: Spl File Info test getPerms
+--CREDITS--
+Cesare D'Amico <cesare.damico@gruppovolta.it> +Andrea Giorgini <agiorg@gmail.com> +Filippo De Santis <fd@ideato.it> +Daniel Londero <daniel.londero@gmail.com> +Francesco Trucchia <ft@ideato.it> +Jacopo Romei <jacopo@sviluppoagile.it> +#Test Fest Cesena (Italy) on 2009-06-20
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
+?>
+--FILE--
+<?php
+ +//file +$fileInfo = new SplFileInfo('not_existing'); +var_dump($fileInfo->getPerms() == 0100557); +?> +
+--EXPECTF-- +Fatal error: Uncaught exception 'RuntimeException' with message 'SplFileInfo::getPerms(): stat failed for %s' in %s +Stack trace: +#0 %s: SplFileInfo->getPerms() +#1 {main} + thrown in %s diff --git a/ext/standard/tests/array/key_exists_basic.phpt b/ext/standard/tests/array/key_exists_basic.phpt new file mode 100644 index 0000000000..40d982da21 --- /dev/null +++ b/ext/standard/tests/array/key_exists_basic.phpt @@ -0,0 +1,15 @@ +--TEST-- +Test function key_exists() by calling it with its expected arguments +--CREDITS-- +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php +echo "*** test key_exists() by calling it with its expected arguments ***\n"; +$a = array('bar' => 1); +var_dump(key_exists('bar', $a)); +var_dump(key_exists('foo', $a)); +--EXPECTF-- +*** test key_exists() by calling it with its expected arguments *** +bool(true) +bool(false) diff --git a/ext/standard/tests/array/key_exists_variation1.phpt b/ext/standard/tests/array/key_exists_variation1.phpt new file mode 100644 index 0000000000..94ea8d45f7 --- /dev/null +++ b/ext/standard/tests/array/key_exists_variation1.phpt @@ -0,0 +1,15 @@ +--TEST-- +Test function key_exists() by calling it with its expected arguments +--CREDITS-- +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php +echo "*** test key_exists() by calling it with its expected arguments ***\n"; +$a = array('bar' => 1, 'foo' => array('bar' => 2, 'baz' => 3)); +var_dump(key_exists('baz', $a)); +var_dump(key_exists('baz', $a['foo'])); +--EXPECTF-- +*** test key_exists() by calling it with its expected arguments *** +bool(false) +bool(true) diff --git a/ext/standard/tests/array/key_exists_variation2.phpt b/ext/standard/tests/array/key_exists_variation2.phpt new file mode 100644 index 0000000000..5f5ab86a4f --- /dev/null +++ b/ext/standard/tests/array/key_exists_variation2.phpt @@ -0,0 +1,72 @@ +--TEST-- +Test function key_exists() by calling it with its expected arguments +--CREDITS-- +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php +echo "*** test key_exists() by using mixed type of arrays ***\n"; + +// there is not a index = 0 element +$a = array(1 => 'bar', 'foo' => 'baz'); +var_dump(key_exists(0, $a)); + +echo "integer\n"; +// 1 has index = 0 +$b = array(1, 'foo' => 'baz'); +var_dump(key_exists(0, $b)); + +// 42 has index = 0, netherless its position is the latest +$c = array('foo' => 'baz', 42); +var_dump(key_exists(0, $c)); + +echo "string\n"; +// 'bar' has index = 0, netherless it is a string +$d = array('bar', 'foo' => 'baz'); +var_dump(key_exists(0, $d)); + +// 'baz' has index = 0, netherless its position is the latest +$e = array('foo' => 'baz', 'baz'); +var_dump(key_exists(0, $e)); + +echo "obj\n"; +class ObjectA +{ + public $foo = 'bar'; +} + +$obj = new ObjectA(); + +// object has index = 0, netherless its position is the latest +$f = array('foo' => 'baz', $obj); +var_dump(key_exists(0, $f)); + +// object has index = 0, netherless its position is the first +$g = array($obj, 'foo' => 'baz'); +var_dump(key_exists(0, $g)); + +echo "stream resource\n"; +// stream resource has index = 0, netherless its position is the first +$st = fopen('php://memory', '+r'); +$h = array($st, 'foo' => 'baz'); +var_dump(key_exists(0, $h)); + +// stream resource has index = 0, netherless its position is the latest +$i = array('foo' => 'baz', $st); +var_dump(key_exists(0, $i)); + +--EXPECTF-- +*** test key_exists() by using mixed type of arrays *** +bool(false) +integer +bool(true) +bool(true) +string +bool(true) +bool(true) +obj +bool(true) +bool(true) +stream resource +bool(true) +bool(true) diff --git a/ext/standard/tests/file/file_get_contents_error001.phpt b/ext/standard/tests/file/file_get_contents_error001.phpt new file mode 100644 index 0000000000..ced0da032c --- /dev/null +++ b/ext/standard/tests/file/file_get_contents_error001.phpt @@ -0,0 +1,18 @@ +--TEST-- +file_get_contents() test using offset parameter out of range +--CREDITS-- +"Blanche V.N." <valerie_nare@yahoo.fr> +"Sylvain R." <sracine@phpquebec.org> +--INI-- +display_errors=false +--SKIPIF-- +<?php + if (!function_exists("file_get_contents")) + die ("skip file_get_contents function is not found"); +?> +--FILE-- +<?php + var_dump(file_get_contents("http://checkip.dyndns.com",null,null,8000,1)); +?> +--EXPECT-- +bool(false) diff --git a/ext/standard/tests/file/file_get_contents_error002.phpt b/ext/standard/tests/file/file_get_contents_error002.phpt new file mode 100644 index 0000000000..47c7b9cd63 --- /dev/null +++ b/ext/standard/tests/file/file_get_contents_error002.phpt @@ -0,0 +1,18 @@ +--TEST-- +file_get_contents() test using negative parameter for length (last parameter) +--CREDITS-- +"Blanche V.N." <valerie_nare@yahoo.fr> +"Sylvain R." <sracine@phpquebec.org> +--INI-- +display_errors=false +--SKIPIF-- +<?php + if (!function_exists("file_get_contents")) + die ("skip file_get_contents function is not found"); +?> +--FILE-- +<?php + var_dump(file_get_contents("http://checkip.dyndns.com",null,null,0,-1)); +?> +--EXPECT-- +bool(false) diff --git a/ext/standard/tests/general_functions/get_cfg_var_variation2.phpt b/ext/standard/tests/general_functions/get_cfg_var_variation2.phpt new file mode 100644 index 0000000000..68495a13d9 --- /dev/null +++ b/ext/standard/tests/general_functions/get_cfg_var_variation2.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test function get_cfg_var() by substituting argument 1 with boolean values. +--CREDITS-- +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--INI-- +session.use_cookies=0 +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with boolean values ***\n"; + + + +$variation_array = array( + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + ); + + +foreach ( $variation_array as $var ) { + var_dump(get_cfg_var( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with boolean values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/get_cfg_var_variation3.phpt b/ext/standard/tests/general_functions/get_cfg_var_variation3.phpt new file mode 100644 index 0000000000..d1fb5e7dda --- /dev/null +++ b/ext/standard/tests/general_functions/get_cfg_var_variation3.phpt @@ -0,0 +1,42 @@ +--TEST-- +Test function get_cfg_var() by substituting argument 1 with emptyUnsetUndefNull values. +--CREDITS-- +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--INI-- +session.use_cookies=0 +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with emptyUnsetUndefNull values ***\n"; + + + +$unset_var = 10; +unset($unset_var); + +$variation_array = array( + 'unset var' => @$unset_var, + 'undefined var' => @$undefined_var, + 'empty string DQ' => "", + 'empty string SQ' => '', + 'uppercase NULL' => NULL, + 'lowercase null' => null + ); + + +foreach ( $variation_array as $var ) { + var_dump(get_cfg_var( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with emptyUnsetUndefNull values *** +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/get_cfg_var_variation4.phpt b/ext/standard/tests/general_functions/get_cfg_var_variation4.phpt new file mode 100644 index 0000000000..8dac4f8a40 --- /dev/null +++ b/ext/standard/tests/general_functions/get_cfg_var_variation4.phpt @@ -0,0 +1,37 @@ +--TEST-- +Test function get_cfg_var() by substituting argument 1 with float values. +--CREDITS-- +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--INI-- +session.use_cookies=0 +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with float values ***\n"; + + + +$variation_array = array( + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float 12.3456789000e10' => 12.3456789000e10, + 'float -12.3456789000e10' => -12.3456789000e10, + 'float .5' => .5, + ); + + +foreach ( $variation_array as $var ) { + var_dump(get_cfg_var( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with float values *** +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/get_cfg_var_variation5.phpt b/ext/standard/tests/general_functions/get_cfg_var_variation5.phpt new file mode 100644 index 0000000000..392abb32c5 --- /dev/null +++ b/ext/standard/tests/general_functions/get_cfg_var_variation5.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test function get_cfg_var() by substituting argument 1 with int values. +--CREDITS-- +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--INI-- +session.use_cookies=0 +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with int values ***\n"; + + + +$variation_array = array ( + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -2345, + ); + + +foreach ( $variation_array as $var ) { + var_dump(get_cfg_var( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with int values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/get_cfg_var_variation7.phpt b/ext/standard/tests/general_functions/get_cfg_var_variation7.phpt new file mode 100644 index 0000000000..3b5b08c6d5 --- /dev/null +++ b/ext/standard/tests/general_functions/get_cfg_var_variation7.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test function get_cfg_var() by substituting argument 1 with string values. +--CREDITS-- +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--INI-- +session.use_cookies=0 +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with unknown string values ***\n"; + + + +$heredoc = <<<EOT +hello world +EOT; + +$variation_array = array( + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc + ); + + +foreach ( $variation_array as $var ) { + var_dump(get_cfg_var( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with unknown string values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/getservbyname_basic.phpt b/ext/standard/tests/general_functions/getservbyname_basic.phpt new file mode 100755 index 0000000000..164e71afd4 --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_basic.phpt @@ -0,0 +1,31 @@ +--TEST-- +Test function getservbyport() by calling it more than or less than its expected arguments +--CREDITS-- +Italian PHP TestFest 2009 Cesena 19-20-21 june +Fabio Fabbrucci (fabbrucci@grupporetina.com) +Michele Orselli (mo@ideato.it) +Simone Gentili (sensorario@gmail.com) +--FILE-- +<?php + + $services = array('http', 'ftp', 'ssh', 'telnet', 'imap', 'smtp', 'nicname', 'gopher', 'finger', 'pop3', 'www'); + + foreach ($services as $service) { + $port = getservbyname($service, 'tcp'); + var_dump($port); + } + + +?> +--EXPECTF-- +int(%d) +int(%d) +int(%d) +int(%d) +int(%d) +int(%d) +int(%d) +int(%d) +int(%d) +int(%d) +int(%d) diff --git a/ext/standard/tests/general_functions/getservbyname_variation10.phpt b/ext/standard/tests/general_functions/getservbyname_variation10.phpt new file mode 100755 index 0000000000..70aa567646 --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_variation10.phpt @@ -0,0 +1,36 @@ +--TEST-- +Test function getservbyname() by substituting argument 2 with emptyUnsetUndefNull values. +--FILE-- +<?php + + +echo "*** Test substituting argument 2 with emptyUnsetUndefNull values ***\n"; + +$service = "www"; + + +$unset_var = 10; +unset($unset_var); + +$variation_array = array( + 'unset var' => @$unset_var, + 'undefined var' => @$undefined_var, + 'empty string DQ' => "", + 'empty string SQ' => '', + 'uppercase NULL' => NULL, + 'lowercase null' => null, + ); + + +foreach ( $variation_array as $var ) { + var_dump(getservbyname( $service, $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 2 with emptyUnsetUndefNull values *** +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/getservbyname_variation11.phpt b/ext/standard/tests/general_functions/getservbyname_variation11.phpt new file mode 100755 index 0000000000..3c410c55b6 --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_variation11.phpt @@ -0,0 +1,30 @@ +--TEST-- +Test function getservbyname() by substituting argument 2 with float values. +--FILE-- +<?php + + +echo "*** Test substituting argument 2 with float values ***\n"; + +$service = "www"; + +$variation_array = array( + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float 12.3456789000e10' => 12.3456789000e10, + 'float -12.3456789000e10' => -12.3456789000e10, + 'float .5' => .5, + ); + + +foreach ( $variation_array as $var ) { + var_dump(getservbyname( $service, $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 2 with float values *** +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/getservbyname_variation12.phpt b/ext/standard/tests/general_functions/getservbyname_variation12.phpt new file mode 100755 index 0000000000..7e5323cca8 --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_variation12.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test function getservbyname() by substituting argument 2 with int values. +--FILE-- +<?php + + +echo "*** Test substituting argument 2 with int values ***\n"; + +$service = "www"; + + +$variation_array = array ( + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -2345, + ); + + +foreach ( $variation_array as $var ) { + var_dump(getservbyname( $service, $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 2 with int values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/getservbyname_variation14.phpt b/ext/standard/tests/general_functions/getservbyname_variation14.phpt new file mode 100755 index 0000000000..d93b53ece4 --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_variation14.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test function getservbyname() by substituting argument 2 with string values. +--FILE-- +<?php + + +echo "*** Test substituting argument 2 with string values ***\n"; + +$service = "www"; + + +$heredoc = <<<EOT +hello world +EOT; + +$variation_array = array( + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + ); + + +foreach ( $variation_array as $var ) { + var_dump(getservbyname( $service, $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 2 with string values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/getservbyname_variation2.phpt b/ext/standard/tests/general_functions/getservbyname_variation2.phpt new file mode 100755 index 0000000000..877c1d12af --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_variation2.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test function getservbyname() by substituting argument 1 with boolean values. +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with boolean values ***\n"; + +$protocol = "tcp"; + + +$variation_array = array( + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + ); + + +foreach ( $variation_array as $var ) { + var_dump(getservbyname( $var , $protocol ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with boolean values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/getservbyname_variation3.phpt b/ext/standard/tests/general_functions/getservbyname_variation3.phpt new file mode 100755 index 0000000000..d34259d2a2 --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_variation3.phpt @@ -0,0 +1,36 @@ +--TEST-- +Test function getservbyname() by substituting argument 1 with emptyUnsetUndefNull values. +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with emptyUnsetUndefNull values ***\n"; + +$protocol = "tcp"; + + +$unset_var = 10; +unset($unset_var); + +$variation_array = array( + 'unset var' => @$unset_var, + 'undefined var' => @$undefined_var, + 'empty string DQ' => "", + 'empty string SQ' => '', + 'uppercase NULL' => NULL, + 'lowercase null' => null, + ); + + +foreach ( $variation_array as $var ) { + var_dump(getservbyname( $var , $protocol ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with emptyUnsetUndefNull values *** +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/getservbyname_variation4.phpt b/ext/standard/tests/general_functions/getservbyname_variation4.phpt new file mode 100755 index 0000000000..6033c94363 --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_variation4.phpt @@ -0,0 +1,31 @@ +--TEST-- +Test function getservbyname() by substituting argument 1 with float values. +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with float values ***\n"; + +$protocol = "tcp"; + + +$variation_array = array( + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float 12.3456789000e10' => 12.3456789000e10, + 'float -12.3456789000e10' => -12.3456789000e10, + 'float .5' => .5, + ); + + +foreach ( $variation_array as $var ) { + var_dump(getservbyname( $var , $protocol ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with float values *** +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/getservbyname_variation5.phpt b/ext/standard/tests/general_functions/getservbyname_variation5.phpt new file mode 100755 index 0000000000..1d3b8f6d74 --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_variation5.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test function getservbyname() by substituting argument 1 with int values. +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with int values ***\n"; + +$protocol = "tcp"; + + +$variation_array = array ( + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -2345, + ); + + +foreach ( $variation_array as $var ) { + var_dump(getservbyname( $var , $protocol ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with int values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/getservbyname_variation7.phpt b/ext/standard/tests/general_functions/getservbyname_variation7.phpt new file mode 100755 index 0000000000..a0e223c50d --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_variation7.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test function getservbyname() by substituting argument 1 with string values. +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with string values ***\n"; + +$protocol = "tcp"; + + +$heredoc = <<<EOT +hello world +EOT; + +$variation_array = array( + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + ); + + +foreach ( $variation_array as $var ) { + var_dump(getservbyname( $var , $protocol ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with string values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/getservbyname_variation9.phpt b/ext/standard/tests/general_functions/getservbyname_variation9.phpt new file mode 100755 index 0000000000..c1c231e148 --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_variation9.phpt @@ -0,0 +1,28 @@ +--TEST-- +Test function getservbyname() by substituting argument 2 with boolean values. +--FILE-- +<?php + + +echo "*** Test substituting argument 2 with boolean values ***\n"; + +$service = "www"; + +$variation_array = array( + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + ); + + +foreach ( $variation_array as $var ) { + var_dump(getservbyname( $service, $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 2 with boolean values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/getservbyport_basic.phpt b/ext/standard/tests/general_functions/getservbyport_basic.phpt new file mode 100644 index 0000000000..c18c0b7731 --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyport_basic.phpt @@ -0,0 +1,22 @@ +--TEST-- +Test function getservbyport() by calling it more than or less than its expected arguments +--CREDITS-- +Italian PHP TestFest 2009 Cesena 19-20-21 june +Fabio Fabbrucci (fabbrucci@grupporetina.com) +Michele Orselli (mo@ideato.it) +Simone Gentili (sensorario@gmail.com) +--FILE-- +<?php + if(stristr(PHP_OS, "linux")) $file = "/etc/services"; + elseif(stristr(PHP_OS, "Darwin")) $file = "/etc/services"; + elseif(substr(PHP_OS,0,3) == "WIN") $file = "C:/WINDOWS/system32/drivers/etc/services"; + else die(PHP_OS. " unsupported"); + + if(file_exists($file)){ + var_dump(getservbyport( 80, "tcp" ) === "www"); + }else{ + var_dump(getservbyport(80, "tcp") === false); + } +?> +--EXPECTF-- +bool(true) diff --git a/ext/standard/tests/general_functions/proc_nice_basic.phpt b/ext/standard/tests/general_functions/proc_nice_basic.phpt new file mode 100644 index 0000000000..5a95756276 --- /dev/null +++ b/ext/standard/tests/general_functions/proc_nice_basic.phpt @@ -0,0 +1,27 @@ +--TEST-- +proc_nice() basic behaviour +--CREDITS-- +Italian PHP TestFest 2009 Cesena 19-20-21 june +Fabio Fabbrucci (fabbrucci@grupporetina.com) +Michele Orselli (mo@ideato.it) +Simone Gentili (sensorario@gmail.com) +--FILE-- +<?php + function getNice($id) + { + $res = shell_exec('ps -p ' . $id .' -o "%p %n"'); + preg_match('/^\s*\w+\s+\w+\s*(\d+)\s+(\d+)/m', $res, $matches); + if (count($matches) > 2) + return $matches[2]; + else + return -1; + } + $delta = 10; + $pid = getmypid(); + $niceBefore = getNice($pid); + proc_nice($delta); + $niceAfter = getNice($pid); + var_dump($niceBefore == ($niceAfter - $delta)); +?> +--EXPECTF-- +bool(true) diff --git a/ext/standard/tests/general_functions/proc_nice_error.phpt b/ext/standard/tests/general_functions/proc_nice_error.phpt new file mode 100644 index 0000000000..c50812c863 --- /dev/null +++ b/ext/standard/tests/general_functions/proc_nice_error.phpt @@ -0,0 +1,21 @@ +--TEST-- +Test function proc_nice() by calling it more than or less than its expected arguments +--FILE-- +<?php + + +echo "*** Test by calling method or function with incorrect numbers of arguments ***\n" + +$priority = + + +$extra_arg = + +var_dump(proc_nice( $priority, $extra_arg ) ); + +var_dump(proc_nice( ) ); + + +?> +--EXPECTF-- +Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in %s on line %d diff --git a/ext/standard/tests/general_functions/proc_nice_variation1.phpt b/ext/standard/tests/general_functions/proc_nice_variation1.phpt new file mode 100644 index 0000000000..b86155c4b2 --- /dev/null +++ b/ext/standard/tests/general_functions/proc_nice_variation1.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test function proc_nice() by substituting argument 1 with array values. +--CREDITS-- +Italian PHP TestFest 2009 Cesena 19-20-21 june +Fabio Fabbrucci (fabbrucci@grupporetina.com) +Michele Orselli (mo@ideato.it) +Simone Gentili (sensorario@gmail.com) +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with array values ***\n"; + + + +$index_array = array(1, 2, 3); +$assoc_array = array(1 => 'one', 2 => 'two'); + +$variation_array = array( + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + ); + + +foreach ( $variation_array as $var ) { + var_dump(proc_nice( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with array values *** + +Warning: proc_nice() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Warning: proc_nice() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Warning: proc_nice() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Warning: proc_nice() expects parameter 1 to be long, array given in %s on line %d +bool(false) diff --git a/ext/standard/tests/general_functions/proc_nice_variation2.phpt b/ext/standard/tests/general_functions/proc_nice_variation2.phpt new file mode 100644 index 0000000000..620fe91447 --- /dev/null +++ b/ext/standard/tests/general_functions/proc_nice_variation2.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test function proc_nice() by substituting argument 1 with boolean values. +--CREDITS-- +Italian PHP TestFest 2009 Cesena 19-20-21 june +Fabio Fabbrucci (fabbrucci@grupporetina.com) +Michele Orselli (mo@ideato.it) +Simone Gentili (sensorario@gmail.com) +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with boolean values ***\n"; + + + +$variation_array = array( + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + ); + + +foreach ( $variation_array as $var ) { + var_dump(proc_nice( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with boolean values *** +bool(true) +bool(true) +bool(true) +bool(true) diff --git a/ext/standard/tests/general_functions/proc_nice_variation5.phpt b/ext/standard/tests/general_functions/proc_nice_variation5.phpt new file mode 100644 index 0000000000..d8325106ba --- /dev/null +++ b/ext/standard/tests/general_functions/proc_nice_variation5.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test function proc_nice() by substituting argument 1 with int values. +--CREDITS-- +Italian PHP TestFest 2009 Cesena 19-20-21 june +Fabio Fabbrucci (fabbrucci@grupporetina.com) +Michele Orselli (mo@ideato.it) +Simone Gentili (sensorario@gmail.com) +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with int values ***\n"; + + + +$variation_array = array ( + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -2345, + ); + + +foreach ( $variation_array as $var ) { + var_dump(proc_nice( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with int values *** +bool(true) +bool(true) +bool(true) + +Warning: proc_nice(): Only a super user may attempt to increase the priority of a process in %s on line %d +bool(false) diff --git a/ext/standard/tests/general_functions/proc_nice_variation6.phpt b/ext/standard/tests/general_functions/proc_nice_variation6.phpt new file mode 100644 index 0000000000..b4babd5930 --- /dev/null +++ b/ext/standard/tests/general_functions/proc_nice_variation6.phpt @@ -0,0 +1,52 @@ +--TEST-- +Test function proc_nice() by substituting argument 1 with object values. +--CREDITS-- +Italian PHP TestFest 2009 Cesena 19-20-21 june +Fabio Fabbrucci (fabbrucci@grupporetina.com) +Michele Orselli (mo@ideato.it) +Simone Gentili (sensorario@gmail.com) +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with object values ***\n"; + + + +function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) { + if (error_reporting() != 0) { + // report non-silenced errors + echo "Error: $err_no - $err_msg, $filename($linenum)\n"; + } +} +set_error_handler('test_error_handler'); + + + +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +$variation_array = array( + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + ); + + +foreach ( $variation_array as $var ) { + var_dump(proc_nice( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with object values *** +Error: 2 - proc_nice() expects parameter 1 to be long, object given, %s(%d) +bool(false) +Error: 2 - proc_nice() expects parameter 1 to be long, object given, %s(%d) +bool(false) diff --git a/ext/standard/tests/misc/time_sleep_until_basic.phpt b/ext/standard/tests/misc/time_sleep_until_basic.phpt new file mode 100644 index 0000000000..7f2f32d243 --- /dev/null +++ b/ext/standard/tests/misc/time_sleep_until_basic.phpt @@ -0,0 +1,14 @@ +--TEST-- +time_sleep_until() function - basic test for time_sleep_until() +--CREDITS-- +Manuel Baldassarri mb@ideato.it +Michele Orselli mo@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + $time = time() + 2; + time_sleep_until( $time ); + var_dump( time() >= $time ); +?> +--EXPECT-- +bool(true) diff --git a/ext/standard/tests/misc/time_sleep_until_error1.phpt b/ext/standard/tests/misc/time_sleep_until_error1.phpt new file mode 100644 index 0000000000..9752fd70e3 --- /dev/null +++ b/ext/standard/tests/misc/time_sleep_until_error1.phpt @@ -0,0 +1,13 @@ +--TEST-- +time_sleep_until() function - error test for time_sleep_until() +--CREDITS-- +Fabio Fabbrucci fabbrucci@grupporetina.com +Danilo Sanchi sanchi@grupporetina.com +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + var_dump(time_sleep_until(time()-1)); +?> +--EXPECTF-- +Warning: time_sleep_until(): Sleep until to time is less than current time in %s on line 2 +bool(false) diff --git a/ext/standard/tests/misc/time_sleep_until_error3.phpt b/ext/standard/tests/misc/time_sleep_until_error3.phpt new file mode 100644 index 0000000000..64489618ae --- /dev/null +++ b/ext/standard/tests/misc/time_sleep_until_error3.phpt @@ -0,0 +1,12 @@ +--TEST-- +time_sleep_until() function - error test for time_sleep_until() +--CREDITS-- +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + var_dump(time_sleep_until()); +?> +--EXPECTF-- +Warning: time_sleep_until() expects exactly 1 parameter, 0 given in %s on line 2 +NULL diff --git a/ext/standard/tests/php_ini_loaded_file.phpt b/ext/standard/tests/php_ini_loaded_file.phpt new file mode 100644 index 0000000000..ab26953eac --- /dev/null +++ b/ext/standard/tests/php_ini_loaded_file.phpt @@ -0,0 +1,13 @@ +--TEST-- +Check the php_ini_loaded_file() function. No file is loaded in test, so false ins returned +--CREDITS-- +Sebastian Schürmann +sschuermann@chip.de +Testfest 2009 Munich +--FILE-- +<?php +var_dump(php_ini_loaded_file()); +?> +--EXPECT-- +bool(false) + diff --git a/ext/standard/tests/php_logo_guid.phpt b/ext/standard/tests/php_logo_guid.phpt new file mode 100644 index 0000000000..c644b2893b --- /dev/null +++ b/ext/standard/tests/php_logo_guid.phpt @@ -0,0 +1,13 @@ +--TEST-- +Check the output of the php_logo_guid() function +--CREDITS-- +Sebastian Schürmann +sschuermann@chip.de +Testfest 2009 Munich +--FILE-- +<?php +echo php_logo_guid(); +?> +--EXPECT-- +PHPE9568F34-D428-11d2-A769-00AA001ACF42 + diff --git a/ext/standard/tests/php_real_logo_guid.phpt b/ext/standard/tests/php_real_logo_guid.phpt new file mode 100644 index 0000000000..a9fa7d35d5 --- /dev/null +++ b/ext/standard/tests/php_real_logo_guid.phpt @@ -0,0 +1,12 @@ +--TEST-- +Testing the undocumented function php_real_logo_guid() +--CREDITS-- +Sebastian Schürmann +sschuermann@chip.de +Testfest 2009 Munich +--FILE-- +<?php +echo php_real_logo_guid(); +?> +--EXPECT-- +PHPE9568F34-D428-11d2-A769-00AA001ACF42 diff --git a/ext/standard/tests/strings/show_source_basic.phpt b/ext/standard/tests/strings/show_source_basic.phpt new file mode 100644 index 0000000000..cfd998fe96 --- /dev/null +++ b/ext/standard/tests/strings/show_source_basic.phpt @@ -0,0 +1,27 @@ +--TEST-- +Test function show_source() by calling it with its expected arguments, more test for highlight_file() +--CREDITS-- +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php +echo "*** Test by calling method or function with its expected arguments ***\n"; +$foo = 'bar'; +$baz = "something ".$foo."\n"; + +if ( $foo == 'bar' ) +{ + $baz = 'baz'; +} + + /* some code here */ + +show_source(__FILE__); + +?> +--EXPECTF-- +*** Test by calling method or function with its expected arguments *** +<code><span style="color: #000000"> +<span style="color: #0000BB"><?php<br /></span><span style="color: #007700">echo </span><span style="color: #DD0000">"*** Test by calling method or function with its expected arguments ***\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$foo </span><span style="color: #007700">= </span><span style="color: #DD0000">'bar'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$baz </span><span style="color: #007700">= </span><span style="color: #DD0000">"something "</span><span style="color: #007700">.</span><span style="color: #0000BB">$foo</span><span style="color: #007700">.</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br />if ( </span><span style="color: #0000BB">$foo </span><span style="color: #007700">== </span><span style="color: #DD0000">'bar' </span><span style="color: #007700">) <br />{<br /> </span><span style="color: #0000BB">$baz </span><span style="color: #007700">= </span><span style="color: #DD0000">'baz'</span><span style="color: #007700">;<br />}<br /><br /> </span><span style="color: #FF8000">/* some code here */<br /> <br /></span><span style="color: #0000BB">show_source</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?><br /></span> +</span> +</code> diff --git a/ext/standard/tests/strings/show_source_variation1.phpt b/ext/standard/tests/strings/show_source_variation1.phpt new file mode 100644 index 0000000000..a9993ed457 --- /dev/null +++ b/ext/standard/tests/strings/show_source_variation1.phpt @@ -0,0 +1,28 @@ +--TEST-- +Test function show_source() by calling it with its expected arguments and php output, more test for highlight_file() +--CREDITS-- +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php +echo "*** Test by calling method or function with its expected arguments and php output ***\n"; +$foo = 'bar'; +$baz = "something ".$foo."\n"; + +if ( $foo == 'bar' ) +{ + $baz = "baz\n"; +} + + /* some code here */ +echo $baz; +show_source(__FILE__); +echo $foo; +?> +--EXPECTF-- +*** Test by calling method or function with its expected arguments and php output *** +baz +<code><span style="color: #000000"> +<span style="color: #0000BB"><?php<br /></span><span style="color: #007700">echo </span><span style="color: #DD0000">"*** Test by calling method or function with its expected arguments and php output ***\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$foo </span><span style="color: #007700">= </span><span style="color: #DD0000">'bar'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$baz </span><span style="color: #007700">= </span><span style="color: #DD0000">"something "</span><span style="color: #007700">.</span><span style="color: #0000BB">$foo</span><span style="color: #007700">.</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br />if ( </span><span style="color: #0000BB">$foo </span><span style="color: #007700">== </span><span style="color: #DD0000">'bar' </span><span style="color: #007700">) <br />{<br /> </span><span style="color: #0000BB">$baz </span><span style="color: #007700">= </span><span style="color: #DD0000">"baz\n"</span><span style="color: #007700">;<br />}<br /><br /> </span><span style="color: #FF8000">/* some code here */<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">$baz</span><span style="color: #007700">; <br /></span><span style="color: #0000BB">show_source</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">$foo</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?><br /></span> +</span> +</code>bar diff --git a/ext/standard/tests/strings/show_source_variation2.phpt b/ext/standard/tests/strings/show_source_variation2.phpt new file mode 100644 index 0000000000..06ef66c2d2 --- /dev/null +++ b/ext/standard/tests/strings/show_source_variation2.phpt @@ -0,0 +1,27 @@ +--TEST-- +Test function show_source() by calling it with its expected arguments and output to variable, more test for highlight_file() +--CREDITS-- +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php +echo "*** Test by calling method or function with its expected arguments and output to variable ***\n"; +$foo = 'bar'; +$baz = "something ".$foo."\n"; + +if ( $foo == 'bar' ) +{ + $baz = "baz\n"; +} + + /* some code here */ +$source = show_source(__FILE__, true); + +var_dump($source); +?> +--EXPECTF-- +*** Test by calling method or function with its expected arguments and output to variable *** +string(1987) "<code><span style="color: #000000"> +<span style="color: #0000BB"><?php<br /></span><span style="color: #007700">echo </span><span style="color: #DD0000">"*** Test by calling method or function with its expected arguments and output to variable ***\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$foo </span><span style="color: #007700">= </span><span style="color: #DD0000">'bar'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$baz </span><span style="color: #007700">= </span><span style="color: #DD0000">"something "</span><span style="color: #007700">.</span><span style="color: #0000BB">$foo</span><span style="color: #007700">.</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br />if ( </span><span style="color: #0000BB">$foo </span><span style="color: #007700">== </span><span style="color: #DD0000">'bar' </span><span style="color: #007700">) <br />{<br /> </span><span style="color: #0000BB">$baz </span><span style="color: #007700">= </span><span style="color: #DD0000">"baz\n"</span><span style="color: #007700">;<br />}<br /><br /> </span><span style="color: #FF8000">/* some code here */ <br /></span><span style="color: #0000BB">$source </span><span style="color: #007700">= </span><span style="color: #0000BB">show_source</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">, </span><span style="color: #0000BB">true</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$source</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?><br /></span> +</span> +</code>" diff --git a/ext/standard/tests/url/get_headers_error_001.phpt b/ext/standard/tests/url/get_headers_error_001.phpt new file mode 100644 index 0000000000..8d5fd11f60 --- /dev/null +++ b/ext/standard/tests/url/get_headers_error_001.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test get_headers() function : error conditions - wrong number of args +--CREDITS-- +June Henriksen <juneih@redpill-linpro.com> +#PHPTestFest2009 Norway 2009-06-09 \o/ +--FILE-- +<?php +/* Prototype : proto array get_headers(string url[, int format]) + * Description: Fetches all the headers sent by the server in response to a HTTP request + * Source code: ext/standard/url.c + * Alias to functions: + */ + +echo "*** Testing get_headers() : error conditions ***\n"; + +// Zero arguments +echo "\n-- Testing get_headers() function with Zero arguments --\n"; +var_dump( get_headers() ); + +//Test get_headers with one more than the expected number of arguments +echo "\n-- Testing get_headers() function with more than expected no. of arguments --\n"; +$url = 'string_val'; +$format = 1; +$extra_arg = 10; +var_dump( get_headers($url, $format, $extra_arg) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing get_headers() : error conditions *** + +-- Testing get_headers() function with Zero arguments -- + +Warning: get_headers() expects at least 1 parameter, 0 given in %s on line 12 +NULL + +-- Testing get_headers() function with more than expected no. of arguments -- + +Warning: get_headers() expects at most 2 parameters, 3 given in %s on line 19 +NULL +Done + + + diff --git a/ext/standard/tests/zend_logo_guid.phpt b/ext/standard/tests/zend_logo_guid.phpt new file mode 100644 index 0000000000..d26ed45e9e --- /dev/null +++ b/ext/standard/tests/zend_logo_guid.phpt @@ -0,0 +1,12 @@ +--TEST-- +Checking the zend_logo_guid() functio +--CREDITS-- +Sebastian Schürmann +sschuermann@chip.de +Testfest 2009 Munich +--FILE-- +<?php +echo zend_logo_guid(); +?> +--EXPECT-- +PHPE9568F35-D428-11d2-A769-00AA001ACF42 diff --git a/tests/basic/php_egg_logo_guid.phpt b/tests/basic/php_egg_logo_guid.phpt new file mode 100644 index 0000000000..b3c5d7bdfd --- /dev/null +++ b/tests/basic/php_egg_logo_guid.phpt @@ -0,0 +1,13 @@ +--TEST-- +Testing php_egg_logo_guid() function +--FILE-- +<?php +echo php_egg_logo_guid(); +?> +--EXPECT-- +PHPE9568F36-D428-11d2-A769-00AA001ACF42 + +--CREDITS-- +Jason Easter <easter@phpug-wuerzburg.de> +PHPUG Würzburg <phpug-wuerzburg.de> +Testfest 2009 2009-06-20
\ No newline at end of file diff --git a/tests/basic/php_logo_guid.phpt b/tests/basic/php_logo_guid.phpt new file mode 100644 index 0000000000..b5724a96ab --- /dev/null +++ b/tests/basic/php_logo_guid.phpt @@ -0,0 +1,10 @@ +--TEST-- +Testing php_logo_guid() function +--FILE-- +<?php +echo php_logo_guid(); +?> +--EXPECT-- +PHPE9568F34-D428-11d2-A769-00AA001ACF42 +--CREDITS-- +Testfest 2009 2009-06-20
\ No newline at end of file diff --git a/tests/basic/php_real_logo_guid.phpt b/tests/basic/php_real_logo_guid.phpt new file mode 100644 index 0000000000..2b9003a350 --- /dev/null +++ b/tests/basic/php_real_logo_guid.phpt @@ -0,0 +1,12 @@ +--TEST-- +Testing php_real_logo_guid() function +--FILE-- +<?php +echo php_real_logo_guid(); +?> +--EXPECT-- +PHPE9568F34-D428-11d2-A769-00AA001ACF42 +--CREDITS-- +Jason Easter <easter@phpug-wuerzburg.de> +PHPUG Würzburg <phpug-wuerzburg.de> +Testfest 2009 2009-06-20
\ No newline at end of file diff --git a/tests/basic/zend_logo_guid.phpt b/tests/basic/zend_logo_guid.phpt new file mode 100644 index 0000000000..23ca0165ae --- /dev/null +++ b/tests/basic/zend_logo_guid.phpt @@ -0,0 +1,13 @@ +--TEST-- +Testing zend_logo_guid() function +--FILE-- +<?php +echo zend_logo_guid(); +?> +--EXPECT-- +PHPE9568F35-D428-11d2-A769-00AA001ACF42 + +--CREDITS-- +Jason Easter <easter@phpug-wuerzburg.de> +PHPUG Würzburg <phpug-wuerzburg.de> +Testfest 2009 2009-06-20
\ No newline at end of file diff --git a/tests/func/time_sleep_until_basic.phpt b/tests/func/time_sleep_until_basic.phpt new file mode 100644 index 0000000000..def114cc48 --- /dev/null +++ b/tests/func/time_sleep_until_basic.phpt @@ -0,0 +1,15 @@ +--TEST-- +time_sleep_until — Make the script sleep until the specified time +--CREDITS-- +Àlex Corretgé - alex@corretge.cat +--FILE-- +<?php + +$timeA = time(); +time_sleep_until($timeA+3); +$timeB = time(); +echo ($timeB - $timeA) . " seconds."; + +?> +--EXPECT-- +3 seconds.
\ No newline at end of file diff --git a/tests/func/time_sleep_until_error2.phpt b/tests/func/time_sleep_until_error2.phpt new file mode 100644 index 0000000000..bb999b9bef --- /dev/null +++ b/tests/func/time_sleep_until_error2.phpt @@ -0,0 +1,16 @@ +--TEST-- +time_sleep_until — Make the script sleep until the specified time +--CREDITS-- +Àlex Corretgé - alex@corretge.cat +--FILE-- +<?php + +$timeA = time(); +time_sleep_until($timeA-3); +$timeB = time(); +echo ($timeB - $timeA) . " seconds."; + +?> +--EXPECTF-- +Warning: time_sleep_until(): Sleep until to time is less than current time in %s.php on line %d +0 seconds.
\ No newline at end of file |