1--TEST--
2Test file_put_contents() function : variation - include path testing
3--CREDITS--
4Dave Kelsey <d_kelsey@uk.ibm.com>
5--FILE--
6<?php
7/* Prototype  : int file_put_contents(string file, mixed data [, int flags [, resource context]])
8 * Description: Write/Create a file with contents data and return the number of bytes written
9 * Source code: ext/standard/file.c
10 * Alias to functions:
11 */
12
13echo "*** Testing file_put_contents() : variation ***\n";
14
15require_once('fopen_include_path.inc');
16
17$thisTestDir = basename(__FILE__, ".php") . ".dir";
18mkdir($thisTestDir);
19chdir($thisTestDir);
20
21$filename = basename(__FILE__, ".php") . ".tmp";
22
23$newpath = create_include_path();
24set_include_path($newpath);
25runtest();
26
27$newpath = generate_next_path();
28set_include_path($newpath);
29runtest();
30
31teardown_include_path();
32restore_include_path();
33chdir("..");
34rmdir($thisTestDir);
35
36
37function runtest() {
38   global $filename;
39
40   //correct php53 behaviour is to ignore the FILE_USE_INCLUDE_PATH unless the file already exists
41   // in the include path. In this case it doesn't so the file should be written in the current dir.
42
43   file_put_contents($filename, (binary) "File in include path", FILE_USE_INCLUDE_PATH);
44   file_put_contents($filename, (binary) ". This was appended", FILE_USE_INCLUDE_PATH | FILE_APPEND);
45   $line = file_get_contents($filename);
46   echo "$line\n";
47   unlink($filename);
48}
49
50?>
51===DONE===
52--EXPECT--
53*** Testing file_put_contents() : variation ***
54File in include path. This was appended
55File in include path. This was appended
56===DONE===
57