Skip to content

Commit a72cbe3

Browse files
committed
Merge pull request #669
2 parents 5042a2f + 83260b5 commit a72cbe3

8 files changed

+41
-22
lines changed

.travis.yml

+7-10
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ cache:
1414

1515
env:
1616
global:
17-
- DRIVER_VERSION=1.6.0alpha2
17+
- DRIVER_VERSION=1.6.0alpha3
1818
- SERVER_DISTRO=ubuntu1604
19-
- SERVER_VERSION=4.0.10
19+
- SERVER_VERSION=4.2.0
2020
- DEPLOYMENT=STANDALONE
2121
- COMPOSER_OPTIONS=
2222

@@ -44,7 +44,7 @@ jobs:
4444
env:
4545
- COMPOSER_OPTIONS=--prefer-lowest
4646

47-
# Test older standalone server versions (3.0-3.6)
47+
# Test older standalone server versions (3.0-4.0)
4848
- stage: Test
4949
php: "7.0"
5050
dist: trusty
@@ -66,6 +66,10 @@ jobs:
6666
php: "7.0"
6767
env:
6868
- SERVER_VERSION=3.6.13
69+
- stage: Test
70+
php: "7.3"
71+
env:
72+
- SERVER_VERSION=4.0.12
6973

7074
# Test other server configurations
7175
- stage: Test
@@ -94,13 +98,6 @@ jobs:
9498
env:
9599
- DEPLOYMENT=SHARDED_CLUSTER_RS
96100

97-
# Test upcoming server versions
98-
- stage: Test
99-
php: "7.3"
100-
env:
101-
- SERVER_VERSION=4.2.0-rc1
102-
- DEPLOYMENT=REPLICASET
103-
104101
before_install:
105102
- pip install "mongo-orchestration>=0.6.7,<1.0" --user `whoami`
106103
- export SERVER_FILENAME=mongodb-linux-x86_64-${SERVER_DISTRO}-${SERVER_VERSION}

.travis/setup_mo.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fi
99
case $DEPLOYMENT in
1010
SHARDED_CLUSTER)
1111
${TRAVIS_BUILD_DIR}/.travis/mo.sh ${TRAVIS_BUILD_DIR}/mongo-orchestration/sharded_clusters/cluster.json start > /tmp/mo-result.json
12-
cat /tmp/mo-result.json | tail -n 1 | php -r 'echo json_decode(file_get_contents("php://stdin"))->mongodb_uri;' > /tmp/uri.txt
12+
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
1313
;;
1414
SHARDED_CLUSTER_RS)
1515
${TRAVIS_BUILD_DIR}/.travis/mo.sh ${TRAVIS_BUILD_DIR}/mongo-orchestration/sharded_clusters/cluster_replset.json start > /tmp/mo-result.json

tests/Collection/CollectionFunctionalTest.php

