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

namespace MongoDB\Tests\Operation;

use MongoDB\Operation\ReplaceOne;

class ReplaceOneTest extends TestCase
{
    /**
10
     * @expectedException MongoDB\Exception\InvalidArgumentException
11
     * @dataProvider provideInvalidDocumentValues
12
     */
13
    public function testConstructorFilterArgumentTypeCheck($filter)
14
    {
Jeremy Mikola's avatar
Jeremy Mikola committed
15
        new ReplaceOne($this->getDatabaseName(), $this->getCollectionName(), $filter, ['y' => 1]);
16 17 18
    }

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

    /**
     * @expectedException MongoDB\Exception\InvalidArgumentException
29
     * @expectedExceptionMessage First key in $replacement argument is an update operator
30 31 32
     */
    public function testConstructorReplacementArgumentRequiresNoOperators()
    {
Jeremy Mikola's avatar
Jeremy Mikola committed
33
        new ReplaceOne($this->getDatabaseName(), $this->getCollectionName(), ['x' => 1], ['$set' => ['x' => 1]]);
34 35
    }
}