Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongo-php-library
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sinan
mongo-php-library
Commits
6afb08f4
Commit
6afb08f4
authored
6 years ago
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create collection before change stream tests
parent
a032bb3f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
22 deletions
+14
-22
DocumentationExamplesTest.php
tests/DocumentationExamplesTest.php
+1
-0
WatchFunctionalTest.php
tests/Operation/WatchFunctionalTest.php
+13
-22
No files found.
tests/DocumentationExamplesTest.php
View file @
6afb08f4
...
...
@@ -930,6 +930,7 @@ class DocumentationExamplesTest extends FunctionalTestCase
$db
=
new
Database
(
$this
->
manager
,
$this
->
getDatabaseName
());
$db
->
dropCollection
(
'inventory'
);
$db
->
createCollection
(
'inventory'
);
// Start Changestream Example 1
$changeStream
=
$db
->
inventory
->
watch
();
...
...
This diff is collapsed.
Click to expand it.
tests/Operation/WatchFunctionalTest.php
View file @
6afb08f4
...
...
@@ -29,19 +29,18 @@ class WatchFunctionalTest extends FunctionalTestCase
parent
::
setUp
();
$this
->
skipIfChangeStreamIsNotSupported
();
$this
->
createCollection
();
}
public
function
testNextResumesAfterCursorNotFound
()
{
$this
->
insertDocument
([
'_id'
=>
1
,
'x'
=>
'foo'
]);
$operation
=
new
Watch
(
$this
->
manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[],
$this
->
defaultOptions
);
$changeStream
=
$operation
->
execute
(
$this
->
getPrimaryServer
());
$changeStream
->
rewind
();
$this
->
assertFalse
(
$changeStream
->
valid
());
$this
->
insertDocument
([
'_id'
=>
2
,
'x'
=>
'bar
'
]);
$this
->
insertDocument
([
'_id'
=>
1
,
'x'
=>
'foo
'
]);
$changeStream
->
next
();
$this
->
assertTrue
(
$changeStream
->
valid
());
...
...
@@ -49,16 +48,16 @@ class WatchFunctionalTest extends FunctionalTestCase
$expectedResult
=
[
'_id'
=>
$changeStream
->
current
()
->
_id
,
'operationType'
=>
'insert'
,
'fullDocument'
=>
[
'_id'
=>
2
,
'x'
=>
'bar
'
],
'fullDocument'
=>
[
'_id'
=>
1
,
'x'
=>
'foo
'
],
'ns'
=>
[
'db'
=>
$this
->
getDatabaseName
(),
'coll'
=>
$this
->
getCollectionName
()],
'documentKey'
=>
[
'_id'
=>
2
],
'documentKey'
=>
[
'_id'
=>
1
],
];
$this
->
assertMatchesDocument
(
$expectedResult
,
$changeStream
->
current
());
$this
->
killChangeStreamCursor
(
$changeStream
);
$this
->
insertDocument
([
'_id'
=>
3
,
'x'
=>
'baz
'
]);
$this
->
insertDocument
([
'_id'
=>
2
,
'x'
=>
'bar
'
]);
$changeStream
->
next
();
$this
->
assertTrue
(
$changeStream
->
valid
());
...
...
@@ -66,9 +65,9 @@ class WatchFunctionalTest extends FunctionalTestCase
$expectedResult
=
[
'_id'
=>
$changeStream
->
current
()
->
_id
,
'operationType'
=>
'insert'
,
'fullDocument'
=>
[
'_id'
=>
3
,
'x'
=>
'baz
'
],
'fullDocument'
=>
[
'_id'
=>
2
,
'x'
=>
'bar
'
],
'ns'
=>
[
'db'
=>
$this
->
getDatabaseName
(),
'coll'
=>
$this
->
getCollectionName
()],
'documentKey'
=>
[
'_id'
=>
3
]
'documentKey'
=>
[
'_id'
=>
2
]
];
$this
->
assertMatchesDocument
(
$expectedResult
,
$changeStream
->
current
());
...
...
@@ -335,15 +334,13 @@ class WatchFunctionalTest extends FunctionalTestCase
public
function
testNoChangeAfterResumeBeforeInsert
()
{
$this
->
insertDocument
([
'_id'
=>
1
,
'x'
=>
'foo'
]);
$operation
=
new
Watch
(
$this
->
manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[],
$this
->
defaultOptions
);
$changeStream
=
$operation
->
execute
(
$this
->
getPrimaryServer
());
$this
->
assertNoCommandExecuted
(
function
()
use
(
$changeStream
)
{
$changeStream
->
rewind
();
});
$this
->
assertFalse
(
$changeStream
->
valid
());
$this
->
insertDocument
([
'_id'
=>
2
,
'x'
=>
'bar
'
]);
$this
->
insertDocument
([
'_id'
=>
1
,
'x'
=>
'foo
'
]);
$changeStream
->
next
();
$this
->
assertTrue
(
$changeStream
->
valid
());
...
...
@@ -351,9 +348,9 @@ class WatchFunctionalTest extends FunctionalTestCase
$expectedResult
=
[
'_id'
=>
$changeStream
->
current
()
->
_id
,
'operationType'
=>
'insert'
,
'fullDocument'
=>
[
'_id'
=>
2
,
'x'
=>
'bar
'
],
'fullDocument'
=>
[
'_id'
=>
1
,
'x'
=>
'foo
'
],
'ns'
=>
[
'db'
=>
$this
->
getDatabaseName
(),
'coll'
=>
$this
->
getCollectionName
()],
'documentKey'
=>
[
'_id'
=>
2
],
'documentKey'
=>
[
'_id'
=>
1
],
];
$this
->
assertMatchesDocument
(
$expectedResult
,
$changeStream
->
current
());
...
...
@@ -363,7 +360,7 @@ class WatchFunctionalTest extends FunctionalTestCase
$changeStream
->
next
();
$this
->
assertFalse
(
$changeStream
->
valid
());
$this
->
insertDocument
([
'_id'
=>
3
,
'x'
=>
'baz
'
]);
$this
->
insertDocument
([
'_id'
=>
2
,
'x'
=>
'bar
'
]);
$changeStream
->
next
();
$this
->
assertTrue
(
$changeStream
->
valid
());
...
...
@@ -371,9 +368,9 @@ class WatchFunctionalTest extends FunctionalTestCase
$expectedResult
=
[
'_id'
=>
$changeStream
->
current
()
->
_id
,
'operationType'
=>
'insert'
,
'fullDocument'
=>
[
'_id'
=>
3
,
'x'
=>
'baz
'
],
'fullDocument'
=>
[
'_id'
=>
2
,
'x'
=>
'bar
'
],
'ns'
=>
[
'db'
=>
$this
->
getDatabaseName
(),
'coll'
=>
$this
->
getCollectionName
()],
'documentKey'
=>
[
'_id'
=>
3
],
'documentKey'
=>
[
'_id'
=>
2
],
];
$this
->
assertMatchesDocument
(
$expectedResult
,
$changeStream
->
current
());
...
...
@@ -381,9 +378,6 @@ class WatchFunctionalTest extends FunctionalTestCase
public
function
testResumeMultipleTimesInSuccession
()
{
$operation
=
new
CreateCollection
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
());
$operation
->
execute
(
$this
->
getPrimaryServer
());
$operation
=
new
Watch
(
$this
->
manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[],
$this
->
defaultOptions
);
$changeStream
=
$operation
->
execute
(
$this
->
getPrimaryServer
());
...
...
@@ -966,9 +960,6 @@ class WatchFunctionalTest extends FunctionalTestCase
public
function
testSessionFreed
()
{
// Create collection so we can drop it later
$this
->
createCollection
();
$operation
=
new
Watch
(
$this
->
manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[],
$this
->
defaultOptions
);
$changeStream
=
$operation
->
execute
(
$this
->
getPrimaryServer
());
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment