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
d3a3c4e8
Commit
d3a3c4e8
authored
Jan 02, 2018
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #453
parents
6523cc6a
b964f3ea
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
7 deletions
+23
-7
.travis.yml
.travis.yml
+0
-1
FunctionalTestCase.php
tests/FunctionalTestCase.php
+23
-6
No files found.
.travis.yml
View file @
d3a3c4e8
...
@@ -61,7 +61,6 @@ matrix:
...
@@ -61,7 +61,6 @@ matrix:
before_script
:
before_script
:
-
mongod --version
-
mongod --version
-
mongo --eval 'var v = db.runCommand({buildInfo:1}).versionArray; if ((v[0] == 3 && v[1] >= 4) || v[0] >= 4) db.adminCommand({setFeatureCompatibilityVersion:"3.4"});'
-
pecl install -f mongodb-${DRIVER_VERSION}
-
pecl install -f mongodb-${DRIVER_VERSION}
-
php --ri mongodb
-
php --ri mongodb
-
composer install --dev --no-interaction --prefer-source
-
composer install --dev --no-interaction --prefer-source
...
...
tests/FunctionalTestCase.php
View file @
d3a3c4e8
...
@@ -11,6 +11,7 @@ use MongoDB\Model\BSONDocument;
...
@@ -11,6 +11,7 @@ use MongoDB\Model\BSONDocument;
use
InvalidArgumentException
;
use
InvalidArgumentException
;
use
stdClass
;
use
stdClass
;
use
Traversable
;
use
Traversable
;
use
UnexpectedValueException
;
abstract
class
FunctionalTestCase
extends
TestCase
abstract
class
FunctionalTestCase
extends
TestCase
{
{
...
@@ -76,20 +77,32 @@ abstract class FunctionalTestCase extends TestCase
...
@@ -76,20 +77,32 @@ abstract class FunctionalTestCase extends TestCase
);
);
}
}
protected
function
getFeatureCompatibilityVersion
()
protected
function
getFeatureCompatibilityVersion
(
ReadPreference
$readPreference
=
null
)
{
{
if
(
version_compare
(
$this
->
getServerVersion
(),
'3.4.0'
,
'<'
))
{
if
(
version_compare
(
$this
->
getServerVersion
(),
'3.4.0'
,
'<'
))
{
return
$this
->
getServerVersion
();
return
$this
->
getServerVersion
(
$readPreference
);
}
}
$cursor
=
$this
->
manager
->
executeCommand
(
$cursor
=
$this
->
manager
->
executeCommand
(
"admin"
,
'admin'
,
new
Command
([
'getParameter'
=>
1
,
'featureCompatibilityVersion'
=>
1
])
new
Command
([
'getParameter'
=>
1
,
'featureCompatibilityVersion'
=>
1
]),
$readPreference
?:
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
)
);
);
$cursor
->
setTypeMap
([
'root'
=>
'array'
,
'document'
=>
'array'
]);
$cursor
->
setTypeMap
([
'root'
=>
'array'
,
'document'
=>
'array'
]);
$document
=
current
(
$cursor
->
toArray
());
$document
=
current
(
$cursor
->
toArray
());
return
$document
[
'featureCompatibilityVersion'
][
'version'
];
// MongoDB 3.6: featureCompatibilityVersion is an embedded document
if
(
isset
(
$document
[
'featureCompatibilityVersion'
][
'version'
])
&&
is_string
(
$document
[
'featureCompatibilityVersion'
][
'version'
]))
{
return
$document
[
'featureCompatibilityVersion'
][
'version'
];
}
// MongoDB 3.4: featureCompatibilityVersion is a string
if
(
isset
(
$document
[
'featureCompatibilityVersion'
])
&&
is_string
(
$document
[
'featureCompatibilityVersion'
]))
{
return
$document
[
'featureCompatibilityVersion'
];
}
throw
new
UnexpectedValueException
(
'Could not determine featureCompatibilityVersion'
);
}
}
protected
function
getPrimaryServer
()
protected
function
getPrimaryServer
()
...
@@ -108,7 +121,11 @@ abstract class FunctionalTestCase extends TestCase
...
@@ -108,7 +121,11 @@ abstract class FunctionalTestCase extends TestCase
$cursor
->
setTypeMap
([
'root'
=>
'array'
,
'document'
=>
'array'
]);
$cursor
->
setTypeMap
([
'root'
=>
'array'
,
'document'
=>
'array'
]);
$document
=
current
(
$cursor
->
toArray
());
$document
=
current
(
$cursor
->
toArray
());
return
$document
[
'version'
];
if
(
isset
(
$document
[
'version'
])
&&
is_string
(
$document
[
'version'
]))
{
return
$document
[
'version'
];
}
throw
new
UnexpectedValueException
(
'Could not determine server version'
);
}
}
/**
/**
...
...
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