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
Jul 11, 2019
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create collection before change stream tests
parent
a032bb3f
Show 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
...
@@ -930,6 +930,7 @@ class DocumentationExamplesTest extends FunctionalTestCase
$db
=
new
Database
(
$this
->
manager
,
$this
->
getDatabaseName
());
$db
=
new
Database
(
$this
->
manager
,
$this
->
getDatabaseName
());
$db
->
dropCollection
(
'inventory'
);
$db
->
dropCollection
(
'inventory'
);
$db
->
createCollection
(
'inventory'
);
// Start Changestream Example 1
// Start Changestream Example 1
$changeStream
=
$db
->
inventory
->
watch
();
$changeStream
=
$db
->
inventory
->
watch
();
...
...
tests/Operation/WatchFunctionalTest.php
View file @
6afb08f4
...
@@ -29,19 +29,18 @@ class WatchFunctionalTest extends FunctionalTestCase
...
@@ -29,19 +29,18 @@ class WatchFunctionalTest extends FunctionalTestCase
parent
::
setUp
();
parent
::
setUp
();
$this
->
skipIfChangeStreamIsNotSupported
();
$this
->
skipIfChangeStreamIsNotSupported
();
$this
->
createCollection
();
}
}
public
function
testNextResumesAfterCursorNotFound
()
public
function
testNextResumesAfterCursorNotFound
()
{
{
$this
->
insertDocument
([
'_id'
=>
1
,
'x'
=>
'foo'
]);
$operation
=
new
Watch
(
$this
->
manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[],
$this
->
defaultOptions
);
$operation
=
new
Watch
(
$this
->
manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[],
$this
->
defaultOptions
);
$changeStream
=
$operation
->
execute
(
$this
->
getPrimaryServer
());
$changeStream
=
$operation
->
execute
(
$this
->
getPrimaryServer
());
$changeStream
->
rewind
();
$changeStream
->
rewind
();
$this
->
assertFalse
(
$changeStream
->
valid
());
$this
->
assertFalse
(
$changeStream
->
valid
());
$this
->
insertDocument
([
'_id'
=>
2
,
'x'
=>
'bar
'
]);
$this
->
insertDocument
([
'_id'
=>
1
,
'x'
=>
'foo
'
]);
$changeStream
->
next
();
$changeStream
->
next
();
$this
->
assertTrue
(
$changeStream
->
valid
());
$this
->
assertTrue
(
$changeStream
->
valid
());
...
@@ -49,16 +48,16 @@ class WatchFunctionalTest extends FunctionalTestCase
...
@@ -49,16 +48,16 @@ class WatchFunctionalTest extends FunctionalTestCase
$expectedResult
=
[
$expectedResult
=
[
'_id'
=>
$changeStream
->
current
()
->
_id
,
'_id'
=>
$changeStream
->
current
()
->
_id
,
'operationType'
=>
'insert'
,
'operationType'
=>
'insert'
,
'fullDocument'
=>
[
'_id'
=>
2
,
'x'
=>
'bar
'
],
'fullDocument'
=>
[
'_id'
=>
1
,
'x'
=>
'foo
'
],
'ns'
=>
[
'db'
=>
$this
->
getDatabaseName
(),
'coll'
=>
$this
->
getCollectionName
()],
'ns'
=>
[
'db'
=>
$this
->
getDatabaseName
(),
'coll'
=>
$this
->
getCollectionName
()],
'documentKey'
=>
[
'_id'
=>
2
],
'documentKey'
=>
[
'_id'
=>
1
],
];
];
$this
->
assertMatchesDocument
(
$expectedResult
,
$changeStream
->
current
());
$this
->
assertMatchesDocument
(
$expectedResult
,
$changeStream
->
current
());
$this
->
killChangeStreamCursor
(
$changeStream
);
$this
->
killChangeStreamCursor
(
$changeStream
);
$this
->
insertDocument
([
'_id'
=>
3
,
'x'
=>
'baz
'
]);
$this
->
insertDocument
([
'_id'
=>
2
,
'x'
=>
'bar
'
]);
$changeStream
->
next
();
$changeStream
->
next
();
$this
->
assertTrue
(
$changeStream
->
valid
());
$this
->
assertTrue
(
$changeStream
->
valid
());
...
@@ -66,9 +65,9 @@ class WatchFunctionalTest extends FunctionalTestCase
...
@@ -66,9 +65,9 @@ class WatchFunctionalTest extends FunctionalTestCase
$expectedResult
=
[
$expectedResult
=
[
'_id'
=>
$changeStream
->
current
()
->
_id
,
'_id'
=>
$changeStream
->
current
()
->
_id
,
'operationType'
=>
'insert'
,
'operationType'
=>
'insert'
,
'fullDocument'
=>
[
'_id'
=>
3
,
'x'
=>
'baz
'
],
'fullDocument'
=>
[
'_id'
=>
2
,
'x'
=>
'bar
'
],
'ns'
=>
[
'db'
=>
$this
->
getDatabaseName
(),
'coll'
=>
$this
->
getCollectionName
()],
'ns'
=>
[
'db'
=>
$this
->
getDatabaseName
(),
'coll'
=>
$this
->
getCollectionName
()],
'documentKey'
=>
[
'_id'
=>
3
]
'documentKey'
=>
[
'_id'
=>
2
]
];
];
$this
->
assertMatchesDocument
(
$expectedResult
,
$changeStream
->
current
());
$this
->
assertMatchesDocument
(
$expectedResult
,
$changeStream
->
current
());
...
@@ -335,15 +334,13 @@ class WatchFunctionalTest extends FunctionalTestCase
...
@@ -335,15 +334,13 @@ class WatchFunctionalTest extends FunctionalTestCase
public
function
testNoChangeAfterResumeBeforeInsert
()
public
function
testNoChangeAfterResumeBeforeInsert
()
{
{
$this
->
insertDocument
([
'_id'
=>
1
,
'x'
=>
'foo'
]);
$operation
=
new
Watch
(
$this
->
manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[],
$this
->
defaultOptions
);
$operation
=
new
Watch
(
$this
->
manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[],
$this
->
defaultOptions
);
$changeStream
=
$operation
->
execute
(
$this
->
getPrimaryServer
());
$changeStream
=
$operation
->
execute
(
$this
->
getPrimaryServer
());
$this
->
assertNoCommandExecuted
(
function
()
use
(
$changeStream
)
{
$changeStream
->
rewind
();
});
$this
->
assertNoCommandExecuted
(
function
()
use
(
$changeStream
)
{
$changeStream
->
rewind
();
});
$this
->
assertFalse
(
$changeStream
->
valid
());
$this
->
assertFalse
(
$changeStream
->
valid
());
$this
->
insertDocument
([
'_id'
=>
2
,
'x'
=>
'bar
'
]);
$this
->
insertDocument
([
'_id'
=>
1
,
'x'
=>
'foo
'
]);
$changeStream
->
next
();
$changeStream
->
next
();
$this
->
assertTrue
(
$changeStream
->
valid
());
$this
->
assertTrue
(
$changeStream
->
valid
());
...
@@ -351,9 +348,9 @@ class WatchFunctionalTest extends FunctionalTestCase
...
@@ -351,9 +348,9 @@ class WatchFunctionalTest extends FunctionalTestCase
$expectedResult
=
[
$expectedResult
=
[
'_id'
=>
$changeStream
->
current
()
->
_id
,
'_id'
=>
$changeStream
->
current
()
->
_id
,
'operationType'
=>
'insert'
,
'operationType'
=>
'insert'
,
'fullDocument'
=>
[
'_id'
=>
2
,
'x'
=>
'bar
'
],
'fullDocument'
=>
[
'_id'
=>
1
,
'x'
=>
'foo
'
],
'ns'
=>
[
'db'
=>
$this
->
getDatabaseName
(),
'coll'
=>
$this
->
getCollectionName
()],
'ns'
=>
[
'db'
=>
$this
->
getDatabaseName
(),
'coll'
=>
$this
->
getCollectionName
()],
'documentKey'
=>
[
'_id'
=>
2
],
'documentKey'
=>
[
'_id'
=>
1
],
];
];
$this
->
assertMatchesDocument
(
$expectedResult
,
$changeStream
->
current
());
$this
->
assertMatchesDocument
(
$expectedResult
,
$changeStream
->
current
());
...
@@ -363,7 +360,7 @@ class WatchFunctionalTest extends FunctionalTestCase
...
@@ -363,7 +360,7 @@ class WatchFunctionalTest extends FunctionalTestCase
$changeStream
->
next
();
$changeStream
->
next
();
$this
->
assertFalse
(
$changeStream
->
valid
());
$this
->
assertFalse
(
$changeStream
->
valid
());
$this
->
insertDocument
([
'_id'
=>
3
,
'x'
=>
'baz
'
]);
$this
->
insertDocument
([
'_id'
=>
2
,
'x'
=>
'bar
'
]);
$changeStream
->
next
();
$changeStream
->
next
();
$this
->
assertTrue
(
$changeStream
->
valid
());
$this
->
assertTrue
(
$changeStream
->
valid
());
...
@@ -371,9 +368,9 @@ class WatchFunctionalTest extends FunctionalTestCase
...
@@ -371,9 +368,9 @@ class WatchFunctionalTest extends FunctionalTestCase
$expectedResult
=
[
$expectedResult
=
[
'_id'
=>
$changeStream
->
current
()
->
_id
,
'_id'
=>
$changeStream
->
current
()
->
_id
,
'operationType'
=>
'insert'
,
'operationType'
=>
'insert'
,
'fullDocument'
=>
[
'_id'
=>
3
,
'x'
=>
'baz
'
],
'fullDocument'
=>
[
'_id'
=>
2
,
'x'
=>
'bar
'
],
'ns'
=>
[
'db'
=>
$this
->
getDatabaseName
(),
'coll'
=>
$this
->
getCollectionName
()],
'ns'
=>
[
'db'
=>
$this
->
getDatabaseName
(),
'coll'
=>
$this
->
getCollectionName
()],
'documentKey'
=>
[
'_id'
=>
3
],
'documentKey'
=>
[
'_id'
=>
2
],
];
];
$this
->
assertMatchesDocument
(
$expectedResult
,
$changeStream
->
current
());
$this
->
assertMatchesDocument
(
$expectedResult
,
$changeStream
->
current
());
...
@@ -381,9 +378,6 @@ class WatchFunctionalTest extends FunctionalTestCase
...
@@ -381,9 +378,6 @@ class WatchFunctionalTest extends FunctionalTestCase
public
function
testResumeMultipleTimesInSuccession
()
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
);
$operation
=
new
Watch
(
$this
->
manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[],
$this
->
defaultOptions
);
$changeStream
=
$operation
->
execute
(
$this
->
getPrimaryServer
());
$changeStream
=
$operation
->
execute
(
$this
->
getPrimaryServer
());
...
@@ -966,9 +960,6 @@ class WatchFunctionalTest extends FunctionalTestCase
...
@@ -966,9 +960,6 @@ class WatchFunctionalTest extends FunctionalTestCase
public
function
testSessionFreed
()
public
function
testSessionFreed
()
{
{
// Create collection so we can drop it later
$this
->
createCollection
();
$operation
=
new
Watch
(
$this
->
manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[],
$this
->
defaultOptions
);
$operation
=
new
Watch
(
$this
->
manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[],
$this
->
defaultOptions
);
$changeStream
=
$operation
->
execute
(
$this
->
getPrimaryServer
());
$changeStream
=
$operation
->
execute
(
$this
->
getPrimaryServer
());
...
...
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