Skip to content

Commit 342ff3f

Browse files
committed
PHPLIB-530: Remove checks against MapReduce statistics on 4.3.0+
1 parent 4b5a0a1 commit 342ff3f

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

src/MapReduceResult.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ class MapReduceResult implements IteratorAggregate
5555
public function __construct(callable $getIterator, stdClass $result)
5656
{
5757
$this->getIterator = $getIterator;
58-
$this->executionTimeMS = (integer) $result->timeMillis;
59-
$this->counts = (array) $result->counts;
58+
$this->executionTimeMS = isset($result->timeMillis) ? (integer) $result->timeMillis : 0;
59+
$this->counts = isset($result->counts) ? (array) $result->counts : [];
6060
$this->timing = isset($result->timing) ? (array) $result->timing : [];
6161
}
6262

tests/Collection/CollectionFunctionalTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,10 @@ public function testMapReduce()
396396

397397
$this->assertSameDocuments($expected, $result);
398398

399-
$this->assertGreaterThanOrEqual(0, $result->getExecutionTimeMS());
400-
$this->assertNotEmpty($result->getCounts());
399+
if (version_compare($this->getServerVersion(), '4.3.0', '<')) {
400+
$this->assertGreaterThanOrEqual(0, $result->getExecutionTimeMS());
401+
$this->assertNotEmpty($result->getCounts());
402+
}
401403
}
402404

403405
public function collectionMethodClosures()

tests/Operation/MapReduceFunctionalTest.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,19 @@ public function testResult()
9292
$result = $operation->execute($this->getPrimaryServer());
9393

9494
$this->assertInstanceOf(MapReduceResult::class, $result);
95-
$this->assertGreaterThanOrEqual(0, $result->getExecutionTimeMS());
96-
$this->assertNotEmpty($result->getCounts());
95+
96+
if (version_compare($this->getServerVersion(), '4.3.0', '<')) {
97+
$this->assertGreaterThanOrEqual(0, $result->getExecutionTimeMS());
98+
$this->assertNotEmpty($result->getCounts());
99+
}
97100
}
98101

99102
public function testResultIncludesTimingWithVerboseOption()
100103
{
104+
if (version_compare($this->getServerVersion(), '4.3.0', '>=')) {
105+
$this->markTestSkipped('mapReduce statistics are no longer exposed');
106+
}
107+
101108
$this->createFixtures(3);
102109

103110
$map = new Javascript('function() { emit(this.x, this.y); }');
@@ -115,6 +122,10 @@ public function testResultIncludesTimingWithVerboseOption()
115122

116123
public function testResultDoesNotIncludeTimingWithoutVerboseOption()
117124
{
125+
if (version_compare($this->getServerVersion(), '4.3.0', '>=')) {
126+
$this->markTestSkipped('mapReduce statistics are no longer exposed');
127+
}
128+
118129
$this->createFixtures(3);
119130

120131
$map = new Javascript('function() { emit(this.x, this.y); }');

0 commit comments

Comments
 (0)