DistinctTest.php 1.46 KB
Newer Older
1 2 3 4 5 6 7 8 9
<?php

namespace MongoDB\Tests\Operation;

use MongoDB\Operation\Distinct;

class DistinctTest extends TestCase
{
    /**
10
     * @expectedException MongoDB\Exception\InvalidArgumentException
11 12 13 14 15 16 17 18
     * @dataProvider provideInvalidDocumentValues
     */
    public function testConstructorFilterArgumentTypeCheck($filter)
    {
        new Distinct($this->getDatabaseName(), $this->getCollectionName(), 'x', $filter);
    }

    /**
19
     * @expectedException MongoDB\Exception\InvalidArgumentException
20 21 22 23
     * @dataProvider provideInvalidConstructorOptions
     */
    public function testConstructorOptionTypeChecks(array $options)
    {
Jeremy Mikola's avatar
Jeremy Mikola committed
24
        new Distinct($this->getDatabaseName(), $this->getCollectionName(), 'x', [], $options);
25 26 27 28
    }

    public function provideInvalidConstructorOptions()
    {
Jeremy Mikola's avatar
Jeremy Mikola committed
29
        $options = [];
30

31 32 33 34
        foreach ($this->getInvalidDocumentValues() as $value) {
            $options[][] = ['collation' => $value];
        }

35
        foreach ($this->getInvalidIntegerValues() as $value) {
Jeremy Mikola's avatar
Jeremy Mikola committed
36
            $options[][] = ['maxTimeMS' => $value];
37 38
        }

39 40 41 42
        foreach ($this->getInvalidReadConcernValues() as $value) {
            $options[][] = ['readConcern' => $value];
        }

43
        foreach ($this->getInvalidReadPreferenceValues() as $value) {
Jeremy Mikola's avatar
Jeremy Mikola committed
44
            $options[][] = ['readPreference' => $value];
45 46
        }

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

51 52 53
        return $options;
    }
}