xref: /PHP-7.4/ext/spl/tests/fileobject_005.phpt (revision 26dfce7f)
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(__DIR__));
10
11$path = __DIR__.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 = __DIR__.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