Revert "remove files after run"
[phpt.git] / tests / CodeRunner / casts-stdin-to-string.phpt
blobbe5ff5f9b9021492b8d4e744376f1a0b9184ce54
1 --TEST--
2 If $stdin property is not null, it will be cast to string prior to being passed in
3 --ARGS--
4 --FILE--
5 <?php
7 require_once dirname(__FILE__) . '/../_setup.inc';
9 $filename = dirname(__FILE__) . '/foobar.php';
10 $code = '<?php
11 $fp = fopen("php://stdin", "r");
12 echo fread($fp, 8192);
13 fclose($fp);
14 ?>';
15 file_put_contents($filename, $code);
17 class FoobarStdin {
18     private $message = '';
19     public function __construct() {
20         $this->message = 'Some Random Int Passed Through STDIN: ' . rand(100, 200);
21     }
22     public function __toString() {
23         return $this->message;
24     }
27 $message = new FoobarStdin();
29 $runner = new PHPT_CodeRunner();
30 $runner->stdin = $message;
31 $result = $runner->run($filename);
33 assert('$result->output == (string)$message');
36 ===DONE===
37 --CLEAN--
38 <?php @unlink(dirname(__FILE__) . '/foobar.php'); ?>
39 --EXPECT--
40 ===DONE===