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

testUpdateOne() public method

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