Skip to content

Commit 30621b2

Browse files
committed
Add test for overwriting an existing stream context using libxml_set_streams_context
This was previously untested and the branch was not covered according to codecov.
1 parent ad29afd commit 30621b2

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
--TEST--
2+
Overwrite libxml_set_streams_context
3+
--EXTENSIONS--
4+
simplexml
5+
--FILE--
6+
<?php
7+
8+
// Based on bug54440.phpt
9+
10+
class TestWrapper {
11+
function stream_open($path, $mode, $options, &$opened_path)
12+
{
13+
print_r(stream_context_get_options($this->context));
14+
return false;
15+
}
16+
17+
function url_stat($path, $flags)
18+
{
19+
return array();
20+
}
21+
}
22+
23+
stream_wrapper_register("test", "TestWrapper");
24+
25+
$ctx1 = stream_context_create(array('test'=>array('test'=>'test 1')));
26+
$ctx2 = stream_context_create(array('test'=>array('test'=>'test 2')));
27+
28+
libxml_set_streams_context($ctx2);
29+
@simplexml_load_file('test://sdfsdf');
30+
31+
libxml_set_streams_context($ctx1);
32+
@simplexml_load_file('test://sdfsdf');
33+
?>
34+
--EXPECT--
35+
Array
36+
(
37+
[test] => Array
38+
(
39+
[test] => test 2
40+
)
41+
42+
)
43+
Array
44+
(
45+
[test] => Array
46+
(
47+
[test] => test 1
48+
)
49+
50+
)

0 commit comments

Comments
 (0)