Alcaeus\MongoDbAdapter\Tests\Mongo\MongoUpdateBatchTest::testUpdateMany PHP Method

testUpdateMany() public method

public testUpdateMany ( )
    public function testUpdateMany()
    {
        $collection = $this->getCollection();
        $batch = new \MongoUpdateBatch($collection);
        $document = ['foo' => 'bar'];
        $collection->insert($document);
        unset($document['_id']);
        $collection->insert($document);
        $this->assertTrue($batch->add(['q' => ['foo' => 'bar'], 'u' => ['$set' => ['foo' => 'foo']], 'multi' => true]));
        $expected = ['nMatched' => 2, 'nModified' => 2, 'nUpserted' => 0, 'ok' => true];
        $this->assertSame($expected, $batch->execute());
        $newCollection = $this->getCheckDatabase()->selectCollection('test');
        $this->assertSame(2, $newCollection->count());
        $record = $newCollection->findOne();
        $this->assertNotNull($record);
        $this->assertObjectHasAttribute('foo', $record);
        $this->assertAttributeSame('foo', 'foo', $record);
    }