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

namespace MongoDB\Tests\Operation;

use MongoDB\Operation\InsertOne;

class InsertOneTest extends TestCase
{
    /**
10
     * @expectedException MongoDB\Exception\InvalidArgumentException
11
     * @dataProvider provideInvalidDocumentValues
12
     */
13
    public function testConstructorDocumentArgumentTypeCheck($document)
14 15 16 17 18
    {
        new InsertOne($this->getDatabaseName(), $this->getCollectionName(), $document);
    }

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

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

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

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

39
        foreach ($this->getInvalidWriteConcernValues() as $value) {
Jeremy Mikola's avatar
Jeremy Mikola committed
40
            $options[][] = ['writeConcern' => $value];
41 42 43
        }

        return $options;
44 45
    }
}