File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / dir / scandir_error1.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 23:48:03 2012 UTC (12 years, 5 months ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17p0, v5_4_17, v5_3_10, HEAD
php

--TEST--
Test scandir() function : error conditions - Incorrect number of args
--FILE--
<?php
/* Prototype  : array scandir(string $dir [, int $sorting_order [, resource $context]])
 * Description: List files & directories inside the specified path 
 * Source code: ext/standard/dir.c
 */

/*
 * Pass incorrect number of arguments to scandir() to test behaviour
 */

echo "*** Testing scandir() : error conditions ***\n";

// Zero arguments
echo "\n-- Testing scandir() function with Zero arguments --\n";
var_dump( scandir() );

//Test scandir with one more than the expected number of arguments
echo "\n-- Testing scandir() function with more than expected no. of arguments --\n";
$dir = dirname(__FILE__) . '/scandir_error';
mkdir($dir);
$sorting_order = 10;
$context = stream_context_create();
$extra_arg = 10;
var_dump( scandir($dir, $sorting_order, $context, $extra_arg) );
?>
===DONE===
--CLEAN--
<?php
$directory = dirname(__FILE__) . '/scandir_error';
rmdir($directory);
?>
--EXPECTF--
*** Testing scandir() : error conditions ***

-- Testing scandir() function with Zero arguments --

Warning: scandir() expects at least 1 parameter, 0 given in %s on line %d
NULL

-- Testing scandir() function with more than expected no. of arguments --

Warning: scandir() expects at most 3 parameters, 4 given in %s on line %d
NULL
===DONE===

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>