+7-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use MongoDB\Driver\ReadPreference;
1010
use MongoDB\Driver\WriteConcern;
1111
use MongoDB\Exception\InvalidArgumentException;
12+
use MongoDB\Exception\UnsupportedException;
1213
use MongoDB\Operation\Count;
1314
use MongoDB\Operation\MapReduce;
1415
use MongoDB\Tests\CommandObserver;
@@ -619,8 +620,6 @@ function(array $event) {
619620

620621
/**
621622
* @dataProvider collectionWriteMethodClosures
622-
* @expectedException MongoDB\Exception\UnsupportedException
623-
* @expectedExceptionMessage "writeConcern" option cannot be specified within a transaction
624623
*/
625624
public function testMethodInTransactionWithWriteConcernOption($method)
626625
{
@@ -631,6 +630,9 @@ public function testMethodInTransactionWithWriteConcernOption($method)
631630
$session = $this->manager->startSession();
632631
$session->startTransaction();
633632

633+
$this->expectException(UnsupportedException::class);
634+
$this->expectExceptionMessage('"writeConcern" option cannot be specified within a transaction');
635+
634636
try {
635637
call_user_func($method, $this->collection, $session, ['writeConcern' => new WriteConcern(1)]);
636638
} finally {
@@ -640,8 +642,6 @@ public function testMethodInTransactionWithWriteConcernOption($method)
640642

641643
/**
642644
* @dataProvider collectionReadMethodClosures
643-
* @expectedException MongoDB\Exception\UnsupportedException
644-
* @expectedExceptionMessage "readConcern" option cannot be specified within a transaction
645645
*/
646646
public function testMethodInTransactionWithReadConcernOption($method)
647647
{
@@ -652,6 +652,9 @@ public function testMethodInTransactionWithReadConcernOption($method)
652652
$session = $this->manager->startSession();
653653
$session->startTransaction();
654654

655+
$this->expectException(UnsupportedException::class);
656+
$this->expectExceptionMessage('"readConcern" option cannot be specified within a transaction');
657+
655658
try {
656659
call_user_func($method, $this->collection, $session, ['readConcern' => new ReadConcern(ReadConcern::LOCAL)]);
657660
} finally {

tests/FunctionalTestCase.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ public static function getUri($allowMultipleMongoses = false)
9494
$parts[] = $urlParts['path'];
9595
}
9696
if (isset($urlParts['query'])) {
97-
$parts += [
97+
$parts = array_merge($parts, [
9898
'?',
99-
$urlParts['path']
100-
];
99+
$urlParts['query']
100+
]);
101101
}
102102

103103
return implode('', $parts);

tests/Operation/AggregateFunctionalTest.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,17 @@ function() use ($pipeline, $options) {
217217
$results = iterator_to_array($operation->execute($this->getPrimaryServer()));
218218

219219
$this->assertCount(1, $results);
220-
$this->assertObjectHasAttribute('stages', current($results));
220+
$result = current($results);
221+
222+
if ($this->isShardedCluster()) {
223+
$this->assertObjectHasAttribute('shards', $result);
224+
225+
foreach ($result->shards as $shard) {
226+
$this->assertObjectHasAttribute('stages', $shard);
227+
}
228+
} else {
229+
$this->assertObjectHasAttribute('stages', $result);
230+
}
221231
},
222232
function(array $event) {
223233
$this->assertObjectNotHasAttribute('writeConcern', $event['started']->getCommand());

tests/Operation/WatchFunctionalTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class WatchFunctionalTest extends FunctionalTestCase
2828
{
2929
use SetUpTearDownTrait;
3030

31+
const INTERRUPTED = 11601;
3132
const NOT_MASTER = 10107;
3233

3334
private static $wireVersionForStartAtOperationTime = 7;
@@ -1295,7 +1296,7 @@ public function testErrorDuringAggregateCommandDoesNotCauseResume()
12951296
$this->configureFailPoint([
12961297
'configureFailPoint' => 'failCommand',
12971298
'mode' => ['times' => 1],
1298-
'data' => ['failCommands' => ['aggregate'], 'errorCode' => self::NOT_MASTER],
1299+
'data' => ['failCommands' => ['aggregate'], 'errorCode' => self::INTERRUPTED],
12991300
]);
13001301

13011302
$this->expectException(CommandException::class);

tests/SpecTests/ChangeStreamsSpecTest.php

+8
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
*/
1919
class ChangeStreamsSpecTest extends FunctionalTestCase
2020
{
21+
private static $incompleteTests = [
22+
'change-streams-errors: Change Stream should error when _id is projected out' => 'PHPC-1419',
23+
];
24+
2125
/**
2226
* Assert that the expected and actual command documents match.
2327
*
@@ -66,6 +70,10 @@ public static function assertResult(array $expectedDocuments, array $actualDocum
6670
*/
6771
public function testChangeStreams(stdClass $test, $databaseName = null, $collectionName = null, $database2Name = null, $collection2Name = null)
6872
{
73+
if (isset(self::$incompleteTests[$this->dataDescription()])) {
74+
$this->markTestIncomplete(self::$incompleteTests[$this->dataDescription()]);
75+
}
76+
6977
$this->checkServerRequirements($this->createRunOn($test));
7078

7179
if (!isset($databaseName, $collectionName, $database2Name, $collection2Name)) {

tests/SpecTests/ErrorExpectation.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function assert(TestCase $test, Exception $actual = null)
132132
$test->assertNotNull($actual);
133133

134134
if (isset($this->messageContains)) {
135-
$test->assertContains($this->messageContains, $actual->getMessage(), '', true /* case-insensitive */);
135+
$test->assertStringContainsStringIgnoringCase($this->messageContains, $actual->getMessage());
136136
}
137137

138138
if (isset($this->codeName)) {
@@ -178,7 +178,7 @@ private function assertCodeName(TestCase $test, Exception $actual = null)
178178
$test->assertInstanceOf(CommandException::class, $actual);
179179
$result = $actual->getResultDocument();
180180
$test->assertObjectHasAttribute('codeName', $result);
181-
$test->assertAttributeSame($this->codeName, 'codeName', $result);
181+
$test->assertSame($this->codeName, $result->codeName);
182182
}
183183

184184
private static function isArrayOfStrings($array)

0 commit comments

Comments
 (0)