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

namespace MongoDB\Tests\Operation;

use MongoDB\Operation\UpdateMany;

class UpdateManyTest 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 UpdateMany($this->getDatabaseName(), $this->getCollectionName(), $filter, ['$set' => ['x' => 1]]);
16 17 18
    }

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

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