Unverified Commit a72cbe38 authored by Andreas Braun's avatar Andreas Braun

Merge pull request #669

parents 5042a2fa 83260b5d
...@@ -14,9 +14,9 @@ cache: ...@@ -14,9 +14,9 @@ cache:
env: env:
global: global:
- DRIVER_VERSION=1.6.0alpha2 - DRIVER_VERSION=1.6.0alpha3
- SERVER_DISTRO=ubuntu1604 - SERVER_DISTRO=ubuntu1604
- SERVER_VERSION=4.0.10 - SERVER_VERSION=4.2.0
- DEPLOYMENT=STANDALONE - DEPLOYMENT=STANDALONE
- COMPOSER_OPTIONS= - COMPOSER_OPTIONS=
...@@ -44,7 +44,7 @@ jobs: ...@@ -44,7 +44,7 @@ jobs:
env: env:
- COMPOSER_OPTIONS=--prefer-lowest - COMPOSER_OPTIONS=--prefer-lowest
# Test older standalone server versions (3.0-3.6) # Test older standalone server versions (3.0-4.0)
- stage: Test - stage: Test
php: "7.0" php: "7.0"
dist: trusty dist: trusty
...@@ -66,6 +66,10 @@ jobs: ...@@ -66,6 +66,10 @@ jobs:
php: "7.0" php: "7.0"
env: env:
- SERVER_VERSION=3.6.13 - SERVER_VERSION=3.6.13
- stage: Test
php: "7.3"
env:
- SERVER_VERSION=4.0.12
# Test other server configurations # Test other server configurations
- stage: Test - stage: Test
...@@ -94,13 +98,6 @@ jobs: ...@@ -94,13 +98,6 @@ jobs:
env: env:
- DEPLOYMENT=SHARDED_CLUSTER_RS - DEPLOYMENT=SHARDED_CLUSTER_RS
# Test upcoming server versions
- stage: Test
php: "7.3"
env:
- SERVER_VERSION=4.2.0-rc1
- DEPLOYMENT=REPLICASET
before_install: before_install:
- pip install "mongo-orchestration>=0.6.7,<1.0" --user `whoami` - pip install "mongo-orchestration>=0.6.7,<1.0" --user `whoami`
- export SERVER_FILENAME=mongodb-linux-x86_64-${SERVER_DISTRO}-${SERVER_VERSION} - export SERVER_FILENAME=mongodb-linux-x86_64-${SERVER_DISTRO}-${SERVER_VERSION}
......
...@@ -9,7 +9,7 @@ fi ...@@ -9,7 +9,7 @@ fi
case $DEPLOYMENT in case $DEPLOYMENT in
SHARDED_CLUSTER) SHARDED_CLUSTER)
${TRAVIS_BUILD_DIR}/.travis/mo.sh ${TRAVIS_BUILD_DIR}/mongo-orchestration/sharded_clusters/cluster.json start > /tmp/mo-result.json ${TRAVIS_BUILD_DIR}/.travis/mo.sh ${TRAVIS_BUILD_DIR}/mongo-orchestration/sharded_clusters/cluster.json start > /tmp/mo-result.json
cat /tmp/mo-result.json | tail -n 1 | php -r 'echo json_decode(file_get_contents("php://stdin"))->mongodb_uri;' > /tmp/uri.txt cat /tmp/mo-result.json | tail -n 1 | php -r 'echo json_decode(file_get_contents("php://stdin"))->mongodb_uri, "/?retryWrites=false";' > /tmp/uri.txt
;; ;;
SHARDED_CLUSTER_RS) SHARDED_CLUSTER_RS)
${TRAVIS_BUILD_DIR}/.travis/mo.sh ${TRAVIS_BUILD_DIR}/mongo-orchestration/sharded_clusters/cluster_replset.json start > /tmp/mo-result.json ${TRAVIS_BUILD_DIR}/.travis/mo.sh ${TRAVIS_BUILD_DIR}/mongo-orchestration/sharded_clusters/cluster_replset.json start > /tmp/mo-result.json
......
...@@ -9,6 +9,7 @@ use MongoDB\Driver\ReadConcern; ...@@ -9,6 +9,7 @@ use MongoDB\Driver\ReadConcern;
use MongoDB\Driver\ReadPreference; use MongoDB\Driver\ReadPreference;
use MongoDB\Driver\WriteConcern; use MongoDB\Driver\WriteConcern;
use MongoDB\Exception\InvalidArgumentException; use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Exception\UnsupportedException;
use MongoDB\Operation\Count; use MongoDB\Operation\Count;
use MongoDB\Operation\MapReduce; use MongoDB\Operation\MapReduce;
use MongoDB\Tests\CommandObserver; use MongoDB\Tests\CommandObserver;
...@@ -619,8 +620,6 @@ class CollectionFunctionalTest extends FunctionalTestCase ...@@ -619,8 +620,6 @@ class CollectionFunctionalTest extends FunctionalTestCase
/** /**
* @dataProvider collectionWriteMethodClosures * @dataProvider collectionWriteMethodClosures
* @expectedException MongoDB\Exception\UnsupportedException
* @expectedExceptionMessage "writeConcern" option cannot be specified within a transaction
*/ */
public function testMethodInTransactionWithWriteConcernOption($method) public function testMethodInTransactionWithWriteConcernOption($method)
{ {
...@@ -631,6 +630,9 @@ class CollectionFunctionalTest extends FunctionalTestCase ...@@ -631,6 +630,9 @@ class CollectionFunctionalTest extends FunctionalTestCase
$session = $this->manager->startSession(); $session = $this->manager->startSession();
$session->startTransaction(); $session->startTransaction();
$this->expectException(UnsupportedException::class);
$this->expectExceptionMessage('"writeConcern" option cannot be specified within a transaction');
try { try {
call_user_func($method, $this->collection, $session, ['writeConcern' => new WriteConcern(1)]); call_user_func($method, $this->collection, $session, ['writeConcern' => new WriteConcern(1)]);
} finally { } finally {
...@@ -640,8 +642,6 @@ class CollectionFunctionalTest extends FunctionalTestCase ...@@ -640,8 +642,6 @@ class CollectionFunctionalTest extends FunctionalTestCase
/** /**
* @dataProvider collectionReadMethodClosures * @dataProvider collectionReadMethodClosures
* @expectedException MongoDB\Exception\UnsupportedException
* @expectedExceptionMessage "readConcern" option cannot be specified within a transaction
*/ */
public function testMethodInTransactionWithReadConcernOption($method) public function testMethodInTransactionWithReadConcernOption($method)
{ {
...@@ -652,6 +652,9 @@ class CollectionFunctionalTest extends FunctionalTestCase ...@@ -652,6 +652,9 @@ class CollectionFunctionalTest extends FunctionalTestCase
$session = $this->manager->startSession(); $session = $this->manager->startSession();
$session->startTransaction(); $session->startTransaction();
$this->expectException(UnsupportedException::class);
$this->expectExceptionMessage('"readConcern" option cannot be specified within a transaction');
try { try {
call_user_func($method, $this->collection, $session, ['readConcern' => new ReadConcern(ReadConcern::LOCAL)]); call_user_func($method, $this->collection, $session, ['readConcern' => new ReadConcern(ReadConcern::LOCAL)]);
} finally { } finally {
......
...@@ -94,10 +94,10 @@ abstract class FunctionalTestCase extends TestCase ...@@ -94,10 +94,10 @@ abstract class FunctionalTestCase extends TestCase
$parts[] = $urlParts['path']; $parts[] = $urlParts['path'];
} }
if (isset($urlParts['query'])) { if (isset($urlParts['query'])) {
$parts += [ $parts = array_merge($parts, [
'?', '?',
$urlParts['path'] $urlParts['query']
]; ]);
} }
return implode('', $parts); return implode('', $parts);
......
...@@ -217,7 +217,17 @@ class AggregateFunctionalTest extends FunctionalTestCase ...@@ -217,7 +217,17 @@ class AggregateFunctionalTest extends FunctionalTestCase
$results = iterator_to_array($operation->execute($this->getPrimaryServer())); $results = iterator_to_array($operation->execute($this->getPrimaryServer()));
$this->assertCount(1, $results); $this->assertCount(1, $results);
$this->assertObjectHasAttribute('stages', current($results)); $result = current($results);
if ($this->isShardedCluster()) {
$this->assertObjectHasAttribute('shards', $result);
foreach ($result->shards as $shard) {
$this->assertObjectHasAttribute('stages', $shard);
}
} else {
$this->assertObjectHasAttribute('stages', $result);
}
}, },
function(array $event) { function(array $event) {
$this->assertObjectNotHasAttribute('writeConcern', $event['started']->getCommand()); $this->assertObjectNotHasAttribute('writeConcern', $event['started']->getCommand());
......
...@@ -28,6 +28,7 @@ class WatchFunctionalTest extends FunctionalTestCase ...@@ -28,6 +28,7 @@ class WatchFunctionalTest extends FunctionalTestCase
{ {
use SetUpTearDownTrait; use SetUpTearDownTrait;
const INTERRUPTED = 11601;
const NOT_MASTER = 10107; const NOT_MASTER = 10107;
private static $wireVersionForStartAtOperationTime = 7; private static $wireVersionForStartAtOperationTime = 7;
...@@ -1295,7 +1296,7 @@ class WatchFunctionalTest extends FunctionalTestCase ...@@ -1295,7 +1296,7 @@ class WatchFunctionalTest extends FunctionalTestCase
$this->configureFailPoint([ $this->configureFailPoint([
'configureFailPoint' => 'failCommand', 'configureFailPoint' => 'failCommand',
'mode' => ['times' => 1], 'mode' => ['times' => 1],
'data' => ['failCommands' => ['aggregate'], 'errorCode' => self::NOT_MASTER], 'data' => ['failCommands' => ['aggregate'], 'errorCode' => self::INTERRUPTED],
]); ]);
$this->expectException(CommandException::class); $this->expectException(CommandException::class);
......
...@@ -18,6 +18,10 @@ use stdClass; ...@@ -18,6 +18,10 @@ use stdClass;
*/ */
class ChangeStreamsSpecTest extends FunctionalTestCase class ChangeStreamsSpecTest extends FunctionalTestCase
{ {
private static $incompleteTests = [
'change-streams-errors: Change Stream should error when _id is projected out' => 'PHPC-1419',
];
/** /**
* Assert that the expected and actual command documents match. * Assert that the expected and actual command documents match.
* *
...@@ -66,6 +70,10 @@ class ChangeStreamsSpecTest extends FunctionalTestCase ...@@ -66,6 +70,10 @@ class ChangeStreamsSpecTest extends FunctionalTestCase
*/ */
public function testChangeStreams(stdClass $test, $databaseName = null, $collectionName = null, $database2Name = null, $collection2Name = null) public function testChangeStreams(stdClass $test, $databaseName = null, $collectionName = null, $database2Name = null, $collection2Name = null)
{ {
if (isset(self::$incompleteTests[$this->dataDescription()])) {
$this->markTestIncomplete(self::$incompleteTests[$this->dataDescription()]);
}
$this->checkServerRequirements($this->createRunOn($test)); $this->checkServerRequirements($this->createRunOn($test));
if (!isset($databaseName, $collectionName, $database2Name, $collection2Name)) { if (!isset($databaseName, $collectionName, $database2Name, $collection2Name)) {
......
...@@ -132,7 +132,7 @@ final class ErrorExpectation ...@@ -132,7 +132,7 @@ final class ErrorExpectation
$test->assertNotNull($actual); $test->assertNotNull($actual);
if (isset($this->messageContains)) { if (isset($this->messageContains)) {
$test->assertContains($this->messageContains, $actual->getMessage(), '', true /* case-insensitive */); $test->assertStringContainsStringIgnoringCase($this->messageContains, $actual->getMessage());
} }
if (isset($this->codeName)) { if (isset($this->codeName)) {
...@@ -178,7 +178,7 @@ final class ErrorExpectation ...@@ -178,7 +178,7 @@ final class ErrorExpectation
$test->assertInstanceOf(CommandException::class, $actual); $test->assertInstanceOf(CommandException::class, $actual);
$result = $actual->getResultDocument(); $result = $actual->getResultDocument();
$test->assertObjectHasAttribute('codeName', $result); $test->assertObjectHasAttribute('codeName', $result);
$test->assertAttributeSame($this->codeName, 'codeName', $result); $test->assertSame($this->codeName, $result->codeName);
} }
private static function isArrayOfStrings($array) private static function isArrayOfStrings($array)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment