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
f4b5a6f4
Commit
f4b5a6f4
authored
Jul 13, 2018
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #563
parents
9813df19
602c12cf
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
12 deletions
+40
-12
DocumentationExamplesTest.php
tests/DocumentationExamplesTest.php
+2
-12
FunctionalTestCase.php
tests/FunctionalTestCase.php
+38
-0
No files found.
tests/DocumentationExamplesTest.php
View file @
f4b5a6f4
...
@@ -1230,12 +1230,7 @@ class DocumentationExamplesTest extends FunctionalTestCase
...
@@ -1230,12 +1230,7 @@ class DocumentationExamplesTest extends FunctionalTestCase
public
function
testTransactions_intro_example_1
()
public
function
testTransactions_intro_example_1
()
{
{
if
(
$this
->
getPrimaryServer
()
->
getType
()
===
Server
::
TYPE_STANDALONE
)
{
$this
->
skipIfTransactionsAreNotSupported
();
$this
->
markTestSkipped
(
'Transactions are not supported on standalone servers'
);
}
if
(
version_compare
(
$this
->
getFeatureCompatibilityVersion
(),
'4.0'
,
'<'
))
{
$this
->
markTestSkipped
(
'Transactions are only supported on FCV 4.0 or higher'
);
}
$client
=
new
Client
(
$this
->
getUri
());
$client
=
new
Client
(
$this
->
getUri
());
...
@@ -1395,12 +1390,7 @@ class DocumentationExamplesTest extends FunctionalTestCase
...
@@ -1395,12 +1390,7 @@ class DocumentationExamplesTest extends FunctionalTestCase
public
function
testTransactions_retry_example_3
()
public
function
testTransactions_retry_example_3
()
{
{
if
(
$this
->
getPrimaryServer
()
->
getType
()
===
Server
::
TYPE_STANDALONE
)
{
$this
->
skipIfTransactionsAreNotSupported
();
$this
->
markTestSkipped
(
'Transactions are not supported on standalone servers'
);
}
if
(
version_compare
(
$this
->
getFeatureCompatibilityVersion
(),
'4.0'
,
'<'
))
{
$this
->
markTestSkipped
(
'Transactions are only supported on FCV 4.0 or higher'
);
}
$client
=
new
Client
(
$this
->
getUri
());
$client
=
new
Client
(
$this
->
getUri
());
...
...
tests/FunctionalTestCase.php
View file @
f4b5a6f4
...
@@ -6,6 +6,7 @@ use MongoDB\Driver\Command;
...
@@ -6,6 +6,7 @@ use MongoDB\Driver\Command;
use
MongoDB\Driver\Cursor
;
use
MongoDB\Driver\Cursor
;
use
MongoDB\Driver\Manager
;
use
MongoDB\Driver\Manager
;
use
MongoDB\Driver\ReadPreference
;
use
MongoDB\Driver\ReadPreference
;
use
MongoDB\Driver\Server
;
use
stdClass
;
use
stdClass
;
use
UnexpectedValueException
;
use
UnexpectedValueException
;
...
@@ -95,4 +96,41 @@ abstract class FunctionalTestCase extends TestCase
...
@@ -95,4 +96,41 @@ abstract class FunctionalTestCase extends TestCase
throw
new
UnexpectedValueException
(
'Could not determine server version'
);
throw
new
UnexpectedValueException
(
'Could not determine server version'
);
}
}
protected
function
getServerStorageEngine
(
ReadPreference
$readPreference
=
null
)
{
$cursor
=
$this
->
manager
->
executeCommand
(
$this
->
getDatabaseName
(),
new
Command
([
'serverStatus'
=>
1
]),
$readPreference
?:
new
ReadPreference
(
'primary'
)
);
$result
=
current
(
$cursor
->
toArray
());
if
(
isset
(
$result
->
storageEngine
->
name
)
&&
is_string
(
$result
->
storageEngine
->
name
))
{
return
$result
->
storageEngine
->
name
;
}
throw
new
UnexpectedValueException
(
'Could not determine server storage engine'
);
}
protected
function
skipIfTransactionsAreNotSupported
()
{
if
(
$this
->
getPrimaryServer
()
->
getType
()
===
Server
::
TYPE_STANDALONE
)
{
$this
->
markTestSkipped
(
'Transactions are not supported on standalone servers'
);
}
// TODO: MongoDB 4.2 should support sharded clusters (see: PHPLIB-374)
if
(
$this
->
getPrimaryServer
()
->
getType
()
===
Server
::
TYPE_MONGOS
)
{
$this
->
markTestSkipped
(
'Transactions are not supported on sharded clusters'
);
}
if
(
version_compare
(
$this
->
getFeatureCompatibilityVersion
(),
'4.0'
,
'<'
))
{
$this
->
markTestSkipped
(
'Transactions are only supported on FCV 4.0 or higher'
);
}
if
(
$this
->
getServerStorageEngine
()
!==
'wiredTiger'
)
{
$this
->
markTestSkipped
(
'Transactions require WiredTiger storage engine'
);
}
}
}
}
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