diff options
Diffstat (limited to 'www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/SQLStore/TableBuilder/TableBuilderTest.php')
-rw-r--r-- | www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/SQLStore/TableBuilder/TableBuilderTest.php | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/SQLStore/TableBuilder/TableBuilderTest.php b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/SQLStore/TableBuilder/TableBuilderTest.php new file mode 100644 index 00000000..edcdbda7 --- /dev/null +++ b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/SQLStore/TableBuilder/TableBuilderTest.php @@ -0,0 +1,83 @@ +<?php + +namespace SMW\Tests\SQLStore\TableBuilder; + +use SMW\SQLStore\TableBuilder\TableBuilder; +use SMW\Tests\PHPUnitCompat; + +/** + * @covers \SMW\SQLStore\TableBuilder\TableBuilder + * @group semantic-mediawiki + * + * @license GNU GPL v2+ + * @since 2.5 + * + * @author mwjames + */ +class TableBuilderTest extends \PHPUnit_Framework_TestCase { + + use PHPUnitCompat; + + public function testCanConstructForMySQL() { + + $connection = $this->getMockBuilder( '\DatabaseBase' ) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $connection->expects( $this->any() ) + ->method( 'getType' ) + ->will( $this->returnValue( 'mysql' ) ); + + $this->assertInstanceOf( + '\SMW\SQLStore\TableBuilder\MySQLTableBuilder', + TableBuilder::factory( $connection ) + ); + } + + public function testCanConstructForSQLite() { + + $connection = $this->getMockBuilder( '\DatabaseBase' ) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $connection->expects( $this->any() ) + ->method( 'getType' ) + ->will( $this->returnValue( 'sqlite' ) ); + + $this->assertInstanceOf( + '\SMW\SQLStore\TableBuilder\SQLiteTableBuilder', + TableBuilder::factory( $connection ) + ); + } + + public function testCanConstructForPostgres() { + + $connection = $this->getMockBuilder( '\DatabaseBase' ) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $connection->expects( $this->any() ) + ->method( 'getType' ) + ->will( $this->returnValue( 'postgres' ) ); + + $this->assertInstanceOf( + '\SMW\SQLStore\TableBuilder\PostgresTableBuilder', + TableBuilder::factory( $connection ) + ); + } + + public function testTryToConstructOnInvalidTypeThrowsException() { + + $connection = $this->getMockBuilder( '\DatabaseBase' ) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $connection->expects( $this->any() ) + ->method( 'getType' ) + ->will( $this->returnValue( 'foo' ) ); + + $this->setExpectedException( 'RuntimeException' ); + TableBuilder::factory( $connection ); + } + +} |