Import used classes

This commit is contained in:
Yassine Guedidi
2022-08-28 16:59:43 +02:00
parent dace00d7fb
commit d1d56fbe25
32 changed files with 145 additions and 104 deletions

View File

@ -3,6 +3,7 @@
namespace Tests\Wallabag\CoreBundle\Command;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Exception\RuntimeException;
use Symfony\Component\Console\Tester\CommandTester;
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
use Wallabag\CoreBundle\Command\ExportCommand;
@ -11,7 +12,7 @@ class ExportCommandTest extends WallabagCoreTestCase
{
public function testExportCommandWithoutUsername()
{
$this->expectException(\Symfony\Component\Console\Exception\RuntimeException::class);
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('Not enough arguments (missing: "username")');
$application = new Application($this->getClient()->getKernel());

View File

@ -6,6 +6,7 @@ use DAMA\DoctrineTestBundle\Doctrine\DBAL\StaticDriver;
use Doctrine\Bundle\DoctrineBundle\Command\CreateDatabaseDoctrineCommand;
use Doctrine\Bundle\DoctrineBundle\Command\DropDatabaseDoctrineCommand;
use Doctrine\Bundle\MigrationsBundle\Command\MigrationsMigrateDoctrineCommand;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\Persistence\ManagerRegistry;
@ -35,7 +36,7 @@ class InstallCommandTest extends WallabagCoreTestCase
{
parent::setUp();
/** @var \Doctrine\DBAL\Connection $connection */
/** @var Connection $connection */
$connection = $this->getClient()->getContainer()->get(ManagerRegistry::class)->getConnection();
if ($connection->getDatabasePlatform() instanceof PostgreSqlPlatform) {
/*
@ -143,7 +144,7 @@ class InstallCommandTest extends WallabagCoreTestCase
{
// skipped SQLite check when database is removed because while testing for the connection,
// the driver will create the file (so the database) before testing if database exist
if ($this->getClient()->getContainer()->get(ManagerRegistry::class)->getConnection()->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) {
if ($this->getClient()->getContainer()->get(ManagerRegistry::class)->getConnection()->getDatabasePlatform() instanceof SqlitePlatform) {
$this->markTestSkipped('SQLite spotted: can\'t test with database removed.');
}

View File

@ -4,6 +4,7 @@ namespace Tests\Wallabag\CoreBundle\Command;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Exception\RuntimeException;
use Symfony\Component\Console\Tester\CommandTester;
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
use Wallabag\CoreBundle\Command\ShowUserCommand;
@ -13,7 +14,7 @@ class ShowUserCommandTest extends WallabagCoreTestCase
{
public function testRunShowUserCommandWithoutUsername()
{
$this->expectException(\Symfony\Component\Console\Exception\RuntimeException::class);
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('Not enough arguments');
$application = new Application($this->getClient()->getKernel());

View File

@ -3,6 +3,7 @@
namespace Tests\Wallabag\CoreBundle\Command;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Exception\RuntimeException;
use Symfony\Component\Console\Tester\CommandTester;
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
use Wallabag\CoreBundle\Command\TagAllCommand;
@ -11,7 +12,7 @@ class TagAllCommandTest extends WallabagCoreTestCase
{
public function testRunTagAllCommandWithoutUsername()
{
$this->expectException(\Symfony\Component\Console\Exception\RuntimeException::class);
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('Not enough arguments (missing: "username")');
$application = new Application($this->getClient()->getKernel());

View File

@ -3,6 +3,9 @@
namespace Tests\Wallabag\CoreBundle\Event\Subscriber;
use Doctrine\Common\EventManager;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\ORM\Event\LoadClassMetadataEventArgs;
use Doctrine\ORM\Mapping\ClassMetadata;
use PHPUnit\Framework\TestCase;
@ -13,21 +16,21 @@ class TablePrefixSubscriberTest extends TestCase
public function dataForPrefix()
{
return [
['wallabag_', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'wallabag_user', '"wallabag_user"', new \Doctrine\DBAL\Platforms\PostgreSqlPlatform()],
['wallabag_', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'wallabag_user', '`wallabag_user`', new \Doctrine\DBAL\Platforms\MySqlPlatform()],
['wallabag_', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'wallabag_user', '"wallabag_user"', new \Doctrine\DBAL\Platforms\SqlitePlatform()],
['wallabag_', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'wallabag_user', '"wallabag_user"', new PostgreSqlPlatform()],
['wallabag_', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'wallabag_user', '`wallabag_user`', new MySqlPlatform()],
['wallabag_', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'wallabag_user', '"wallabag_user"', new SqlitePlatform()],
['wallabag_', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'wallabag_user', 'wallabag_user', new \Doctrine\DBAL\Platforms\PostgreSqlPlatform()],
['wallabag_', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'wallabag_user', 'wallabag_user', new \Doctrine\DBAL\Platforms\MySqlPlatform()],
['wallabag_', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'wallabag_user', 'wallabag_user', new \Doctrine\DBAL\Platforms\SqlitePlatform()],
['wallabag_', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'wallabag_user', 'wallabag_user', new PostgreSqlPlatform()],
['wallabag_', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'wallabag_user', 'wallabag_user', new MySqlPlatform()],
['wallabag_', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'wallabag_user', 'wallabag_user', new SqlitePlatform()],
['', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'user', '"user"', new \Doctrine\DBAL\Platforms\PostgreSqlPlatform()],
['', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'user', '`user`', new \Doctrine\DBAL\Platforms\MySqlPlatform()],
['', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'user', '"user"', new \Doctrine\DBAL\Platforms\SqlitePlatform()],
['', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'user', '"user"', new PostgreSqlPlatform()],
['', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'user', '`user`', new MySqlPlatform()],
['', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'user', '"user"', new SqlitePlatform()],
['', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'user', 'user', new \Doctrine\DBAL\Platforms\PostgreSqlPlatform()],
['', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'user', 'user', new \Doctrine\DBAL\Platforms\MySqlPlatform()],
['', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'user', 'user', new \Doctrine\DBAL\Platforms\SqlitePlatform()],
['', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'user', 'user', new PostgreSqlPlatform()],
['', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'user', 'user', new MySqlPlatform()],
['', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'user', 'user', new SqlitePlatform()],
];
}
@ -110,6 +113,6 @@ class TablePrefixSubscriberTest extends TestCase
$this->assertSame('yo_entry', $metaDataEvent->getClassMetadata()->getTableName());
$this->assertSame('yo_entry_tag', $metaDataEvent->getClassMetadata()->associationMappings['tags']['joinTable']['name']);
$this->assertSame('yo_entry', $metaDataEvent->getClassMetadata()->getQuotedTableName(new \Doctrine\DBAL\Platforms\MySqlPlatform()));
$this->assertSame('yo_entry', $metaDataEvent->getClassMetadata()->getQuotedTableName(new MySqlPlatform()));
}
}

View File

@ -5,6 +5,7 @@ namespace Tests\Wallabag\CoreBundle\ParamConverter;
use PHPUnit\Framework\TestCase;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Wallabag\CoreBundle\ParamConverter\UsernameFeedTokenConverter;
use Wallabag\UserBundle\Entity\User;
@ -138,7 +139,7 @@ class UsernameFeedTokenConverterTest extends TestCase
public function testApplyUserNotFound()
{
$this->expectException(\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class);
$this->expectException(NotFoundHttpException::class);
$this->expectExceptionMessage('User not found');
$repo = $this->getMockBuilder('Wallabag\UserBundle\Repository\UserRepository')