public function testOnSchemaIndexDefinitionWithSubpart()
{
/** @var Connection|\PHPUnit_Framework_MockObject_MockObject $event */
$connection = $this->getMock('Doctrine\\DBAL\\Connection', ['getDatabasePlatform', 'fetchAssoc'], [], '', false);
$connection->expects($this->any())->method('getDatabasePlatform')->willReturn(new MySqlPlatform());
$connection->expects($this->once())->method('fetchAssoc')->with("SHOW INDEX FROM tl_files WHERE Key_name='path'")->willReturn(['Table' => 'tl_files', 'Non_unique' => '1', 'Key_name' => 'path', 'Seq_in_index' => '1', 'Column_name' => 'path', 'Collation' => 'A', 'Cardinality' => '903', 'Sub_part' => '333', 'Packed' => null, 'Null' => null, 'Index_type' => 'BTREE', 'Comment' => '', 'Index_comment' => '']);
/** @var SchemaIndexDefinitionEventArgs|\PHPUnit_Framework_MockObject_MockObject $event */
$event = $this->getMock('Doctrine\\DBAL\\Event\\SchemaIndexDefinitionEventArgs', ['getConnection', 'getTable', 'getTableIndex', 'preventDefault'], [], '', false);
$event->expects($this->any())->method('getConnection')->willReturn($connection);
$event->expects($this->any())->method('getTable')->willReturn('tl_files');
$event->expects($this->any())->method('getTableIndex')->willReturn($this->getIndexEventArg('path'));
$event->expects($this->once())->method('preventDefault');
$listener = new DoctrineSchemaListener($this->getMock('Contao\\CoreBundle\\Doctrine\\Schema\\DcaSchemaProvider', [], [], '', false));
$listener->onSchemaIndexDefinition($event);
$index = $event->getIndex();
$this->assertInstanceOf('Doctrine\\DBAL\\Schema\\Index', $index);
$this->assertEquals('path', $index->getName());
$this->assertEquals(['path(333)'], $index->getColumns());
}