diff --git a/.travis.yml b/.travis.yml index 88430166b..de3cbb3d9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,9 +14,9 @@ cache: env: global: - - DRIVER_VERSION=1.6.0alpha2 + - DRIVER_VERSION=1.6.0alpha3 - SERVER_DISTRO=ubuntu1604 - - SERVER_VERSION=4.0.10 + - SERVER_VERSION=4.2.0 - DEPLOYMENT=STANDALONE - COMPOSER_OPTIONS= @@ -44,7 +44,7 @@ jobs: env: - COMPOSER_OPTIONS=--prefer-lowest - # Test older standalone server versions (3.0-3.6) + # Test older standalone server versions (3.0-4.0) - stage: Test php: "7.0" dist: trusty @@ -66,6 +66,10 @@ jobs: php: "7.0" env: - SERVER_VERSION=3.6.13 + - stage: Test + php: "7.3" + env: + - SERVER_VERSION=4.0.12 # Test other server configurations - stage: Test @@ -94,13 +98,6 @@ jobs: env: - DEPLOYMENT=SHARDED_CLUSTER_RS - # Test upcoming server versions - - stage: Test - php: "7.3" - env: - - SERVER_VERSION=4.2.0-rc1 - - DEPLOYMENT=REPLICASET - before_install: - pip install "mongo-orchestration>=0.6.7,<1.0" --user `whoami` - export SERVER_FILENAME=mongodb-linux-x86_64-${SERVER_DISTRO}-${SERVER_VERSION} diff --git a/.travis/setup_mo.sh b/.travis/setup_mo.sh index e58b874bb..4d8a49502 100755 --- a/.travis/setup_mo.sh +++ b/.travis/setup_mo.sh @@ -9,7 +9,7 @@ fi case $DEPLOYMENT in SHARDED_CLUSTER) ${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) ${TRAVIS_BUILD_DIR}/.travis/mo.sh ${TRAVIS_BUILD_DIR}/mongo-orchestration/sharded_clusters/cluster_replset.json start > /tmp/mo-result.json diff --git a/tests/Collection/CollectionFunctionalTest.php b/tests/Collection/CollectionFunctionalTest.php index 65e1c9fb9..411769da5 100644 --- a/tests/Collection/CollectionFunctionalTest.php +++ b/tests/Collection/CollectionFunctionalTest.php @@ -9,6 +9,7 @@ use MongoDB\Driver\ReadPreference; use MongoDB\Driver\WriteConcern; use MongoDB\Exception\InvalidArgumentException; +use MongoDB\Exception\UnsupportedException; use MongoDB\Operation\Count; use MongoDB\Operation\MapReduce; use MongoDB\Tests\CommandObserver; @@ -619,8 +620,6 @@ function(array $event) { /** * @dataProvider collectionWriteMethodClosures - * @expectedException MongoDB\Exception\UnsupportedException - * @expectedExceptionMessage "writeConcern" option cannot be specified within a transaction */ public function testMethodInTransactionWithWriteConcernOption($method) { @@ -631,6 +630,9 @@ public function testMethodInTransactionWithWriteConcernOption($method) $session = $this->manager->startSession(); $session->startTransaction(); + $this->expectException(UnsupportedException::class); + $this->expectExceptionMessage('"writeConcern" option cannot be specified within a transaction'); + try { call_user_func($method, $this->collection, $session, ['writeConcern' => new WriteConcern(1)]); } finally { @@ -640,8 +642,6 @@ public function testMethodInTransactionWithWriteConcernOption($method) /** * @dataProvider collectionReadMethodClosures - * @expectedException MongoDB\Exception\UnsupportedException - * @expectedExceptionMessage "readConcern" option cannot be specified within a transaction */ public function testMethodInTransactionWithReadConcernOption($method) { @@ -652,6 +652,9 @@ public function testMethodInTransactionWithReadConcernOption($method) $session = $this->manager->startSession(); $session->startTransaction(); + $this->expectException(UnsupportedException::class); + $this->expectExceptionMessage('"readConcern" option cannot be specified within a transaction'); + try { call_user_func($method, $this->collection, $session, ['readConcern' => new ReadConcern(ReadConcern::LOCAL)]); } finally { diff --git a/tests/FunctionalTestCase.php b/tests/FunctionalTestCase.php index 418115726..1fbbb0f7e 100644 --- a/tests/FunctionalTestCase.php +++ b/tests/FunctionalTestCase.php @@ -94,10 +94,10 @@ public static function getUri($allowMultipleMongoses = false) $parts[] = $urlParts['path']; } if (isset($urlParts['query'])) { - $parts += [ + $parts = array_merge($parts, [ '?', - $urlParts['path'] - ]; + $urlParts['query'] + ]); } return implode('', $parts); diff --git a/tests/Operation/AggregateFunctionalTest.php b/tests/Operation/AggregateFunctionalTest.php index 4b33397ae..f832c650e 100644 --- a/tests/Operation/AggregateFunctionalTest.php +++ b/tests/Operation/AggregateFunctionalTest.php @@ -217,7 +217,17 @@ function() use ($pipeline, $options) { $results = iterator_to_array($operation->execute($this->getPrimaryServer())); $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) { $this->assertObjectNotHasAttribute('writeConcern', $event['started']->getCommand()); diff --git a/tests/Operation/WatchFunctionalTest.php b/tests/Operation/WatchFunctionalTest.php index 093e7a9e8..670fc38d8 100644 --- a/tests/Operation/WatchFunctionalTest.php +++ b/tests/Operation/WatchFunctionalTest.php @@ -28,6 +28,7 @@ class WatchFunctionalTest extends FunctionalTestCase { use SetUpTearDownTrait; + const INTERRUPTED = 11601; const NOT_MASTER = 10107; private static $wireVersionForStartAtOperationTime = 7; @@ -1295,7 +1296,7 @@ public function testErrorDuringAggregateCommandDoesNotCauseResume() $this->configureFailPoint([ 'configureFailPoint' => 'failCommand', 'mode' => ['times' => 1], - 'data' => ['failCommands' => ['aggregate'], 'errorCode' => self::NOT_MASTER], + 'data' => ['failCommands' => ['aggregate'], 'errorCode' => self::INTERRUPTED], ]); $this->expectException(CommandException::class); diff --git a/tests/SpecTests/ChangeStreamsSpecTest.php b/tests/SpecTests/ChangeStreamsSpecTest.php index 52163cfd9..b044c6b69 100644 --- a/tests/SpecTests/ChangeStreamsSpecTest.php +++ b/tests/SpecTests/ChangeStreamsSpecTest.php @@ -18,6 +18,10 @@ */ 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. * @@ -66,6 +70,10 @@ public static function assertResult(array $expectedDocuments, array $actualDocum */ 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)); if (!isset($databaseName, $collectionName, $database2Name, $collection2Name)) { diff --git a/tests/SpecTests/ErrorExpectation.php b/tests/SpecTests/ErrorExpectation.php index 04362a18b..ce853c186 100644 --- a/tests/SpecTests/ErrorExpectation.php +++ b/tests/SpecTests/ErrorExpectation.php @@ -132,7 +132,7 @@ public function assert(TestCase $test, Exception $actual = null) $test->assertNotNull($actual); if (isset($this->messageContains)) { - $test->assertContains($this->messageContains, $actual->getMessage(), '', true /* case-insensitive */); + $test->assertStringContainsStringIgnoringCase($this->messageContains, $actual->getMessage()); } if (isset($this->codeName)) { @@ -178,7 +178,7 @@ private function assertCodeName(TestCase $test, Exception $actual = null) $test->assertInstanceOf(CommandException::class, $actual); $result = $actual->getResultDocument(); $test->assertObjectHasAttribute('codeName', $result); - $test->assertAttributeSame($this->codeName, 'codeName', $result); + $test->assertSame($this->codeName, $result->codeName); } private static function isArrayOfStrings($array)