DropIndexesTest.php 1.3 KB
Newer Older
1 2 3 4
<?php

namespace MongoDB\Tests\Operation;

5
use MongoDB\Exception\InvalidArgumentException;
6 7 8 9 10 11
use MongoDB\Operation\DropIndexes;

class DropIndexesTest extends TestCase
{
    public function testDropIndexShouldNotAllowEmptyIndexName()
    {
12
        $this->expectException(InvalidArgumentException::class);
13 14
        new DropIndexes($this->getDatabaseName(), $this->getCollectionName(), '');
    }
15 16 17 18 19 20

    /**
     * @dataProvider provideInvalidConstructorOptions
     */
    public function testConstructorOptionTypeChecks(array $options)
    {
21
        $this->expectException(InvalidArgumentException::class);
22 23 24 25 26 27 28
        new DropIndexes($this->getDatabaseName(), $this->getCollectionName(), '*', $options);
    }

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

29 30 31 32
        foreach ($this->getInvalidIntegerValues() as $value) {
            $options[][] = ['maxTimeMS' => $value];
        }

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

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

41 42 43 44
        foreach ($this->getInvalidWriteConcernValues() as $value) {
            $options[][] = ['writeConcern' => $value];
        }

45 46
        return $options;
    }
47
}