Alcaeus\MongoDbAdapter\Tests\Mongo\MongoInsertBatchTest::testInsertBatch PHP Method

testInsertBatch() public method

public testInsertBatch ( )
    public function testInsertBatch()
    {
        $batch = new \MongoInsertBatch($this->getCollection());
        $this->assertTrue($batch->add(['foo' => 'bar']));
        $this->assertTrue($batch->add(['bar' => 'foo']));
        $expected = ['nInserted' => 2, '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('bar', 'foo', $record);
    }