Drop SQLite support (#2405)

This commit is contained in:
Kevin Papst
2021-03-08 16:06:22 +01:00
committed by GitHub
parent 70f7f35009
commit 30ac5e4c24
78 changed files with 1165 additions and 1596 deletions

View File

@@ -1,71 +0,0 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Tests\Doctrine;
use App\Doctrine\SqliteSessionInitSubscriber;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Event\ConnectionEventArgs;
use Doctrine\DBAL\Events;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use PHPUnit\Framework\TestCase;
/**
* @covers \App\Doctrine\SqliteSessionInitSubscriber
*/
class SqliteSessionInitSubscriberTest extends TestCase
{
public function testGetSubscribedEvents()
{
$sut = new SqliteSessionInitSubscriber();
$events = $sut->getSubscribedEvents();
$this->assertTrue(\in_array(Events::postConnect, $events));
}
public function testPostConnectWithSqlite()
{
$sut = new SqliteSessionInitSubscriber();
$platformMock = $this->getMockBuilder(SqlitePlatform::class)
->onlyMethods(['getName'])
->disableOriginalConstructor()
->getMock();
$platformMock->expects($this->once())->method('getName')->willReturn('sqlite');
$connectionMock = $this->createMock(Connection::class);
$connectionMock->expects($this->once())->method('getDatabasePlatform')->willReturn($platformMock);
$connectionMock->expects($this->once())->method('exec')->with('PRAGMA foreign_keys = ON;');
$args = new ConnectionEventArgs($connectionMock);
$sut->postConnect($args);
}
public function testPostConnectWithMysql()
{
$sut = new SqliteSessionInitSubscriber();
$platformMock = $this->getMockBuilder(MySqlPlatform::class)
->onlyMethods(['getName'])
->disableOriginalConstructor()
->getMock();
$platformMock->expects($this->once())->method('getName')->willReturn('mysql');
$connectionMock = $this->createMock(Connection::class);
$connectionMock->expects($this->once())->method('getDatabasePlatform')->willReturn($platformMock);
$connectionMock->expects($this->never())->method('exec')->with('PRAGMA foreign_keys = ON;');
$args = new ConnectionEventArgs($connectionMock);
$sut->postConnect($args);
}
}

View File

@@ -12,9 +12,9 @@ namespace App\Tests\Doctrine;
use App\Doctrine\UTCDateTimeType;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use PHPUnit\Framework\TestCase;
/**
@@ -24,9 +24,9 @@ class UTCDateTimeTypeTest extends TestCase
{
public function testGetUtc()
{
Type::overrideType(Type::DATETIME, UTCDateTimeType::class);
Type::overrideType(Types::DATETIME_MUTABLE, UTCDateTimeType::class);
/** @var UTCDateTimeType $type */
$type = Type::getType(Type::DATETIME);
$type = Type::getType(Types::DATETIME_MUTABLE);
$this->assertInstanceOf(UTCDateTimeType::class, $type);
$utc = $type::getUtc();
@@ -39,9 +39,9 @@ class UTCDateTimeTypeTest extends TestCase
*/
public function testConvertToDatabaseValue(AbstractPlatform $platform)
{
Type::overrideType(Type::DATETIME, UTCDateTimeType::class);
Type::overrideType(Types::DATETIME_MUTABLE, UTCDateTimeType::class);
/** @var UTCDateTimeType $type */
$type = Type::getType(Type::DATETIME);
$type = Type::getType(Types::DATETIME_MUTABLE);
$result = $type->convertToDatabaseValue(null, $platform);
$this->assertNull($result);
@@ -67,9 +67,9 @@ class UTCDateTimeTypeTest extends TestCase
*/
public function testConvertToPHPValue(AbstractPlatform $platform)
{
Type::overrideType(Type::DATETIME, UTCDateTimeType::class);
Type::overrideType(Types::DATETIME_MUTABLE, UTCDateTimeType::class);
/** @var UTCDateTimeType $type */
$type = Type::getType(Type::DATETIME);
$type = Type::getType(Types::DATETIME_MUTABLE);
$result = $type->convertToPHPValue(null, $platform);
$this->assertNull($result);
@@ -89,9 +89,9 @@ class UTCDateTimeTypeTest extends TestCase
{
$this->expectException(ConversionException::class);
Type::overrideType(Type::DATETIME, UTCDateTimeType::class);
Type::overrideType(Types::DATETIME_MUTABLE, UTCDateTimeType::class);
/** @var UTCDateTimeType $type */
$type = Type::getType(Type::DATETIME);
$type = Type::getType(Types::DATETIME_MUTABLE);
$type->convertToPHPValue('201xx01-17 13:30:00', $platform);
}
@@ -101,9 +101,9 @@ class UTCDateTimeTypeTest extends TestCase
*/
public function testRequiresSQLCommentHint(AbstractPlatform $platform)
{
Type::overrideType(Type::DATETIME, UTCDateTimeType::class);
Type::overrideType(Types::DATETIME_MUTABLE, UTCDateTimeType::class);
/** @var UTCDateTimeType $type */
$type = Type::getType(Type::DATETIME);
$type = Type::getType(Types::DATETIME_MUTABLE);
self::assertTrue($type->requiresSQLCommentHint($platform));
}
@@ -111,7 +111,6 @@ class UTCDateTimeTypeTest extends TestCase
{
return [
[new MySqlPlatform()],
[new SqlitePlatform()],
];
}
}