Commit fefdb978 authored by Katherine Walker's avatar Katherine Walker

Improve ExplainTest and ExplainFunctionalTest

parent c7b2b033
......@@ -80,16 +80,12 @@ class Explain implements Executable
throw UnsupportedException::explainNotSupported();
}
if ($this->explainable instanceOf \MongoDB\Operation\Distinct) {
if (! \MongoDB\server_supports_feature($server, self::$wireVersionForDistinct)) {
throw UnsupportedException::explainNotSupported();
}
if ($this->explainable instanceof \MongoDB\Operation\Distinct && ! \MongoDB\server_supports_feature($server, self::$wireVersionForDistinct)) {
throw UnsupportedException::explainNotSupported();
}
if ($this->explainable instanceOf \MongoDB\Operation\FindAndModify) {
if (! \MongoDB\server_supports_feature($server, self::$wireVersionForFindAndModify)) {
throw UnsupportedException::explainNotSupported();
}
if ($this->explainable instanceof \MongoDB\Operation\FindAndModify && ! \MongoDB\server_supports_feature($server, self::$wireVersionForFindAndModify)) {
throw UnsupportedException::explainNotSupported();
}
$cmd = ['explain' => $this->explainable->getCommandDocument()];
......
This diff is collapsed.
......@@ -12,19 +12,9 @@ class ExplainTest extends TestCase
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
*/
public function testConstructorOptionTypeChecksForCount(array $options)
public function testConstructorOptionTypeChecks(array $options)
{
$explainable = new Count($this->getDatabaseName(), $this->getCollectionName(),[]);
new Explain($this->getDatabaseName(), $explainable, $options);
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
*/
public function testConstructorOptionTypeChecksForDistinct(array $options)
{
$explainable = new Distinct($this->getDatabaseName(), $this->getCollectionName(), 'x', []);
$explainable = $this->createMock('MongoDB\Operation\Explainable');
new Explain($this->getDatabaseName(), $explainable, $options);
}
......
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