Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit cc280df

Browse files
committed
wip tests
1 parent afca224 commit cc280df

File tree

4 files changed

+430
-0
lines changed

4 files changed

+430
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
--TEST--
2+
MongoDB\Driver\BulkWriteCommand::__construct() ordered=true
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
<?php skip_if_not_live(); ?>
6+
<?php skip_if_server_version('<', '8.0'); ?>
7+
<?php skip_if_not_clean(); ?>
8+
--FILE--
9+
<?php
10+
11+
require_once __DIR__ . "/../utils/basic.inc";
12+
13+
$manager = create_test_manager();
14+
15+
$bulk = new MongoDB\Driver\BulkWriteCommand(['ordered' => true]);
16+
$bulk->insertOne(NS, ['_id' => 1]);
17+
$bulk->insertOne(NS, ['_id' => 1]);
18+
$bulk->insertOne(NS, ['_id' => 2]);
19+
20+
try {
21+
$manager->executeBulkWriteCommand($bulk);
22+
} catch (MongoDB\Driver\Exception\BulkWriteCommandException $e) {
23+
printf("%s(%d): %s\n", get_class($e), $e->getCode(), $e->getMessage());
24+
25+
if ($prev = $e->getPrevious()) {
26+
printf("Previous %s(%d): %s\n", get_class($prev), $prev->getCode(), $prev->getMessage());
27+
}
28+
29+
var_dump($e->getBulkWriteCommandResult());
30+
}
31+
32+
?>
33+
===DONE===
34+
<?php exit(0); ?>
35+
--EXPECTF--
36+
object(MongoDB\Driver\BulkWriteCommandResult)#%d (%d) {
37+
["isAcknowledged"]=>
38+
bool(true)
39+
["insertedCount"]=>
40+
int(1)
41+
["matchedCount"]=>
42+
int(1)
43+
["modifiedCount"]=>
44+
int(1)
45+
["upsertedCount"]=>
46+
int(0)
47+
["deletedCount"]=>
48+
int(1)
49+
["insertResults"]=>
50+
NULL
51+
["updateResults"]=>
52+
NULL
53+
["deleteResults"]=>
54+
NULL
55+
["writeErrors"]=>
56+
NULL
57+
["writeConcernErrors"]=>
58+
NULL
59+
["errorReply"]=>
60+
NULL
61+
["server"]=>
62+
object(MongoDB\Driver\Server)#%d (%d) {%A
63+
}
64+
}
65+
===DONE===
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
--TEST--
2+
MongoDB\Driver\BulkWriteCommand::__construct() verboseResults=true
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
<?php skip_if_not_live(); ?>
6+
<?php skip_if_server_version('<', '8.0'); ?>
7+
<?php skip_if_not_clean(); ?>
8+
--FILE--
9+
<?php
10+
11+
require_once __DIR__ . "/../utils/basic.inc";
12+
13+
$manager = create_test_manager();
14+
15+
$bulk = new MongoDB\Driver\BulkWriteCommand(['verboseResults' => true]);
16+
$bulk->insertOne(NS, ['_id' => 1]);
17+
$bulk->updateOne(NS, ['_id' => 1], ['$set' => ['x' => 1]]);
18+
$bulk->deleteOne(NS, ['_id' => 1]);
19+
20+
$result = $manager->executeBulkWriteCommand($bulk);
21+
22+
var_dump($result);
23+
24+
?>
25+
===DONE===
26+
<?php exit(0); ?>
27+
--EXPECTF--
28+
object(MongoDB\Driver\BulkWriteCommandResult)#%d (%d) {
29+
["isAcknowledged"]=>
30+
bool(true)
31+
["insertedCount"]=>
32+
int(1)
33+
["matchedCount"]=>
34+
int(1)
35+
["modifiedCount"]=>
36+
int(1)
37+
["upsertedCount"]=>
38+
int(0)
39+
["deletedCount"]=>
40+
int(1)
41+
["insertResults"]=>
42+
object(MongoDB\BSON\Document)#%d (%d) {
43+
["data"]=>
44+
string(40) "HQAAAAMwABUAAAAQaW5zZXJ0ZWRJZAABAAAAAAA="
45+
["value"]=>
46+
object(stdClass)#%d (%d) {
47+
["0"]=>
48+
object(MongoDB\BSON\Document)#%d (%d) {
49+
["data"]=>
50+
string(28) "FQAAABBpbnNlcnRlZElkAAEAAAAA"
51+
["value"]=>
52+
object(stdClass)#%d (%d) {
53+
["insertedId"]=>
54+
int(1)
55+
}
56+
}
57+
}
58+
}
59+
["updateResults"]=>
60+
object(MongoDB\BSON\Document)#%d (%d) {
61+
["data"]=>
62+
string(80) "OgAAAAMxADIAAAASbWF0Y2hlZENvdW50AAEAAAAAAAAAEm1vZGlmaWVkQ291bnQAAQAAAAAAAAAAAA=="
63+
["value"]=>
64+
object(stdClass)#%d (%d) {
65+
["1"]=>
66+
object(MongoDB\BSON\Document)#%d (%d) {
67+
["data"]=>
68+
string(68) "MgAAABJtYXRjaGVkQ291bnQAAQAAAAAAAAASbW9kaWZpZWRDb3VudAABAAAAAAAAAAA="
69+
["value"]=>
70+
object(stdClass)#%d (%d) {
71+
["matchedCount"]=>
72+
int(1)
73+
["modifiedCount"]=>
74+
int(1)
75+
}
76+
}
77+
}
78+
}
79+
["deleteResults"]=>
80+
object(MongoDB\BSON\Document)#%d (%d) {
81+
["data"]=>
82+
string(48) "IwAAAAMyABsAAAASZGVsZXRlZENvdW50AAEAAAAAAAAAAAA="
83+
["value"]=>
84+
object(stdClass)#%d (%d) {
85+
["2"]=>
86+
object(MongoDB\BSON\Document)#%d (%d) {
87+
["data"]=>
88+
string(36) "GwAAABJkZWxldGVkQ291bnQAAQAAAAAAAAAA"
89+
["value"]=>
90+
object(stdClass)#%d (%d) {
91+
["deletedCount"]=>
92+
int(1)
93+
}
94+
}
95+
}
96+
}
97+
["writeErrors"]=>
98+
NULL
99+
["writeConcernErrors"]=>
100+
NULL
101+
["errorReply"]=>
102+
NULL
103+
["server"]=>
104+
object(MongoDB\Driver\Server)#%d (%d) {%A
105+
}
106+
}
107+
===DONE===
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
--TEST--
2+
MongoDB\Driver\BulkWriteCommand::__construct() verboseResults=false
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
<?php skip_if_not_live(); ?>
6+
<?php skip_if_server_version('<', '8.0'); ?>
7+
<?php skip_if_not_clean(); ?>
8+
--FILE--
9+
<?php
10+
11+
require_once __DIR__ . "/../utils/basic.inc";
12+
13+
$manager = create_test_manager();
14+
15+
$bulk = new MongoDB\Driver\BulkWriteCommand(['verboseResults' => false]);
16+
$bulk->insertOne(NS, ['_id' => 1]);
17+
$bulk->updateOne(NS, ['_id' => 1], ['$set' => ['x' => 1]]);
18+
$bulk->deleteOne(NS, ['_id' => 1]);
19+
20+
$result = $manager->executeBulkWriteCommand($bulk);
21+
22+
var_dump($result);
23+
24+
?>
25+
===DONE===
26+
<?php exit(0); ?>
27+
--EXPECTF--
28+
object(MongoDB\Driver\BulkWriteCommandResult)#%d (%d) {
29+
["isAcknowledged"]=>
30+
bool(true)
31+
["insertedCount"]=>
32+
int(1)
33+
["matchedCount"]=>
34+
int(1)
35+
["modifiedCount"]=>
36+
int(1)
37+
["upsertedCount"]=>
38+
int(0)
39+
["deletedCount"]=>
40+
int(1)
41+
["indexResults"]=>
42+
NULL
43+
["updateResults"]=>
44+
NULL
45+
["deleteResults"]=>
46+
NULL
47+
["writeErrors"]=>
48+
NULL
49+
["writeConcernErrors"]=>
50+
NULL
51+
["errorReply"]=>
52+
NULL
53+
["server"]=>
54+
object(MongoDB\Driver\Server)#%d (%d) {%A
55+
}
56+
}
57+
===DONE===

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /