Skip to content

Commit ea25a9b

Browse files
Added tests contributions on spl_autoload and stream_context_set_option()
Thank you Jean-Marc Fontaine and Alter Way
1 parent 665ff34 commit ea25a9b

4 files changed

+94
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
spl_autoload_call() function - basic test for spl_autoload_call()
3+
--CREDITS--
4+
Jean-Marc Fontaine <jean-marc.fontaine@alterway.fr>
5+
# Alter Way Contribution Day 2011
6+
--FILE--
7+
<?php
8+
function customAutolader($class) {
9+
require_once __DIR__ . '/testclass.class.inc';
10+
}
11+
spl_autoload_register('customAutolader');
12+
13+
spl_autoload_call('TestClass');
14+
var_dump(class_exists('TestClass', false));
15+
?>
16+
--EXPECTF--
17+
%stestclass.class.inc
18+
bool(true)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
--TEST--
2+
stream_context_set_option() function - basic test for stream_context_set_option()
3+
--CREDITS--
4+
Jean-Marc Fontaine <jean-marc.fontaine@alterway.fr>
5+
# Alter Way Contribution Day 2011
6+
--FILE--
7+
<?php
8+
$context = stream_context_create();
9+
10+
// Single option
11+
var_dump(stream_context_set_option($context, 'http', 'method', 'POST'));
12+
13+
// Array of options
14+
$options = array(
15+
'http' => array(
16+
'protocol_version' => 1.1,
17+
'user_agent' => 'PHPT Agent',
18+
),
19+
);
20+
var_dump(stream_context_set_option($context, $options));
21+
22+
var_dump(stream_context_get_options($context));
23+
?>
24+
--EXPECT--
25+
bool(true)
26+
bool(true)
27+
array(1) {
28+
["http"]=>
29+
array(3) {
30+
["method"]=>
31+
string(4) "POST"
32+
["protocol_version"]=>
33+
float(1.1)
34+
["user_agent"]=>
35+
string(10) "PHPT Agent"
36+
}
37+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
stream_context_set_option() function - error : invalid argument
3+
--CREDITS--
4+
Jean-Marc Fontaine <jean-marc.fontaine@alterway.fr>
5+
# Alter Way Contribution Day 2011
6+
--FILE--
7+
<?php
8+
$context = stream_context_create();
9+
10+
// Single option
11+
var_dump(stream_context_set_option($context, 'http'));
12+
13+
// Array of options
14+
var_dump(stream_context_set_option($context, array(), 'foo', 'bar'));
15+
?>
16+
--EXPECTF--
17+
Warning: stream_context_set_option(): called with wrong number or type of parameters; please RTM in %s on line %d
18+
bool(false)
19+
20+
Warning: stream_context_set_option(): called with wrong number or type of parameters; please RTM in %s on line %d
21+
bool(false)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
stream_context_set_option() function - error : missing argument
3+
--CREDITS--
4+
Jean-Marc Fontaine <jean-marc.fontaine@alterway.fr>
5+
# Alter Way Contribution Day 2011
6+
--FILE--
7+
<?php
8+
var_dump(stream_context_set_option());
9+
10+
$context = stream_context_create();
11+
var_dump(stream_context_set_option($context));
12+
?>
13+
--EXPECTF--
14+
Warning: stream_context_set_option(): called with wrong number or type of parameters; please RTM in %s on line %d
15+
bool(false)
16+
17+
Warning: stream_context_set_option(): called with wrong number or type of parameters; please RTM in %s on line %d
18+
bool(false)

0 commit comments

Comments
 (0)