Alcaeus\MongoDbAdapter\Tests\Mongo\MongoCollectionTest::testCreateIndex PHP Method

testCreateIndex() public method

public testCreateIndex ( )
    public function testCreateIndex()
    {
        $expected = ['createdCollectionAutomatically' => true, 'numIndexesBefore' => 1, 'numIndexesAfter' => 2, 'ok' => 1.0];
        $collection = $this->getCollection();
        $this->assertSame($expected, $collection->createIndex(['foo' => 1]));
        $newCollection = $this->getCheckDatabase()->selectCollection('test');
        $iterator = $newCollection->listIndexes();
        $indexes = iterator_to_array($iterator);
        $this->assertCount(2, $indexes);
        $index = $indexes[1];
        $this->assertSame(['foo' => 1], $index->getKey());
        $this->assertSame('mongo-php-adapter.test', $index->getNamespace());
    }
MongoCollectionTest