xref: /PHP-7.1/ext/spl/tests/fileobject_005.phpt (revision 113213f0)
1--TEST--
2SPL: SplFileObject truncate tests
3--CREDITS--
4Mark Ammann
5#Hackday Webtuesday 2008-05-24
6--FILE--
7<?php
8
9set_include_path(dirname(dirname(__FILE__)));
10
11$path = dirname(__FILE__).DIRECTORY_SEPARATOR.'fileobject_005.txt';
12touch($path);
13
14$fo = new SplFileObject('tests'.DIRECTORY_SEPARATOR.'fileobject_005.txt', 'w+', true);
15$fo->fwrite("blahlubba");
16var_dump($fo->ftruncate(4));
17
18$fo->rewind();
19var_dump($fo->fgets(8));
20
21$fo->rewind();
22$fo->fwrite("blahlubba");
23
24// This should throw a warning and return NULL since an argument is missing
25var_dump($fo->ftruncate());
26
27?>
28==DONE==
29--CLEAN--
30<?php
31$path = dirname(__FILE__).DIRECTORY_SEPARATOR.'fileobject_005.txt';
32unlink($path);
33?>
34--EXPECTF--
35bool(true)
36
37Warning: SplFileObject::fgets() expects exactly 0 parameters, 1 given in %s on line %d
38NULL
39
40Warning: SplFileObject::ftruncate() expects exactly 1 parameter, 0 given in %s on line %d
41NULL
42==DONE==
43