Skip to content

Commit d67bb73

Browse files
committed
Split tests for invalid arguments out into their own files, and ignore them for HHVM
1 parent 1d8362c commit d67bb73

12 files changed

+152
-47
lines changed

tests/bson/bson-binary-001.phpt

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@ foreach($types as $type) {
2626
$tests[] = array("binary" => $binary);
2727
}
2828

29-
throws(function() use($classname) {
30-
$b = new $classname("random binary data without type");
31-
echo "FAIL: Constructed BSON\Binary without type!\n";
32-
}, "MongoDB\\Driver\\Exception\\InvalidArgumentException");
33-
34-
35-
3629
foreach($tests as $n => $test) {
3730
$s = fromPHP($test);
3831
echo "Test#{$n} ", $json = toJSON($s), "\n";
@@ -41,9 +34,6 @@ foreach($tests as $n => $test) {
4134
var_dump(toJSON(fromPHP($test)), toJSON(fromPHP($testagain)));
4235
var_dump((object)$test == (object)$testagain);
4336
}
44-
45-
$binary->getData(2);
46-
$binary->getType(2);
4737
?>
4838
===DONE===
4939
<?php exit(0); ?>
@@ -64,7 +54,6 @@ bool(true)
6454
bool(true)
6555
bool(true)
6656
bool(true)
67-
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
6857
Test#0 { "binary" : { "$type" : "00", "$binary" : "cmFuZG9tIGJpbmFyeSBkYXRh" } }
6958
string(73) "{ "binary" : { "$type" : "00", "$binary" : "cmFuZG9tIGJpbmFyeSBkYXRh" } }"
7059
string(73) "{ "binary" : { "$type" : "00", "$binary" : "cmFuZG9tIGJpbmFyeSBkYXRh" } }"
@@ -97,8 +86,4 @@ Test#7 { "binary" : { "$type" : "85", "$binary" : "cmFuZG9tIGJpbmFyeSBkYXRh" } }
9786
string(73) "{ "binary" : { "$type" : "85", "$binary" : "cmFuZG9tIGJpbmFyeSBkYXRh" } }"
9887
string(73) "{ "binary" : { "$type" : "85", "$binary" : "cmFuZG9tIGJpbmFyeSBkYXRh" } }"
9988
bool(true)
100-
101-
Warning: %s\Binary::getData() expects exactly 0 parameters, 1 given in %s on line %d
102-
103-
Warning: %s\Binary::getType() expects exactly 0 parameters, 1 given in %s on line %d
10489
===DONE===

tests/bson/bson-binary_error-001.phpt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--TEST--
2+
BSON BSON\Binary #001 error
3+
--SKIPIF--
4+
<?php if (defined("HHVM_VERSION_ID")) exit("skip HHVM handles parameter parsing differently"); ?>
5+
<?php require __DIR__ . "/../utils/basic-skipif.inc"?>
6+
--FILE--
7+
<?php
8+
require_once __DIR__ . "/../utils/basic.inc";
9+
10+
$classname = BSON_NAMESPACE . "\\Binary";
11+
12+
$binary = new $classname("random binary data", $classname::TYPE_GENERIC);
13+
14+
throws(function() use($classname) {
15+
$b = new $classname("random binary data without type");
16+
echo "FAIL: Constructed BSON\Binary without type!\n";
17+
}, "MongoDB\\Driver\\Exception\\InvalidArgumentException");
18+
19+
$binary->getData(2);
20+
$binary->getType(2);
21+
?>
22+
===DONE===
23+
<?php exit(0); ?>
24+
--EXPECTF--
25+
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
26+
27+
Warning: %s\Binary::getData() expects exactly 0 parameters, 1 given in %s on line %d
28+
29+
Warning: %s\Binary::getType() expects exactly 0 parameters, 1 given in %s on line %d
30+
===DONE===
31+

tests/bson/bson-javascript-001.phpt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ $tests = array(
1515
array("jswscope" => $jswscope),
1616
);
1717

18-
throws(function() use($classname) {
19-
$j = new $classname;
20-
}, "MongoDB\\Driver\\Exception\\InvalidArgumentException");
21-
2218
foreach($tests as $n => $test) {
2319
echo "Test#{$n}", "\n";
2420
$s = fromPHP($test);
@@ -31,7 +27,6 @@ foreach($tests as $n => $test) {
3127
===DONE===
3228
<?php exit(0); ?>
3329
--EXPECTF--
34-
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
3530
Test#0
3631
bool(true)
3732
bool(true)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
--TEST--
2+
BSON BSON\Javascript #001 error
3+
--SKIPIF--
4+
<?php if (defined("HHVM_VERSION_ID")) exit("skip HHVM handles parameter parsing differently"); ?>
5+
<?php require __DIR__ . "/../utils/basic-skipif.inc"?>
6+
--FILE--
7+
<?php
8+
require_once __DIR__ . "/../utils/basic.inc";
9+
10+
$classname = BSON_NAMESPACE . "\\Javascript";
11+
12+
$js = new $classname("function foo(bar) {var baz = bar; var bar = foo; return bar; }");
13+
$jswscope = new $classname("function foo(bar) {var baz = bar; var bar = foo; return bar; }", array("foo" => 42));
14+
$tests = array(
15+
array("js" => $js),
16+
array("jswscope" => $jswscope),
17+
);
18+
19+
throws(function() use($classname) {
20+
$j = new $classname;
21+
}, "MongoDB\\Driver\\Exception\\InvalidArgumentException");
22+
?>
23+
===DONE===
24+
<?php exit(0); ?>
25+
--EXPECTF--
26+
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
27+
===DONE===

tests/bson/bson-objectid-001.phpt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ $id = new $classname("-3e28b650640fd3162152da1");
5353
throws(function() use($classname) {
5454
$id = new $classname(" 3e28b650640fd3162152da1");
5555
}, "MongoDB\\Driver\\Exception\\InvalidArgumentException");
56-
throws(function() use($classname) {
57-
$id = new $classname(new stdclass);
58-
}, "MongoDB\\Driver\\Exception\\InvalidArgumentException");
5956

6057

6158

@@ -90,6 +87,5 @@ OK: Got MongoDB\Driver\Exception\InvalidArgumentException
9087
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
9188
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
9289
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
93-
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
9490
OK: Got E_WARNING
9591
===DONE===
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
BSON BSON\ObjectID #001 error
3+
--SKIPIF--
4+
<?php if (defined("HHVM_VERSION_ID")) exit("skip HHVM handles parameter parsing differently"); ?>
5+
<?php require __DIR__ . "/../utils/basic-skipif.inc"?>
6+
--FILE--
7+
<?php
8+
require_once __DIR__ . "/../utils/basic.inc";
9+
10+
$classname = BSON_NAMESPACE . "\\ObjectID";
11+
throws(function() use($classname) {
12+
$id = new $classname(new stdclass);
13+
}, "MongoDB\\Driver\\Exception\\InvalidArgumentException");
14+
?>
15+
===DONE===
16+
<?php exit(0); ?>
17+
--EXPECTF--
18+
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
19+
===DONE===
20+

tests/bson/bson-regex-001.phpt

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ $tests = array(
1717
array("regex" => $regexp),
1818
);
1919

20-
throws(function() use($classname) {
21-
$regexp = new $classname;
22-
}, "MongoDB\\Driver\\Exception\\InvalidArgumentException");
23-
24-
2520
foreach($tests as $n => $test) {
2621
$s = fromPHP($test);
2722
echo "Test#{$n} ", $json = toJSON($s), "\n";
@@ -30,23 +25,15 @@ foreach($tests as $n => $test) {
3025
var_dump(toJSON(fromPHP($test)), toJSON(fromPHP($testagain)));
3126
var_dump((object)$test == (object)$testagain);
3227
}
33-
34-
$regexp->getPattern(true);
35-
$regexp->getFlags(true);
3628
?>
3729
===DONE===
3830
<?php exit(0); ?>
3931
--EXPECTF--
4032
Pattern: regexp
4133
Flags: i
4234
String representation: /regexp/i
43-
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
4435
Test#0 { "regex" : { "$regex" : "regexp", "$options" : "i" } }
4536
string(55) "{ "regex" : { "$regex" : "regexp", "$options" : "i" } }"
4637
string(55) "{ "regex" : { "$regex" : "regexp", "$options" : "i" } }"
4738
bool(true)
48-
49-
Warning: %s\Regex::getPattern() expects exactly 0 parameters, 1 given in %s on line %d
50-
51-
Warning: %s\Regex::getFlags() expects exactly 0 parameters, 1 given in %s on line %d
5239
===DONE===

tests/bson/bson-regex_error-001.phpt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
BSON BSON\Regex #001 error
3+
--SKIPIF--
4+
<?php if (defined("HHVM_VERSION_ID")) exit("skip HHVM handles parameter parsing differently"); ?>
5+
<?php require __DIR__ . "/../utils/basic-skipif.inc"?>
6+
--FILE--
7+
<?php
8+
require_once __DIR__ . "/../utils/basic.inc";
9+
10+
$classname = BSON_NAMESPACE . "\\Regex";
11+
$regexp = new $classname("regexp", "i");
12+
13+
throws(function() use($classname) {
14+
$regexp = new $classname;
15+
}, "MongoDB\\Driver\\Exception\\InvalidArgumentException");
16+
17+
$regexp->getPattern(true);
18+
$regexp->getFlags(true);
19+
?>
20+
===DONE===
21+
<?php exit(0); ?>
22+
--EXPECTF--
23+
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
24+
25+
Warning: %s\Regex::getPattern() expects exactly 0 parameters, 1 given in %s on line %d
26+
27+
Warning: %s\Regex::getFlags() expects exactly 0 parameters, 1 given in %s on line %d
28+
===DONE===
29+

tests/bson/bson-timestamp-001.phpt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ $tests = array(
1212
array("timestamp" => $timestamp),
1313
);
1414

15-
throws(function() use($classname) {
16-
$s = new $classname;
17-
}, "MongoDB\\Driver\\Exception\\InvalidArgumentException");
18-
1915
$s = new $classname(1234, 5678);
2016
echo $s, "\n";
2117

@@ -31,7 +27,6 @@ foreach($tests as $n => $test) {
3127
===DONE===
3228
<?php exit(0); ?>
3329
--EXPECTF--
34-
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
3530
[1234:5678]
3631
Test#0 { "timestamp" : { "$timestamp" : { "t" : 5678, "i" : 1234 } } }
3732
string(63) "{ "timestamp" : { "$timestamp" : { "t" : 5678, "i" : 1234 } } }"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
BSON BSON\Timestamp #001 error
3+
--SKIPIF--
4+
<?php if (defined("HHVM_VERSION_ID")) exit("skip HHVM handles parameter parsing differently"); ?>
5+
<?php require __DIR__ . "/../utils/basic-skipif.inc"?>
6+
--FILE--
7+
<?php
8+
require_once __DIR__ . "/../utils/basic.inc";
9+
10+
$classname = BSON_NAMESPACE . "\\Timestamp";
11+
12+
throws(function() use($classname) {
13+
$s = new $classname;
14+
}, "MongoDB\\Driver\\Exception\\InvalidArgumentException");
15+
?>
16+
===DONE===
17+
<?php exit(0); ?>
18+
--EXPECTF--
19+
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
20+
===DONE===
21+

0 commit comments

Comments
 (0)