Commit fefdb978 authored by Katherine Walker's avatar Katherine Walker

Improve ExplainTest and ExplainFunctionalTest

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