Skip to content

Commit 76ef271

Browse files
committed
Merge pull request #470
2 parents 7231d87 + a46f70b commit 76ef271

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

src/Operation/MapReduce.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class MapReduce implements Executable
121121
* applied to the returned Cursor (it is not sent to the server).
122122
*
123123
* * verbose (boolean): Specifies whether to include the timing information
124-
* in the result information. The default is true.
124+
* in the result information.
125125
*
126126
* * writeConcern (MongoDB\Driver\WriteConcern): Write concern. This only
127127
* applies when results are output to a collection.
@@ -143,10 +143,6 @@ public function __construct($databaseName, $collectionName, JavascriptInterface
143143
throw InvalidArgumentException::invalidType('$out', $out, 'string or array or object');
144144
}
145145

146-
$options += [
147-
'verbose' => true,
148-
];
149-
150146
if (isset($options['bypassDocumentValidation']) && ! is_bool($options['bypassDocumentValidation'])) {
151147
throw InvalidArgumentException::invalidType('"bypassDocumentValidation" option', $options['bypassDocumentValidation'], 'boolean');
152148
}

tests/Collection/CollectionFunctionalTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ public function testMapReduce()
201201

202202
$this->assertGreaterThanOrEqual(0, $result->getExecutionTimeMS());
203203
$this->assertNotEmpty($result->getCounts());
204-
$this->assertNotEmpty($result->getTiming());
205204
}
206205

207206
/**

tests/Operation/MapReduceFunctionalTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,22 @@ public function testResult()
9090
$operation = new MapReduce($this->getDatabaseName(), $this->getCollectionName(), $map, $reduce, $out);
9191
$result = $operation->execute($this->getPrimaryServer());
9292

93+
$this->assertInstanceOf('MongoDB\MapReduceResult', $result);
94+
$this->assertGreaterThanOrEqual(0, $result->getExecutionTimeMS());
95+
$this->assertNotEmpty($result->getCounts());
96+
}
97+
98+
public function testResultIncludesTimingWithVerboseOption()
99+
{
100+
$this->createFixtures(3);
101+
102+
$map = new Javascript('function() { emit(this.x, this.y); }');
103+
$reduce = new Javascript('function(key, values) { return Array.sum(values); }');
104+
$out = ['inline' => 1];
105+
106+
$operation = new MapReduce($this->getDatabaseName(), $this->getCollectionName(), $map, $reduce, $out, ['verbose' => true]);
107+
$result = $operation->execute($this->getPrimaryServer());
108+
93109
$this->assertInstanceOf('MongoDB\MapReduceResult', $result);
94110
$this->assertGreaterThanOrEqual(0, $result->getExecutionTimeMS());
95111
$this->assertNotEmpty($result->getCounts());

0 commit comments

Comments
 (0)