1--TEST--
2Test posix_ttyname() with wrong parameters
3--DESCRIPTION--
4Gets the absolute path to the current terminal device that is open on a given file descriptor.
5Source code: ext/posix/posix.c
6
7--CREDITS--
8Falko Menge, mail at falko-menge dot de
9PHP Testfest Berlin 2009-05-10
10--SKIPIF--
11<?php
12    if (!extension_loaded('posix')) {
13        die('SKIP - POSIX extension not available');
14    }
15    if (!extension_loaded('standard')) {
16        die('SKIP - Standard extension not available');
17    }
18?>
19--FILE--
20<?php
21
22var_dump(posix_ttyname(0)); // param not a resource
23
24$descriptors = [["pty"], ["pty"], ["pty"], ["pipe", "w"]];
25$pipes = [];
26$process = proc_open('echo "foo";', $descriptors, $pipes);
27
28try {
29    var_dump(posix_ttyname($process)); // wrong resource type
30} catch (TypeError $e) {
31    echo $e->getMessage(), "\n";
32}
33?>
34--EXPECT--
35bool(false)
36posix_ttyname(): supplied resource is not a valid stream resource
37