Skip to content

Commit

Permalink
Test fwrite and fread with both tmpfile() and fopen()
Browse files Browse the repository at this point in the history
  • Loading branch information
asgrim committed Oct 31, 2019
1 parent 7522109 commit 65c414d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.xml
Expand Up @@ -65,7 +65,8 @@
<file name="007-evaled-code-handled.phpt" role="test" />
<file name="008-class-with-no-constructor-call-handled.phpt" role="test" />
<file name="009-curl_exec.phpt" role="test" />
<file name="010-fwrite-fread.phpt" role="test" />
<file name="010-fwrite-fread-fopen.phpt" role="test" />
<file name="010-fwrite-fread-tmpfile.phpt" role="test" />
<file name="011-pdo-exec.phpt" role="test" />
<file name="011-pdo-query.phpt" role="test" />
<file name="011-pdostatement-execute.phpt" role="test" />
Expand Down
File renamed without changes.
38 changes: 38 additions & 0 deletions tests/010-fwrite-fread-tmpfile.phpt
@@ -0,0 +1,38 @@
--TEST--
Calls to fwrite and fread are logged
--SKIPIF--
<?php if (!extension_loaded("scoutapm")) die("skip scoutapm extension required."); ?>
--FILE--
<?php
$fh = fopen(tempnam(sys_get_temp_dir(), 'scoutapm-test'), 'w+');

fwrite($fh, "fread/fwrite test\n");
fseek($fh, 0);
echo fread($fh, 18);
fclose($fh);

$calls = scoutapm_get_calls();

var_dump($calls[0]['function']);
var_dump($calls[0]['argv']);

var_dump($calls[1]['function']);
var_dump($calls[1]['argv']);
?>
--EXPECTF--
fread/fwrite test
string(6) "fwrite"
array(2) {
[0]=>
resource(%d) of type (Unknown)
[1]=>
string(18) "fread/fwrite test
"
}
string(5) "fread"
array(2) {
[0]=>
string(24) "/tmp/scoutapm-test%s"
[1]=>
string(2) "w+"
}

0 comments on commit 65c414d

Please sign in to comment.