Annotation of embedaddon/php/ext/posix/tests/posix_ttyname_variation6.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test function posix_ttyname() by substituting argument 1 with object values.
3: --CREDITS--
4: Marco Fabbri mrfabbri@gmail.com
5: Francesco Fullone ff@ideato.it
6: #PHPTestFest Cesena Italia on 2009-06-20
7: --SKIPIF--
8: <?php
9: if (!extension_loaded('posix')) {
10: die('SKIP The posix extension is not loaded.');
11: }
12: ?>
13: --FILE--
14: <?php
15:
16:
17: echo "*** Test substituting argument 1 with object values ***\n";
18:
19:
20:
21: function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
22: if (error_reporting() != 0) {
23: // report non-silenced errors
24: echo "Error: $err_no - $err_msg, $filename($linenum)\n";
25: }
26: }
27: set_error_handler('test_error_handler');
28:
29:
30:
31: class classWithToString
32: {
33: public function __toString() {
34: return "Class A object";
35: }
36: }
37:
38: class classWithoutToString
39: {
40: }
41:
42: $variation_array = array(
43: 'instance of classWithToString' => new classWithToString(),
44: 'instance of classWithoutToString' => new classWithoutToString(),
45: );
46:
47:
48: foreach ( $variation_array as $var ) {
49: var_dump(posix_ttyname( $var ) );
50: }
51: ?>
52: --EXPECTF--
53: *** Test substituting argument 1 with object values ***
54: Error: 8 - Object of class classWithToString could not be converted to int, %s(%d)
55: bool(false)
56: Error: 8 - Object of class classWithoutToString could not be converted to int, %s(%d)
57: bool(false)
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>