getMockBuilder( '\Wikimedia\Rdbms\Database' ) ->disableOriginalConstructor() ->getMockForAbstractClass(); $connection->expects( $this->any() ) ->method( 'getType' ) ->willReturn( 'mysql' ); $this->assertInstanceOf( '\SMW\SQLStore\TableBuilder\MySQLTableBuilder', TableBuilder::factory( $connection ) ); } public function testCanConstructForSQLite() { $connection = $this->getMockBuilder( '\Wikimedia\Rdbms\Database' ) ->disableOriginalConstructor() ->getMockForAbstractClass(); $connection->expects( $this->any() ) ->method( 'getType' ) ->willReturn( 'sqlite' ); $this->assertInstanceOf( '\SMW\SQLStore\TableBuilder\SQLiteTableBuilder', TableBuilder::factory( $connection ) ); } public function testCanConstructForPostgres() { $connection = $this->getMockBuilder( '\Wikimedia\Rdbms\Database' ) ->disableOriginalConstructor() ->getMockForAbstractClass(); $connection->expects( $this->any() ) ->method( 'getType' ) ->willReturn( 'postgres' ); $this->assertInstanceOf( '\SMW\SQLStore\TableBuilder\PostgresTableBuilder', TableBuilder::factory( $connection ) ); } public function testConstructWithInvalidTypeThrowsException() { $connection = $this->getMockBuilder( '\Wikimedia\Rdbms\Database' ) ->disableOriginalConstructor() ->getMockForAbstractClass(); $connection->expects( $this->any() ) ->method( 'getType' ) ->willReturn( 'foo' ); $this->expectException( 'RuntimeException' ); TableBuilder::factory( $connection ); } public function testConstructWithInvalidInstanceThrowsException() { $this->expectException( 'RuntimeException' ); TableBuilder::factory( 'foo' ); } }