ExplainTest.php 1.16 KB
Newer Older
1 2 3 4
<?php

namespace MongoDB\Tests\Operation;

5
use MongoDB\Exception\InvalidArgumentException;
6
use MongoDB\Operation\Explain;
7
use MongoDB\Operation\Explainable;
8 9 10 11 12 13

class ExplainTest extends TestCase
{
    /**
     * @dataProvider provideInvalidConstructorOptions
     */
14
    public function testConstructorOptionTypeChecks(array $options)
15
    {
16
        $explainable = $this->getMockBuilder(Explainable::class)->getMock();
17
        $this->expectException(InvalidArgumentException::class);
18 19 20 21 22 23 24
        new Explain($this->getDatabaseName(), $explainable, $options);
    }

    public function provideInvalidConstructorOptions()
    {
        $options = [];

25 26 27 28 29 30 31 32
        foreach ($this->getInvalidReadPreferenceValues() as $value) {
            $options[][] = ['readPreference' => $value];
        }

        foreach ($this->getInvalidSessionValues() as $value) {
            $options[][] = ['session' => $value];
        }

33 34 35 36 37 38 39 40 41 42 43
        foreach ($this->getInvalidStringValues() as $value) {
            $options[][] = ['verbosity' => $value];
        }

        foreach ($this->getInvalidArrayValues() as $value) {
            $options[][] = ['typeMap' => $value];
        }

        return $options;
    }
}