initIndexes() public method

Create indexes based on self::$_index metadata
public initIndexes ( ) : Collection
return Collection
Example #1
0
 /**
  * @expectedException \Sokil\Mongo\Exception
  * @expectedExceptionMessage Keys not specified
  */
 public function testInitIndexes_KeysNotSpecified()
 {
     $reflection = new \ReflectionClass($this->collection);
     $property = $reflection->getProperty('definition');
     $property->setAccessible(true);
     $definition = $property->getValue($this->collection);
     $definition->setOption('index', array(array('unique' => true)));
     $this->collection->initIndexes();
     $indexes = $this->collection->getIndexes();
     $this->assertEquals(array('asc' => 1, 'desc' => -1), $indexes[1]['key']);
     $this->assertArrayHasKey('unique', $indexes[1]);
 }