1--TEST-- 2Test function getservbyport() by calling it more than or less than its expected arguments 3--DESCRIPTION-- 4Test function passing invalid port number and invalid protocol name 5--CREDITS-- 6Italian PHP TestFest 2009 Cesena 19-20-21 june 7Fabio Fabbrucci (fabbrucci@grupporetina.com) 8Michele Orselli (mo@ideato.it) 9Simone Gentili (sensorario@gmail.com) 10--SKIPIF-- 11<?php 12 if(in_array(PHP_OS_FAMILY, ['BSD', 'Darwin', 'Solaris', 'Linux'])){ 13 if (!file_exists("/etc/services")) die("skip reason: missing /etc/services"); 14 } 15?> 16--FILE-- 17<?php 18 var_dump(getservbyport( -1, "tcp" )); 19 var_dump(getservbyport( 80, "ppp" )); 20 var_dump(getservbyport( null, null)); 21 var_dump(getservbyport( array(), array())); 22 var_dump(getservbyport( array(80), array("tcp"))); 23 var_dump(getservbyport( array(2, 3), array("one"=>1, "two"=>2))); 24 var_dump(getservbyport( 2, 2)); 25 var_dump(getservbyport( "80", "tcp")); 26 var_dump(getservbyport( new stdClass(), new stdClass())); 27 28?> 29--EXPECTF-- 30bool(false) 31bool(false) 32bool(false) 33 34Warning: getservbyport() expects parameter 1 to be int, array given in %s on line %d 35NULL 36 37Warning: getservbyport() expects parameter 1 to be int, array given in %s on line %d 38NULL 39 40Warning: getservbyport() expects parameter 1 to be int, array given in %s on line %d 41NULL 42bool(false) 43string(%d) "%s" 44 45Warning: getservbyport() expects parameter 1 to be int, object given in %s on line %d 46NULL 47