Skip to content

Commit 1d536fe

Browse files
committed
Clean up BSON error tests
1 parent 14d43f7 commit 1d536fe

6 files changed

+26
-37
lines changed

tests/bson/bson-binary_error-001.phpt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,20 @@ require_once __DIR__ . "/../utils/basic.inc";
1010
$classname = BSON_NAMESPACE . "\\Binary";
1111

1212
$binary = new $classname("random binary data", $classname::TYPE_GENERIC);
13+
$binary->getData(2);
14+
$binary->getType(2);
1315

1416
throws(function() use($classname) {
15-
$b = new $classname("random binary data without type");
16-
echo "FAIL: Constructed BSON\Binary without type!\n";
17+
new $classname("random binary data without type");
1718
}, "MongoDB\\Driver\\Exception\\InvalidArgumentException");
1819

19-
$binary->getData(2);
20-
$binary->getType(2);
2120
?>
2221
===DONE===
2322
<?php exit(0); ?>
2423
--EXPECTF--
25-
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
26-
2724
Warning: %s\Binary::getData() expects exactly 0 parameters, 1 given in %s on line %d
2825

2926
Warning: %s\Binary::getType() expects exactly 0 parameters, 1 given in %s on line %d
27+
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
3028
===DONE===
3129

tests/bson/bson-javascript_error-001.phpt

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,11 @@ BSON BSON\Javascript #001 error
77
<?php
88
require_once __DIR__ . "/../utils/basic.inc";
99

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;
10+
throws(function() {
11+
$classname = BSON_NAMESPACE . "\\Javascript";
12+
new $classname;
2113
}, "MongoDB\\Driver\\Exception\\InvalidArgumentException");
14+
2215
?>
2316
===DONE===
2417
<?php exit(0); ?>

tests/bson/bson-objectid_error-001.phpt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ BSON BSON\ObjectID #001 error
77
<?php
88
require_once __DIR__ . "/../utils/basic.inc";
99

10-
$classname = BSON_NAMESPACE . "\\ObjectID";
11-
throws(function() use($classname) {
12-
$id = new $classname(new stdclass);
10+
throws(function() {
11+
$classname = BSON_NAMESPACE . "\\ObjectID";
12+
new $classname(new stdclass);
1313
}, "MongoDB\\Driver\\Exception\\InvalidArgumentException");
14+
1415
?>
1516
===DONE===
1617
<?php exit(0); ?>

tests/bson/bson-regex_error-001.phpt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,21 @@ BSON BSON\Regex #001 error
88
require_once __DIR__ . "/../utils/basic.inc";
99

1010
$classname = BSON_NAMESPACE . "\\Regex";
11+
1112
$regexp = new $classname("regexp", "i");
13+
$regexp->getPattern(true);
14+
$regexp->getFlags(true);
1215

1316
throws(function() use($classname) {
14-
$regexp = new $classname;
17+
new $classname;
1518
}, "MongoDB\\Driver\\Exception\\InvalidArgumentException");
1619

17-
$regexp->getPattern(true);
18-
$regexp->getFlags(true);
1920
?>
2021
===DONE===
2122
<?php exit(0); ?>
2223
--EXPECTF--
23-
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
24-
2524
Warning: %s\Regex::getPattern() expects exactly 0 parameters, 1 given in %s on line %d
2625

2726
Warning: %s\Regex::getFlags() expects exactly 0 parameters, 1 given in %s on line %d
27+
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
2828
===DONE===
29-

tests/bson/bson-timestamp_error-001.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ BSON BSON\Timestamp #001 error
77
<?php
88
require_once __DIR__ . "/../utils/basic.inc";
99

10-
$classname = BSON_NAMESPACE . "\\Timestamp";
11-
12-
throws(function() use($classname) {
13-
$s = new $classname;
10+
throws(function() {
11+
$classname = BSON_NAMESPACE . "\\Timestamp";
12+
new $classname;
1413
}, "MongoDB\\Driver\\Exception\\InvalidArgumentException");
14+
1515
?>
1616
===DONE===
1717
<?php exit(0); ?>

tests/bson/bson-utcdatetime_error-001.phpt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,16 @@ BSON BSON\UTCDateTime #001 error
44
date.timezone=America/Los_Angeles
55
--SKIPIF--
66
<?php if (defined("HHVM_VERSION_ID")) exit("skip HHVM handles parameter parsing differently"); ?>
7-
<?php require __DIR__ . "/../utils/basic-skipif.inc"; CLEANUP(STANDALONE) ?>
7+
<?php require __DIR__ . "/../utils/basic-skipif.inc"?>
88
--FILE--
99
<?php
1010
require_once __DIR__ . "/../utils/basic.inc";
1111

12-
$manager = new MongoDB\Driver\Manager(STANDALONE);
13-
14-
$classname = BSON_NAMESPACE . "\\UTCDateTime";
15-
16-
throws(function() use($classname) {
17-
$d = new $classname;
12+
throws(function() {
13+
$classname = BSON_NAMESPACE . "\\UTCDateTime";
14+
new $classname;
1815
}, "MongoDB\\Driver\\Exception\\InvalidArgumentException");
16+
1917
?>
2018
===DONE===
2119
<?php exit(0); ?>

0 commit comments

Comments
 (0)