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
9036b03e
Commit
9036b03e
authored
Mar 13, 2018
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract default options in Watch tests to class property
parent
899b43ce
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
13 deletions
+15
-13
WatchFunctionalTest.php
tests/Operation/WatchFunctionalTest.php
+15
-13
No files found.
tests/Operation/WatchFunctionalTest.php
View file @
9036b03e
...
...
@@ -17,6 +17,8 @@ use ReflectionClass;
class
WatchFunctionalTest
extends
FunctionalTestCase
{
private
$defaultOptions
=
[
'maxAwaitTimeMS'
=>
100
];
public
function
setUp
()
{
parent
::
setUp
();
...
...
@@ -34,7 +36,7 @@ class WatchFunctionalTest extends FunctionalTestCase
{
$this
->
insertDocument
([
'_id'
=>
1
,
'x'
=>
'foo'
]);
$operation
=
new
Watch
(
$this
->
manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[],
[
'maxAwaitTimeMS'
=>
100
]
);
$operation
=
new
Watch
(
$this
->
manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[],
$this
->
defaultOptions
);
$changeStream
=
$operation
->
execute
(
$this
->
getPrimaryServer
());
$changeStream
->
rewind
();
...
...
@@ -81,7 +83,7 @@ class WatchFunctionalTest extends FunctionalTestCase
$manager
=
new
Manager
(
$this
->
getUri
(),
[
'socketTimeoutMS'
=>
50
]);
$primaryServer
=
$manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
$operation
=
new
Watch
(
$manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[],
[
'maxAwaitTimeMS'
=>
100
]
);
$operation
=
new
Watch
(
$manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[],
$this
->
defaultOptions
);
$changeStream
=
$operation
->
execute
(
$primaryServer
);
/* Note: we intentionally do not start iteration with rewind() to ensure
...
...
@@ -134,7 +136,7 @@ class WatchFunctionalTest extends FunctionalTestCase
$manager
=
new
Manager
(
$this
->
getUri
(),
[
'socketTimeoutMS'
=>
50
]);
$primaryServer
=
$manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
$operation
=
new
Watch
(
$manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[],
[
'maxAwaitTimeMS'
=>
100
]
);
$operation
=
new
Watch
(
$manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[],
$this
->
defaultOptions
);
$changeStream
=
$operation
->
execute
(
$primaryServer
);
$commands
=
[];
...
...
@@ -180,7 +182,7 @@ class WatchFunctionalTest extends FunctionalTestCase
{
$this
->
insertDocument
([
'_id'
=>
1
,
'x'
=>
'foo'
]);
$operation
=
new
Watch
(
$this
->
manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[],
[
'maxAwaitTimeMS'
=>
100
]
);
$operation
=
new
Watch
(
$this
->
manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[],
$this
->
defaultOptions
);
$changeStream
=
$operation
->
execute
(
$this
->
getPrimaryServer
());
$changeStream
->
rewind
();
...
...
@@ -225,7 +227,7 @@ class WatchFunctionalTest extends FunctionalTestCase
public
function
testKey
()
{
$operation
=
new
Watch
(
$this
->
manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[],
[
'maxAwaitTimeMS'
=>
100
]
);
$operation
=
new
Watch
(
$this
->
manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[],
$this
->
defaultOptions
);
$changeStream
=
$operation
->
execute
(
$this
->
getPrimaryServer
());
$this
->
assertFalse
(
$changeStream
->
valid
());
...
...
@@ -262,7 +264,7 @@ class WatchFunctionalTest extends FunctionalTestCase
{
$pipeline
=
[[
'$project'
=>
[
'foo'
=>
[
0
]]]];
$operation
=
new
Watch
(
$this
->
manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
$pipeline
,
[
'maxAwaitTimeMS'
=>
100
]
);
$operation
=
new
Watch
(
$this
->
manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
$pipeline
,
$this
->
defaultOptions
);
$changeStream
=
$operation
->
execute
(
$this
->
getPrimaryServer
());
$this
->
insertDocument
([
'_id'
=>
1
]);
...
...
@@ -313,7 +315,7 @@ class WatchFunctionalTest extends FunctionalTestCase
{
$pipeline
=
[[
'$project'
=>
[
'_id'
=>
0
]]];
$operation
=
new
Watch
(
$this
->
manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
$pipeline
,
[
'maxAwaitTimeMS'
=>
100
]
);
$operation
=
new
Watch
(
$this
->
manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
$pipeline
,
$this
->
defaultOptions
);
$changeStream
=
$operation
->
execute
(
$this
->
getPrimaryServer
());
/* Note: we intentionally do not start iteration with rewind() to ensure
...
...
@@ -331,7 +333,7 @@ class WatchFunctionalTest extends FunctionalTestCase
{
$pipeline
=
[[
'$project'
=>
[
'_id'
=>
0
]]];
$operation
=
new
Watch
(
$this
->
manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
$pipeline
,
[
'maxAwaitTimeMS'
=>
100
]
);
$operation
=
new
Watch
(
$this
->
manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
$pipeline
,
$this
->
defaultOptions
);
$changeStream
=
$operation
->
execute
(
$this
->
getPrimaryServer
());
$this
->
insertDocument
([
'x'
=>
1
]);
...
...
@@ -347,7 +349,7 @@ class WatchFunctionalTest extends FunctionalTestCase
{
$pipeline
=
[[
'$project'
=>
[
'_id'
=>
[
'$literal'
=>
'foo'
]]]];
$operation
=
new
Watch
(
$this
->
manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
$pipeline
,
[
'maxAwaitTimeMS'
=>
100
]
);
$operation
=
new
Watch
(
$this
->
manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
$pipeline
,
$this
->
defaultOptions
);
$changeStream
=
$operation
->
execute
(
$this
->
getPrimaryServer
());
/* Note: we intentionally do not start iteration with rewind() to ensure
...
...
@@ -365,7 +367,7 @@ class WatchFunctionalTest extends FunctionalTestCase
{
$pipeline
=
[[
'$project'
=>
[
'_id'
=>
[
'$literal'
=>
'foo'
]]]];
$operation
=
new
Watch
(
$this
->
manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
$pipeline
,
[
'maxAwaitTimeMS'
=>
100
]
);
$operation
=
new
Watch
(
$this
->
manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
$pipeline
,
$this
->
defaultOptions
);
$changeStream
=
$operation
->
execute
(
$this
->
getPrimaryServer
());
$this
->
insertDocument
([
'x'
=>
1
]);
...
...
@@ -424,7 +426,7 @@ class WatchFunctionalTest extends FunctionalTestCase
public
function
testRewindResumesAfterCursorNotFound
()
{
$operation
=
new
Watch
(
$this
->
manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[],
[
'maxAwaitTimeMS'
=>
100
]
);
$operation
=
new
Watch
(
$this
->
manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[],
$this
->
defaultOptions
);
$changeStream
=
$operation
->
execute
(
$this
->
getPrimaryServer
());
$this
->
killChangeStreamCursor
(
$changeStream
);
...
...
@@ -436,7 +438,7 @@ class WatchFunctionalTest extends FunctionalTestCase
public
function
testRewindExtractsResumeTokenAndNextResumes
()
{
$operation
=
new
Watch
(
$this
->
manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[],
[
'maxAwaitTimeMS'
=>
100
]
);
$operation
=
new
Watch
(
$this
->
manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[],
$this
->
defaultOptions
);
$changeStream
=
$operation
->
execute
(
$this
->
getPrimaryServer
());
$this
->
insertDocument
([
'_id'
=>
1
,
'x'
=>
'foo'
]);
...
...
@@ -473,7 +475,7 @@ class WatchFunctionalTest extends FunctionalTestCase
*/
public
function
testTypeMapOption
(
array
$typeMap
,
$expectedChangeDocument
)
{
$operation
=
new
Watch
(
$this
->
manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[],
[
'
maxAwaitTimeMS'
=>
100
,
'typeMap'
=>
$typeMap
]
);
$operation
=
new
Watch
(
$this
->
manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[],
[
'
typeMap'
=>
$typeMap
]
+
$this
->
defaultOptions
);
$changeStream
=
$operation
->
execute
(
$this
->
getPrimaryServer
());
$changeStream
->
rewind
();
...
...
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