Use ::class notation where possible

This commit is contained in:
Yassine Guedidi
2022-09-01 20:54:56 +02:00
parent d1d56fbe25
commit 98af2e25f2
52 changed files with 347 additions and 250 deletions

View File

@ -174,7 +174,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$author = $content->getPublishedBy();
$this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content);
$this->assertInstanceOf(Entry::class, $content);
$this->assertSame($this->url, $content->getUrl());
$this->assertStringContainsString('la cryptomonnaie de Facebook', $content->getTitle());
$this->assertSame('fr', $content->getLanguage());
@ -246,7 +246,7 @@ class EntryControllerTest extends WallabagCoreTestCase
->getRepository(Entry::class)
->findByUrlAndUserId($url, $this->getLoggedInUserId());
$this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content);
$this->assertInstanceOf(Entry::class, $content);
$authors = $content->getPublishedBy();
$this->assertSame('2017-04-05', $content->getPublishedAt()->format('Y-m-d'));
$this->assertSame('fr', $content->getLanguage());
@ -1217,7 +1217,7 @@ class EntryControllerTest extends WallabagCoreTestCase
->getRepository(Entry::class)
->findByUrlAndUserId($url, $this->getLoggedInUserId());
$this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $entry);
$this->assertInstanceOf(Entry::class, $entry);
$this->assertSame($url, $entry->getUrl());
$this->assertStringContainsString('Judo', $entry->getTitle());
// instead of checking for the filename (which might change) check that the image is now local
@ -1536,7 +1536,7 @@ class EntryControllerTest extends WallabagCoreTestCase
->getRepository(Entry::class)
->findByUrlAndUserId($url, $this->getLoggedInUserId());
$this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content);
$this->assertInstanceOf(Entry::class, $content);
$this->assertSame($url, $content->getUrl());
$this->assertSame($expectedLanguage, $content->getLanguage());
}
@ -1587,7 +1587,7 @@ class EntryControllerTest extends WallabagCoreTestCase
->getRepository(Entry::class)
->findByUrlAndUserId($url, $this->getLoggedInUserId());
$this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content);
$this->assertInstanceOf(Entry::class, $content);
$this->assertSame('Quand Manille manœuvre', $content->getTitle());
$client->getContainer()->get(Config::class)->set('restricted_access', 0);

View File

