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
abfae48c
Commit
abfae48c
authored
Jan 27, 2020
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #712
parents
0f353869
bbfad489
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
12 deletions
+11
-12
Context.php
tests/SpecTests/Context.php
+3
-3
FunctionalTestCase.php
tests/SpecTests/FunctionalTestCase.php
+8
-9
No files found.
tests/SpecTests/Context.php
View file @
abfae48c
...
@@ -38,7 +38,7 @@ final class Context
...
@@ -38,7 +38,7 @@ final class Context
public
$defaultWriteOptions
=
[];
public
$defaultWriteOptions
=
[];
/** @var array */
/** @var array */
public
$outcome
Fin
dOptions
=
[];
public
$outcome
Rea
dOptions
=
[];
/** @var string */
/** @var string */
public
$outcomeCollectionName
;
public
$outcomeCollectionName
;
...
@@ -98,7 +98,7 @@ final class Context
...
@@ -98,7 +98,7 @@ final class Context
'writeConcern'
=>
new
WriteConcern
(
WriteConcern
::
MAJORITY
),
'writeConcern'
=>
new
WriteConcern
(
WriteConcern
::
MAJORITY
),
];
];
$o
->
outcome
Fin
dOptions
=
[
$o
->
outcome
Rea
dOptions
=
[
'readConcern'
=>
new
ReadConcern
(
'local'
),
'readConcern'
=>
new
ReadConcern
(
'local'
),
'readPreference'
=>
new
ReadPreference
(
'primary'
),
'readPreference'
=>
new
ReadPreference
(
'primary'
),
];
];
...
@@ -147,7 +147,7 @@ final class Context
...
@@ -147,7 +147,7 @@ final class Context
'writeConcern'
=>
new
WriteConcern
(
WriteConcern
::
MAJORITY
),
'writeConcern'
=>
new
WriteConcern
(
WriteConcern
::
MAJORITY
),
];
];
$o
->
outcome
Fin
dOptions
=
[
$o
->
outcome
Rea
dOptions
=
[
'readConcern'
=>
new
ReadConcern
(
'local'
),
'readConcern'
=>
new
ReadConcern
(
'local'
),
'readPreference'
=>
new
ReadPreference
(
'primary'
),
'readPreference'
=>
new
ReadPreference
(
'primary'
),
];
];
...
...
tests/SpecTests/FunctionalTestCase.php
View file @
abfae48c
...
@@ -101,12 +101,11 @@ class FunctionalTestCase extends BaseFunctionalTestCase
...
@@ -101,12 +101,11 @@ class FunctionalTestCase extends BaseFunctionalTestCase
*/
*/
protected
function
assertOutcomeCollectionData
(
array
$expectedDocuments
)
protected
function
assertOutcomeCollectionData
(
array
$expectedDocuments
)
{
{
$outcomeCollection
=
$this
->
getOutcomeCollection
();
$outcomeCollection
=
$this
->
getOutcomeCollection
(
$this
->
getContext
()
->
outcomeReadOptions
);
$findOptions
=
$this
->
getContext
()
->
outcomeFindOptions
;
$mi
=
new
MultipleIterator
(
MultipleIterator
::
MIT_NEED_ANY
);
$mi
=
new
MultipleIterator
(
MultipleIterator
::
MIT_NEED_ANY
);
$mi
->
attachIterator
(
new
ArrayIterator
(
$expectedDocuments
));
$mi
->
attachIterator
(
new
ArrayIterator
(
$expectedDocuments
));
$mi
->
attachIterator
(
new
IteratorIterator
(
$outcomeCollection
->
find
(
[],
$findOptions
)));
$mi
->
attachIterator
(
new
IteratorIterator
(
$outcomeCollection
->
find
()));
foreach
(
$mi
as
$documents
)
{
foreach
(
$mi
as
$documents
)
{
list
(
$expectedDocument
,
$actualDocument
)
=
$documents
;
list
(
$expectedDocument
,
$actualDocument
)
=
$documents
;
...
@@ -193,16 +192,16 @@ class FunctionalTestCase extends BaseFunctionalTestCase
...
@@ -193,16 +192,16 @@ class FunctionalTestCase extends BaseFunctionalTestCase
$collection
=
null
;
$collection
=
null
;
if
(
$context
->
collectionName
!==
null
)
{
if
(
$context
->
collectionName
!==
null
)
{
$collection
=
$context
->
getCollection
();
$collection
=
$context
->
getCollection
(
$context
->
defaultWriteOptions
);
$collection
->
drop
(
$context
->
defaultWriteOptions
);
$collection
->
drop
();
}
}
if
(
$context
->
outcomeCollectionName
!==
null
)
{
if
(
$context
->
outcomeCollectionName
!==
null
)
{
$outcomeCollection
=
$this
->
getOutcomeCollection
();
$outcomeCollection
=
$this
->
getOutcomeCollection
(
$context
->
defaultWriteOptions
);
// Avoid redundant drop if the test and outcome collections are the same
// Avoid redundant drop if the test and outcome collections are the same
if
(
$collection
===
null
||
$outcomeCollection
->
getNamespace
()
!==
$collection
->
getNamespace
())
{
if
(
$collection
===
null
||
$outcomeCollection
->
getNamespace
()
!==
$collection
->
getNamespace
())
{
$outcomeCollection
->
drop
(
$context
->
defaultWriteOptions
);
$outcomeCollection
->
drop
();
}
}
}
}
}
}
...
@@ -226,12 +225,12 @@ class FunctionalTestCase extends BaseFunctionalTestCase
...
@@ -226,12 +225,12 @@ class FunctionalTestCase extends BaseFunctionalTestCase
return
;
return
;
}
}
private
function
getOutcomeCollection
()
private
function
getOutcomeCollection
(
array
$collectionOptions
=
[]
)
{
{
$context
=
$this
->
getContext
();
$context
=
$this
->
getContext
();
// Outcome collection need not use the client under test
// Outcome collection need not use the client under test
return
new
Collection
(
$this
->
manager
,
$context
->
databaseName
,
$context
->
outcomeCollectionName
);
return
new
Collection
(
$this
->
manager
,
$context
->
databaseName
,
$context
->
outcomeCollectionName
,
$collectionOptions
);
}
}
/**
/**
...
...
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