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,38 +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\Command;
use App\Command\CreateReleaseCommand;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
/**
* @covers \App\Command\CreateReleaseCommand
* @group integration
*/
class CreateReleaseCommandTest extends KernelTestCase
{
public function testCommandName()
{
$kernel = self::bootKernel(['environment' => 'test']);
$application = new Application($kernel);
$application->add(new CreateReleaseCommand(realpath(__DIR__ . '/../../'), 'test'));
$command = $application->find('kimai:create-release');
self::assertTrue($command->isEnabled());
self::assertInstanceOf(CreateReleaseCommand::class, $command);
}
public function testCommandNameIsNotAvailableInProd()
{
$command = new CreateReleaseCommand(realpath(__DIR__ . '/../../'), 'prod');
self::assertFalse($command->isEnabled());
}
}

View File

@@ -10,11 +10,9 @@
namespace App\Tests\Command;
use App\Command\InstallCommand;
use App\Constants;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Tester\CommandTester;
/**
* @covers \App\Command\InstallCommand
@@ -40,30 +38,4 @@ class InstallCommandTest extends KernelTestCase
return $this->application->find('kimai:install');
}
public function testFullRunWithEverythingPreInstalled()
{
$command = $this->getCommand();
$commandTester = new CommandTester($command);
$commandTester->setInputs(['no']);
$commandTester->execute([
'command' => $command->getName(),
]);
$result = $commandTester->getDisplay();
self::assertStringContainsString('Kimai installation running', $result);
// create database is skipped
self::assertStringContainsString('[NOTE] Database is existing and connection could be established', $result);
// make sure migrations run always
self::assertStringContainsString('Application Migrations', $result);
self::assertStringContainsString('No migrations to execute.', $result);
self::assertStringContainsString(
sprintf('[OK] Congratulations! Successfully installed Kimai 2 version %s (%s)', Constants::VERSION, Constants::STATUS),
$result
);
self::assertEquals(0, $commandTester->getStatusCode());
}
}

View File

@@ -21,7 +21,7 @@ use App\Repository\ProjectRepository;
use App\Repository\TimesheetRepository;
use App\Repository\UserRepository;
use App\Tests\DataFixtures\CustomerFixtures;
use App\Tests\DataFixtures\InvoiceFixtures;
use App\Tests\DataFixtures\InvoiceTemplateFixtures;
use App\Tests\DataFixtures\ProjectFixtures;
use App\Tests\DataFixtures\TimesheetFixtures;
use App\Tests\KernelTestTrait;
@@ -176,7 +176,7 @@ class InvoiceCreateCommandTest extends KernelTestCase
public function testCreateInvoice()
{
$fixture = new InvoiceFixtures();
$fixture = new InvoiceTemplateFixtures();
$this->importFixture($fixture);
$commandTester = $this->createInvoice(['--user' => UserFixtures::USERNAME_SUPER_ADMIN, '--set-exported' => null, '--customer' => 1, '--template' => 'Invoice', '--start' => '2020-01-01', '--end' => '2020-03-01']);
@@ -185,7 +185,7 @@ class InvoiceCreateCommandTest extends KernelTestCase
$this->assertStringContainsString('+----+----------+-------+------------- Created 1 invoice(s) --------------------------------------+', $output);
$this->assertStringContainsString('| ID | Customer | Total | Filename |', $output);
$this->assertStringContainsString('+----+----------+-------+-------------------------------------------------------------------------+', $output);
$this->assertStringContainsString('| 1 | Test | 0 EUR | /', $output);
$this->assertStringContainsString('| Test | 0 EUR | /', $output);
$this->assertStringContainsString('/tests/_data/invoices/' . ((new \DateTime())->format('Y')) . '-001-Test.html |', $output);
}
@@ -201,22 +201,24 @@ class InvoiceCreateCommandTest extends KernelTestCase
$meta->setValue('Invoice');
$customer->setMetaField($meta);
});
$this->importFixture($fixture);
$customer = $this->importFixture($fixture)[0];
$fixture = new ProjectFixtures();
$fixture->setCustomers([$em->getRepository(Customer::class)->find(2)]);
$fixture->setCustomers([$customer]);
$fixture->setAmount(1);
$this->importFixture($fixture);
$projects = $this->importFixture($fixture);
$fixture = new TimesheetFixtures();
$fixture->setUser($this->getUserByName(UserFixtures::USERNAME_SUPER_ADMIN));
$fixture->setAmount(20);
$fixture->setStartDate($start);
$fixture->setProjects([$em->getRepository(Project::class)->find(2)]);
$fixture->setProjects($projects);
$this->importFixture($fixture);
$fixture = new InvoiceFixtures();
$fixture = new InvoiceTemplateFixtures();
$this->importFixture($fixture);
return [$customer];
}
public function testCreateInvoiceByCustomer()
@@ -237,9 +239,10 @@ class InvoiceCreateCommandTest extends KernelTestCase
$start = new \DateTime('-2 months');
$end = new \DateTime();
$this->prepareFixtures($start);
$imports = $this->prepareFixtures($start);
$customer = $imports[0]->getId();
$commandTester = $this->createInvoice(['--user' => UserFixtures::USERNAME_SUPER_ADMIN, '--customer' => '2,1', '--template-meta' => 'template', '--start' => $start->format('Y-m-d'), '--end' => $end->format('Y-m-d')]);
$commandTester = $this->createInvoice(['--user' => UserFixtures::USERNAME_SUPER_ADMIN, '--customer' => $customer . ',1', '--template-meta' => 'template', '--start' => $start->format('Y-m-d'), '--end' => $end->format('Y-m-d')]);
$output = $commandTester->getDisplay();
$this->assertStringContainsString('Created 1 invoice(s) ', $output);

View File

@@ -9,29 +9,30 @@
namespace App\Tests\Command;
use App\Command\ResetCommand;
use App\Command\ResetDevelopmentCommand;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
/**
* @covers \App\Command\ResetCommand
* @covers \App\Command\ResetDevelopmentCommand
* @group integration
*/
class ResetCommandTest extends KernelTestCase
class ResetDevelopmentCommandTest extends KernelTestCase
{
public function testCommandName()
{
$kernel = self::bootKernel();
$application = new Application($kernel);
$application->add(new ResetCommand('test'));
$application->add(new ResetDevelopmentCommand('test', $this->createMock(EntityManagerInterface::class)));
$command = $application->find('kimai:reset-dev');
self::assertInstanceOf(ResetCommand::class, $command);
self::assertInstanceOf(ResetDevelopmentCommand::class, $command);
}
public function testCommandNameIsNotEnabledInProd()
{
$command = new ResetCommand('prod');
$command = new ResetDevelopmentCommand('prod', $this->createMock(EntityManagerInterface::class));
self::assertFalse($command->isEnabled());
}
}

View File

@@ -0,0 +1,38 @@
<?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\Command;
use App\Command\ResetTestCommand;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
/**
* @covers \App\Command\ResetTestCommand
* @group integration
*/
class ResetTestCommandTest extends KernelTestCase
{
public function testCommandName()
{
$kernel = self::bootKernel();
$application = new Application($kernel);
$application->add(new ResetTestCommand('test', $this->createMock(EntityManagerInterface::class)));
$command = $application->find('kimai:reset-test');
self::assertInstanceOf(ResetTestCommand::class, $command);
}
public function testCommandNameIsNotEnabledInProd()
{
$command = new ResetTestCommand('prod', $this->createMock(EntityManagerInterface::class));
self::assertFalse($command->isEnabled());
}
}