~ubuntu-branches/ubuntu/quantal/php5/quantal

« back to all changes in this revision

Viewing changes to ext/standard/tests/file/tempnam_variation5.phpt

  • Committer: Bazaar Package Importer
  • Author(s): Sean Finney
  • Date: 2009-07-01 09:12:10 UTC
  • mto: (0.9.1) (1.1.17 upstream)
  • mto: This revision was merged to the branch mainline in revision 58.
  • Revision ID: james.westby@ubuntu.com-20090701091210-go0h6506p62on17r
Tags: upstream-5.3.0
ImportĀ upstreamĀ versionĀ 5.3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--TEST--
 
2
Test tempnam() function: usage variations - existing file
 
3
--SKIPIF--
 
4
<?php
 
5
if(substr(PHP_OS, 0, 3) == "WIN")
 
6
  die("skip Do not run on Windows");
 
7
?>
 
8
--FILE--
 
9
<?php
 
10
/* Prototype:  string tempnam ( string $dir, string $prefix );
 
11
   Description: Create file with unique file name.
 
12
*/
 
13
 
 
14
/* Passing an existing file as $prefix for tempnam() fn */
 
15
 
 
16
$file_path = dirname(__FILE__);
 
17
 
 
18
echo "*** Test tempnam() function: by passing an existing filename as prefix ***\n";
 
19
$dir_name = $file_path."/tempnam_variation6";
 
20
mkdir($dir_name);
 
21
$h = fopen($dir_name."/tempnam_variation6.tmp", "w");
 
22
 
 
23
for($i=1; $i<=3; $i++) {
 
24
  echo "-- Iteration $i --\n";
 
25
  $created_file = tempnam("$dir_name", "tempnam_variation6.tmp");
 
26
  
 
27
  if( file_exists($created_file) ) {
 
28
    echo "File name is => ";
 
29
    print($created_file);
 
30
    echo "\n";
 
31
  }
 
32
  else
 
33
    print("File is not created");
 
34
 
 
35
  unlink($created_file);
 
36
}
 
37
fclose($h);
 
38
unlink($dir_name."/tempnam_variation6.tmp");
 
39
rmdir($dir_name);
 
40
 
 
41
echo "\n*** Done ***\n";
 
42
?>
 
43
--EXPECTF--
 
44
*** Test tempnam() function: by passing an existing filename as prefix ***
 
45
-- Iteration 1 --
 
46
File name is => %stempnam_variation6%etempnam_variation6.tmp%s
 
47
-- Iteration 2 --
 
48
File name is => %stempnam_variation6%etempnam_variation6.tmp%s
 
49
-- Iteration 3 --
 
50
File name is => %stempnam_variation6%etempnam_variation6.tmp%s
 
51
 
 
52
*** Done ***