xref: /PHP-7.4/ext/spl/tests/bug80933.phpt (revision 976e71a2)
1--TEST--
2Bug #80933 (SplFileObject::DROP_NEW_LINE is broken for NUL and CR)
3--FILE--
4<?php
5$lines = [
6    "Lorem ipsum \0 dolor sit amet", // string with NUL
7    "Lorem ipsum \r dolor sit amet", // string with CR
8];
9foreach ($lines as $line) {
10    $temp = new SplTempFileObject();
11    $temp->fwrite($line);
12
13    $temp->rewind();
14    $read = $temp->fgets();
15    var_dump($line === $read);
16
17    $temp->rewind();
18    $temp->setFlags(SplFileObject::DROP_NEW_LINE);
19    $read = $temp->fgets();
20    var_dump($line === $read);
21}
22?>
23--EXPECT--
24bool(true)
25bool(true)
26bool(true)
27bool(true)
28