. * */ namespace OCA\News\Db; require_once(__DIR__ . "/../../classloader.php"); class MapperTest extends \PHPUnit_Framework_TestCase { public function setUp() { $this->api = $this->getMockBuilder('\OCA\AppFramework\Core\API') ->disableOriginalConstructor() ->getMock(); } public function testGetItemMapperSqlite() { $this->api->expects($this->once()) ->method('getSystemValue') ->with($this->equalTo('dbtype')) ->will($this->returnValue('sqlite')); $factory = new MapperFactory($this->api); $this->assertTrue($factory->getItemMapper() instanceof ItemMapper); } public function testGetItemMapperMysql() { $this->api->expects($this->once()) ->method('getSystemValue') ->with($this->equalTo('dbtype')) ->will($this->returnValue('mysql')); $factory = new MapperFactory($this->api); $this->assertTrue($factory->getItemMapper() instanceof ItemMapper); } public function testGetItemMapperPostgres() { $this->api->expects($this->once()) ->method('getSystemValue') ->with($this->equalTo('dbtype')) ->will($this->returnValue('pgsql')); $factory = new MapperFactory($this->api); $this->assertTrue($factory->getItemMapper() instanceof \OCA\News\Db\Postgres\ItemMapper); } }