@ -78,7 +78,7 @@ class LocaleListenerTest extends TestCase
private function getEvent(Request $request)
{
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')
$kernel = $this->getMockBuilder(HttpKernelInterface::class)
->disableOriginalConstructor()
->getMock();

View File

@ -6,31 +6,33 @@ use Doctrine\Common\EventManager;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Event\LoadClassMetadataEventArgs;
use Doctrine\ORM\Mapping\ClassMetadata;
use PHPUnit\Framework\TestCase;
use Wallabag\CoreBundle\Event\Subscriber\TablePrefixSubscriber;
use Wallabag\UserBundle\Entity\User;
class TablePrefixSubscriberTest extends TestCase
{
public function dataForPrefix()
{
return [
['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_', User::class, '`user`', 'user', 'wallabag_user', '"wallabag_user"', new PostgreSqlPlatform()],
['wallabag_', User::class, '`user`', 'user', 'wallabag_user', '`wallabag_user`', new MySqlPlatform()],
['wallabag_', User::class, '`user`', 'user', 'wallabag_user', '"wallabag_user"', new 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_', User::class, 'user', 'user', 'wallabag_user', 'wallabag_user', new PostgreSqlPlatform()],
['wallabag_', User::class, 'user', 'user', 'wallabag_user', 'wallabag_user', new MySqlPlatform()],
['wallabag_', User::class, 'user', 'user', 'wallabag_user', 'wallabag_user', new 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()],
['', User::class, '`user`', 'user', 'user', '"user"', new PostgreSqlPlatform()],
['', User::class, '`user`', 'user', 'user', '`user`', new MySqlPlatform()],
['', User::class, '`user`', 'user', 'user', '"user"', new 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()],
['', User::class, 'user', 'user', 'user', 'user', new PostgreSqlPlatform()],
['', User::class, 'user', 'user', 'user', 'user', new MySqlPlatform()],
['', User::class, 'user', 'user', 'user', 'user', new SqlitePlatform()],
];
}
@ -39,7 +41,7 @@ class TablePrefixSubscriberTest extends TestCase
*/
public function testPrefix($prefix, $entityName, $tableName, $tableNameExpected, $finalTableName, $finalTableNameQuoted, $platform)
{
$em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
$em = $this->getMockBuilder(EntityManager::class)
->disableOriginalConstructor()
->getMock();
@ -63,7 +65,7 @@ class TablePrefixSubscriberTest extends TestCase
*/
public function testSubscribedEvents($prefix, $entityName, $tableName, $tableNameExpected, $finalTableName, $finalTableNameQuoted, $platform)
{
$em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
$em = $this->getMockBuilder(EntityManager::class)
->disableOriginalConstructor()
->getMock();
@ -85,7 +87,7 @@ class TablePrefixSubscriberTest extends TestCase
public function testPrefixManyToMany()
{
$em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
$em = $this->getMockBuilder(EntityManager::class)
->disableOriginalConstructor()
->getMock();

View File

@ -2,6 +2,7 @@
namespace Tests\Wallabag\CoreBundle\GuzzleSiteAuthenticator;
use Graby\SiteConfig\ConfigBuilder;
use Graby\SiteConfig\SiteConfig as GrabySiteConfig;
use Monolog\Handler\TestHandler;
use Monolog\Logger;
@ -10,6 +11,7 @@ use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
use Wallabag\CoreBundle\GuzzleSiteAuthenticator\GrabySiteConfigBuilder;
use Wallabag\CoreBundle\Repository\SiteCredentialRepository;
use Wallabag\UserBundle\Entity\User;
class GrabySiteConfigBuilderTest extends WallabagCoreTestCase
{
@ -17,7 +19,7 @@ class GrabySiteConfigBuilderTest extends WallabagCoreTestCase
public function testBuildConfigExists()
{
$grabyConfigBuilderMock = $this->getMockBuilder('Graby\SiteConfig\ConfigBuilder')
$grabyConfigBuilderMock = $this->getMockBuilder(ConfigBuilder::class)
->disableOriginalConstructor()
->getMock();
@ -38,7 +40,7 @@ class GrabySiteConfigBuilderTest extends WallabagCoreTestCase
$handler = new TestHandler();
$logger->pushHandler($handler);
$siteCrentialRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\SiteCredentialRepository')
$siteCrentialRepo = $this->getMockBuilder(SiteCredentialRepository::class)
->disableOriginalConstructor()
->getMock();
$siteCrentialRepo->expects($this->once())
@ -46,7 +48,7 @@ class GrabySiteConfigBuilderTest extends WallabagCoreTestCase
->with(['api.example.com', '.example.com'], 1)
->willReturn(['username' => 'foo', 'password' => 'bar']);
$user = $this->getMockBuilder('Wallabag\UserBundle\Entity\User')
$user = $this->getMockBuilder(User::class)
->disableOriginalConstructor()
->getMock();
$user->expects($this->once())
@ -84,7 +86,7 @@ class GrabySiteConfigBuilderTest extends WallabagCoreTestCase
public function testBuildConfigDoesntExist()
{
$grabyConfigBuilderMock = $this->getMockBuilder('\Graby\SiteConfig\ConfigBuilder')
$grabyConfigBuilderMock = $this->getMockBuilder(ConfigBuilder::class)
->disableOriginalConstructor()
->getMock();
@ -97,7 +99,7 @@ class GrabySiteConfigBuilderTest extends WallabagCoreTestCase
$handler = new TestHandler();
$logger->pushHandler($handler);
$siteCrentialRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\SiteCredentialRepository')
$siteCrentialRepo = $this->getMockBuilder(SiteCredentialRepository::class)
->disableOriginalConstructor()
->getMock();
$siteCrentialRepo->expects($this->once())
@ -105,7 +107,7 @@ class GrabySiteConfigBuilderTest extends WallabagCoreTestCase
->with(['unknown.com', '.com'], 1)
->willReturn(null);
$user = $this->getMockBuilder('Wallabag\UserBundle\Entity\User')
$user = $this->getMockBuilder(User::class)
->disableOriginalConstructor()
->getMock();
$user->expects($this->once())
@ -135,7 +137,7 @@ class GrabySiteConfigBuilderTest extends WallabagCoreTestCase
public function testBuildConfigWithBadExtraFields()
{
$grabyConfigBuilderMock = $this->getMockBuilder('Graby\SiteConfig\ConfigBuilder')
$grabyConfigBuilderMock = $this->getMockBuilder(ConfigBuilder::class)
->disableOriginalConstructor()
->getMock();
@ -156,7 +158,7 @@ class GrabySiteConfigBuilderTest extends WallabagCoreTestCase
$handler = new TestHandler();
$logger->pushHandler($handler);
$siteCrentialRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\SiteCredentialRepository')
$siteCrentialRepo = $this->getMockBuilder(SiteCredentialRepository::class)
->disableOriginalConstructor()
->getMock();
$siteCrentialRepo->expects($this->once())
@ -164,7 +166,7 @@ class GrabySiteConfigBuilderTest extends WallabagCoreTestCase
->with(['example.com', '.com'], 1)
->willReturn(['username' => 'foo', 'password' => 'bar']);
$user = $this->getMockBuilder('Wallabag\UserBundle\Entity\User')
$user = $this->getMockBuilder(User::class)
->disableOriginalConstructor()
->getMock();
$user->expects($this->once())
@ -202,7 +204,7 @@ class GrabySiteConfigBuilderTest extends WallabagCoreTestCase
public function testBuildConfigUserNotDefined()
{
$grabyConfigBuilderMock = $this->getMockBuilder('\Graby\SiteConfig\ConfigBuilder')
$grabyConfigBuilderMock = $this->getMockBuilder(ConfigBuilder::class)
->disableOriginalConstructor()
->getMock();
@ -215,7 +217,7 @@ class GrabySiteConfigBuilderTest extends WallabagCoreTestCase
$handler = new TestHandler();
$logger->pushHandler($handler);
$siteCrentialRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\SiteCredentialRepository')
$siteCrentialRepo = $this->getMockBuilder(SiteCredentialRepository::class)
->disableOriginalConstructor()
->getMock();
@ -265,7 +267,7 @@ class GrabySiteConfigBuilderTest extends WallabagCoreTestCase
*/
public function testBuildConfigWithDbAccess($host, $expectedUsername = null, $expectedPassword = null)
{
$grabyConfigBuilderMock = $this->getMockBuilder('Graby\SiteConfig\ConfigBuilder')
$grabyConfigBuilderMock = $this->getMockBuilder(ConfigBuilder::class)
->disableOriginalConstructor()
->getMock();
@ -282,7 +284,7 @@ class GrabySiteConfigBuilderTest extends WallabagCoreTestCase
->with($host)
->willReturn($grabySiteConfig);
$user = $this->getMockBuilder('Wallabag\UserBundle\Entity\User')
$user = $this->getMockBuilder(User::class)
->disableOriginalConstructor()
->getMock();
$user->expects($this->once())

View File

@ -28,7 +28,7 @@ class ContentProxyTest extends TestCase
$ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
$graby = $this->getMockBuilder('Graby\Graby')
$graby = $this->getMockBuilder(Graby::class)
->setMethods(['fetchContent'])
->disableOriginalConstructor()
->getMock();
@ -67,7 +67,7 @@ class ContentProxyTest extends TestCase
$ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
$graby = $this->getMockBuilder('Graby\Graby')
$graby = $this->getMockBuilder(Graby::class)
->setMethods(['fetchContent'])
->disableOriginalConstructor()
->getMock();
@ -106,7 +106,7 @@ class ContentProxyTest extends TestCase
$ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
$graby = $this->getMockBuilder('Graby\Graby')
$graby = $this->getMockBuilder(Graby::class)
->setMethods(['fetchContent'])
->disableOriginalConstructor()
->getMock();
@ -150,7 +150,7 @@ class ContentProxyTest extends TestCase
$ruleBasedIgnoreOriginProcessor->expects($this->once())
->method('process');
$graby = $this->getMockBuilder('Graby\Graby')
$graby = $this->getMockBuilder(Graby::class)
->setMethods(['fetchContent'])
->disableOriginalConstructor()
->getMock();
@ -195,7 +195,7 @@ class ContentProxyTest extends TestCase
$ruleBasedIgnoreOriginProcessor->expects($this->once())
->method('process');
$graby = $this->getMockBuilder('Graby\Graby')
$graby = $this->getMockBuilder(Graby::class)
->setMethods(['fetchContent'])
->disableOriginalConstructor()
->getMock();
@ -240,7 +240,7 @@ class ContentProxyTest extends TestCase
$ruleBasedIgnoreOriginProcessor->expects($this->once())
->method('process');
$graby = $this->getMockBuilder('Graby\Graby')
$graby = $this->getMockBuilder(Graby::class)
->setMethods(['fetchContent'])
->disableOriginalConstructor()
->getMock();
@ -284,7 +284,7 @@ class ContentProxyTest extends TestCase
$ruleBasedIgnoreOriginProcessor->expects($this->once())
->method('process');
$graby = $this->getMockBuilder('Graby\Graby')
$graby = $this->getMockBuilder(Graby::class)
->setMethods(['fetchContent'])
->disableOriginalConstructor()
->getMock();
@ -333,7 +333,7 @@ class ContentProxyTest extends TestCase
->method('validate')
->willReturn(new ConstraintViolationList([new ConstraintViolation('oops', 'oops', [], 'oops', 'language', 'dontexist')]));
$graby = $this->getMockBuilder('Graby\Graby')
$graby = $this->getMockBuilder(Graby::class)
->setMethods(['fetchContent'])
->disableOriginalConstructor()
->getMock();
@ -383,7 +383,7 @@ class ContentProxyTest extends TestCase
new ConstraintViolationList([new ConstraintViolation('oops', 'oops', [], 'oops', 'url', 'https://')])
));
$graby = $this->getMockBuilder('Graby\Graby')
$graby = $this->getMockBuilder(Graby::class)
->setMethods(['fetchContent'])
->disableOriginalConstructor()
->getMock();
@ -635,7 +635,7 @@ class ContentProxyTest extends TestCase
$ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
$graby = $this->getMockBuilder('Graby\Graby')
$graby = $this->getMockBuilder(Graby::class)
->setMethods(['fetchContent'])
->disableOriginalConstructor()
->getMock();
@ -678,7 +678,7 @@ class ContentProxyTest extends TestCase
$ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
$graby = $this->getMockBuilder('Graby\Graby')
$graby = $this->getMockBuilder(Graby::class)
->setMethods(['fetchContent'])
->disableOriginalConstructor()
->getMock();
@ -717,7 +717,7 @@ class ContentProxyTest extends TestCase
$ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
$graby = $this->getMockBuilder('Graby\Graby')
$graby = $this->getMockBuilder(Graby::class)
->setMethods(['fetchContent'])
->disableOriginalConstructor()
->getMock();
@ -755,7 +755,7 @@ class ContentProxyTest extends TestCase
$ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
$graby = $this->getMockBuilder('Graby\Graby')
$graby = $this->getMockBuilder(Graby::class)
->setMethods(['fetchContent'])
->disableOriginalConstructor()
->getMock();
@ -793,7 +793,7 @@ class ContentProxyTest extends TestCase
$ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
$graby = $this->getMockBuilder('Graby\Graby')
$graby = $this->getMockBuilder(Graby::class)
->setMethods(['fetchContent'])
->disableOriginalConstructor()
->getMock();
@ -831,7 +831,7 @@ class ContentProxyTest extends TestCase
$ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
$graby = $this->getMockBuilder('Graby\Graby')
$graby = $this->getMockBuilder(Graby::class)
->setMethods(['fetchContent'])
->disableOriginalConstructor()
->getMock();
@ -870,7 +870,7 @@ class ContentProxyTest extends TestCase
$ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
$graby = $this->getMockBuilder('Graby\Graby')
$graby = $this->getMockBuilder(Graby::class)
->setMethods(['fetchContent'])
->disableOriginalConstructor()
->getMock();

View File

@ -3,6 +3,7 @@
namespace Tests\Wallabag\CoreBundle\Helper;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Routing\Router;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Wallabag\CoreBundle\Entity\Config;
@ -22,7 +23,7 @@ class RedirectTest extends TestCase
protected function setUp(): void
{
$this->routerMock = $this->getMockBuilder('Symfony\Component\Routing\Router')
$this->routerMock = $this->getMockBuilder(Router::class)
->disableOriginalConstructor()
->getMock();

View File

@ -5,11 +5,13 @@ namespace Tests\Wallabag\CoreBundle\Helper;
use Monolog\Handler\TestHandler;
use Monolog\Logger;
use PHPUnit\Framework\TestCase;
use RulerZ\RulerZ;
use Wallabag\CoreBundle\Entity\Config;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\IgnoreOriginInstanceRule;
use Wallabag\CoreBundle\Entity\IgnoreOriginUserRule;
use Wallabag\CoreBundle\Helper\RuleBasedIgnoreOriginProcessor;
use Wallabag\CoreBundle\Repository\IgnoreOriginInstanceRuleRepository;
use Wallabag\UserBundle\Entity\User;
class RuleBasedIgnoreOriginProcessorTest extends TestCase
@ -193,14 +195,14 @@ class RuleBasedIgnoreOriginProcessorTest extends TestCase
private function getRulerZMock()
{
return $this->getMockBuilder('RulerZ\RulerZ')
return $this->getMockBuilder(RulerZ::class)
->disableOriginalConstructor()
->getMock();
}
private function getIgnoreOriginInstanceRuleRepositoryMock()
{
return $this->getMockBuilder('Wallabag\CoreBundle\Repository\IgnoreOriginInstanceRuleRepository')
return $this->getMockBuilder(IgnoreOriginInstanceRuleRepository::class)
->disableOriginalConstructor()
->getMock();
}

View File

@ -2,14 +2,19 @@
namespace Tests\Wallabag\CoreBundle\Helper;
use Doctrine\ORM\AbstractQuery;
use Doctrine\ORM\QueryBuilder;
use Monolog\Handler\TestHandler;
use Monolog\Logger;
use PHPUnit\Framework\TestCase;
use RulerZ\RulerZ;
use Wallabag\CoreBundle\Entity\Config;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\Tag;
use Wallabag\CoreBundle\Entity\TaggingRule;
use Wallabag\CoreBundle\Helper\RuleBasedTagger;
use Wallabag\CoreBundle\Repository\EntryRepository;
use Wallabag\CoreBundle\Repository\TagRepository;
use Wallabag\UserBundle\Entity\User;
class RuleBasedTaggerTest extends TestCase
@ -202,7 +207,7 @@ class RuleBasedTaggerTest extends TestCase
->method('satisfies')
->willReturn(true);
$query = $this->getMockBuilder('Doctrine\ORM\AbstractQuery')
$query = $this->getMockBuilder(AbstractQuery::class)
->disableOriginalConstructor()
->getMock();
@ -211,7 +216,7 @@ class RuleBasedTaggerTest extends TestCase
->method('getResult')
->willReturn([new Entry($user), new Entry($user)]);
$qb = $this->getMockBuilder('Doctrine\ORM\QueryBuilder')
$qb = $this->getMockBuilder(QueryBuilder::class)
->disableOriginalConstructor()
->getMock();
@ -263,21 +268,21 @@ class RuleBasedTaggerTest extends TestCase
private function getRulerZMock()
{
return $this->getMockBuilder('RulerZ\RulerZ')
return $this->getMockBuilder(RulerZ::class)
->disableOriginalConstructor()
->getMock();
}
private function getTagRepositoryMock()
{
return $this->getMockBuilder('Wallabag\CoreBundle\Repository\TagRepository')
return $this->getMockBuilder(TagRepository::class)
->disableOriginalConstructor()
->getMock();
}
private function getEntryRepositoryMock()
{
return $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
return $this->getMockBuilder(EntryRepository::class)
->disableOriginalConstructor()
->getMock();
}

View File

@ -2,12 +2,16 @@
namespace Tests\Wallabag\CoreBundle\ParamConverter;
use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
use Doctrine\Common\Persistence\ObjectManager;
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;
use Wallabag\UserBundle\Repository\UserRepository;
class UsernameFeedTokenConverterTest extends TestCase
{
@ -21,7 +25,7 @@ class UsernameFeedTokenConverterTest extends TestCase
public function testSupportsWithNoRegistryManagers()
{
$registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')
$registry = $this->getMockBuilder(ManagerRegistry::class)
->disableOriginalConstructor()
->getMock();
@ -37,7 +41,7 @@ class UsernameFeedTokenConverterTest extends TestCase
public function testSupportsWithNoConfigurationClass()
{
$registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')
$registry = $this->getMockBuilder(ManagerRegistry::class)
->disableOriginalConstructor()
->getMock();
@ -53,7 +57,7 @@ class UsernameFeedTokenConverterTest extends TestCase
public function testSupportsWithNotTheGoodClass()
{
$meta = $this->getMockBuilder('Doctrine\Common\Persistence\Mapping\ClassMetadata')
$meta = $this->getMockBuilder(ClassMetadata::class)
->disableOriginalConstructor()
->getMock();
@ -61,7 +65,7 @@ class UsernameFeedTokenConverterTest extends TestCase
->method('getName')
->willReturn('nothingrelated');
$em = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')
$em = $this->getMockBuilder(ObjectManager::class)
->disableOriginalConstructor()
->getMock();
@ -70,7 +74,7 @@ class UsernameFeedTokenConverterTest extends TestCase
->with('superclass')
->willReturn($meta);
$registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')
$registry = $this->getMockBuilder(ManagerRegistry::class)
->disableOriginalConstructor()
->getMock();
@ -91,15 +95,15 @@ class UsernameFeedTokenConverterTest extends TestCase
public function testSupportsWithGoodClass()
{
$meta = $this->getMockBuilder('Doctrine\Common\Persistence\Mapping\ClassMetadata')
$meta = $this->getMockBuilder(ClassMetadata::class)
->disableOriginalConstructor()
->getMock();
$meta->expects($this->once())
->method('getName')
->willReturn('Wallabag\UserBundle\Entity\User');
->willReturn(User::class);
$em = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')
$em = $this->getMockBuilder(ObjectManager::class)
->disableOriginalConstructor()
->getMock();
@ -108,7 +112,7 @@ class UsernameFeedTokenConverterTest extends TestCase
->with(User::class)
->willReturn($meta);
$registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')
$registry = $this->getMockBuilder(ManagerRegistry::class)
->disableOriginalConstructor()
->getMock();
@ -142,7 +146,7 @@ class UsernameFeedTokenConverterTest extends TestCase
$this->expectException(NotFoundHttpException::class);
$this->expectExceptionMessage('User not found');
$repo = $this->getMockBuilder('Wallabag\UserBundle\Repository\UserRepository')
$repo = $this->getMockBuilder(UserRepository::class)
->disableOriginalConstructor()
->getMock();
@ -151,7 +155,7 @@ class UsernameFeedTokenConverterTest extends TestCase
->with('test', 'test')
->willReturn(null);
$em = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')
$em = $this->getMockBuilder(ObjectManager::class)
->disableOriginalConstructor()
->getMock();
@ -160,7 +164,7 @@ class UsernameFeedTokenConverterTest extends TestCase
->with(User::class)
->willReturn($repo);
$registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')
$registry = $this->getMockBuilder(ManagerRegistry::class)
->disableOriginalConstructor()
->getMock();
@ -180,7 +184,7 @@ class UsernameFeedTokenConverterTest extends TestCase
{
$user = new User();
$repo = $this->getMockBuilder('Wallabag\UserBundle\Repository\UserRepository')
$repo = $this->getMockBuilder(UserRepository::class)
->disableOriginalConstructor()
->getMock();
@ -189,7 +193,7 @@ class UsernameFeedTokenConverterTest extends TestCase
->with('test', 'test')
->willReturn($user);
$em = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')
$em = $this->getMockBuilder(ObjectManager::class)
->disableOriginalConstructor()
->getMock();
@ -198,7 +202,7 @@ class UsernameFeedTokenConverterTest extends TestCase
->with(User::class)
->willReturn($repo);
$registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')
$registry = $this->getMockBuilder(ManagerRegistry::class)
->disableOriginalConstructor()
->getMock();

View File

@ -3,25 +3,29 @@
namespace Tests\Wallabag\CoreBundle\Twig;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Translation\TranslatorInterface;
use Wallabag\CoreBundle\Repository\EntryRepository;
use Wallabag\CoreBundle\Repository\TagRepository;
use Wallabag\CoreBundle\Twig\WallabagExtension;
class WallabagExtensionTest extends TestCase
{
public function testRemoveWww()
{
$entryRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
$entryRepository = $this->getMockBuilder(EntryRepository::class)
->disableOriginalConstructor()
->getMock();
$tagRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\TagRepository')
$tagRepository = $this->getMockBuilder(TagRepository::class)
->disableOriginalConstructor()
->getMock();
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')
$tokenStorage = $this->getMockBuilder(TokenStorageInterface::class)
->disableOriginalConstructor()
->getMock();
$translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')
$translator = $this->getMockBuilder(TranslatorInterface::class)
->disableOriginalConstructor()
->getMock();
@ -34,19 +38,19 @@ class WallabagExtensionTest extends TestCase
public function testRemoveScheme()
{
$entryRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
$entryRepository = $this->getMockBuilder(EntryRepository::class)
->disableOriginalConstructor()
->getMock();
$tagRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\TagRepository')
$tagRepository = $this->getMockBuilder(TagRepository::class)
->disableOriginalConstructor()
->getMock();
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')
$tokenStorage = $this->getMockBuilder(TokenStorageInterface::class)
->disableOriginalConstructor()
->getMock();
$translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')
$translator = $this->getMockBuilder(TranslatorInterface::class)
->disableOriginalConstructor()
->getMock();
@ -59,19 +63,19 @@ class WallabagExtensionTest extends TestCase
public function testRemoveSchemeAndWww()
{
$entryRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
$entryRepository = $this->getMockBuilder(EntryRepository::class)
->disableOriginalConstructor()
->getMock();
$tagRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\TagRepository')
$tagRepository = $this->getMockBuilder(TagRepository::class)
->disableOriginalConstructor()
->getMock();
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')
$tokenStorage = $this->getMockBuilder(TokenStorageInterface::class)
->disableOriginalConstructor()
->getMock();
$translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')
$translator = $this->getMockBuilder(TranslatorInterface::class)
->disableOriginalConstructor()
->getMock();