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

@ -2,17 +2,21 @@
namespace Tests\Wallabag\ImportBundle\Consumer;
use Doctrine\ORM\EntityManager;
use PhpAmqpLib\Message\AMQPMessage;
use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\ImportBundle\Consumer\AMQPEntryConsumer;
use Wallabag\ImportBundle\Import\AbstractImport;
use Wallabag\UserBundle\Entity\User;
use Wallabag\UserBundle\Repository\UserRepository;
class AMQPEntryConsumerTest extends TestCase
{
public function testMessageOk()
{
$em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
$em = $this->getMockBuilder(EntityManager::class)
->disableOriginalConstructor()
->getMock();
@ -87,7 +91,7 @@ JSON;
$user = new User();
$entry = new Entry($user);
$userRepository = $this->getMockBuilder('Wallabag\UserBundle\Repository\UserRepository')
$userRepository = $this->getMockBuilder(UserRepository::class)
->disableOriginalConstructor()
->getMock();
@ -98,7 +102,7 @@ JSON;
->with(1)
->willReturn($user);
$import = $this->getMockBuilder('Wallabag\ImportBundle\Import\AbstractImport')
$import = $this->getMockBuilder(AbstractImport::class)
->disableOriginalConstructor()
->getMock();
@ -113,7 +117,7 @@ JSON;
->with(json_decode($body, true))
->willReturn($entry);
$dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
$dispatcher = $this->getMockBuilder(EventDispatcher::class)
->disableOriginalConstructor()
->getMock();
@ -135,7 +139,7 @@ JSON;
public function testMessageWithBadUser()
{
$em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
$em = $this->getMockBuilder(EntityManager::class)
->disableOriginalConstructor()
->getMock();
@ -152,7 +156,7 @@ JSON;
$user = new User();
$entry = new Entry($user);
$userRepository = $this->getMockBuilder('Wallabag\UserBundle\Repository\UserRepository')
$userRepository = $this->getMockBuilder(UserRepository::class)
->disableOriginalConstructor()
->getMock();
@ -163,11 +167,11 @@ JSON;
->with(123)
->willReturn(null);
$import = $this->getMockBuilder('Wallabag\ImportBundle\Import\AbstractImport')
$import = $this->getMockBuilder(AbstractImport::class)
->disableOriginalConstructor()
->getMock();
$dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
$dispatcher = $this->getMockBuilder(EventDispatcher::class)
->disableOriginalConstructor()
->getMock();
@ -191,7 +195,7 @@ JSON;
public function testMessageWithEntryProcessed()
{
$em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
$em = $this->getMockBuilder(EntityManager::class)
->disableOriginalConstructor()
->getMock();
@ -207,7 +211,7 @@ JSON;
$user = new User();
$userRepository = $this->getMockBuilder('Wallabag\UserBundle\Repository\UserRepository')
$userRepository = $this->getMockBuilder(UserRepository::class)
->disableOriginalConstructor()
->getMock();
@ -218,7 +222,7 @@ JSON;
->with(123)
->willReturn($user);
$import = $this->getMockBuilder('Wallabag\ImportBundle\Import\AbstractImport')
$import = $this->getMockBuilder(AbstractImport::class)
->disableOriginalConstructor()
->getMock();
@ -233,7 +237,7 @@ JSON;
->with(json_decode($body, true))
->willReturn(null);
$dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
$dispatcher = $this->getMockBuilder(EventDispatcher::class)
->disableOriginalConstructor()
->getMock();

View File

@ -2,16 +2,20 @@
namespace Tests\Wallabag\ImportBundle\Consumer;
use Doctrine\ORM\EntityManager;
use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\ImportBundle\Consumer\RedisEntryConsumer;
use Wallabag\ImportBundle\Import\AbstractImport;
use Wallabag\UserBundle\Entity\User;
use Wallabag\UserBundle\Repository\UserRepository;
class RedisEntryConsumerTest extends TestCase
{
public function testMessageOk()
{
$em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
$em = $this->getMockBuilder(EntityManager::class)
->disableOriginalConstructor()
->getMock();
@ -86,7 +90,7 @@ JSON;
$user = new User();
$entry = new Entry($user);
$userRepository = $this->getMockBuilder('Wallabag\UserBundle\Repository\UserRepository')
$userRepository = $this->getMockBuilder(UserRepository::class)
->disableOriginalConstructor()
->getMock();
@ -97,7 +101,7 @@ JSON;
->with(1)
->willReturn($user);
$import = $this->getMockBuilder('Wallabag\ImportBundle\Import\AbstractImport')
$import = $this->getMockBuilder(AbstractImport::class)
->disableOriginalConstructor()
->getMock();
@ -112,7 +116,7 @@ JSON;
->with(json_decode($body, true))
->willReturn($entry);
$dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
$dispatcher = $this->getMockBuilder(EventDispatcher::class)
->disableOriginalConstructor()
->getMock();
@ -134,7 +138,7 @@ JSON;
public function testMessageWithBadUser()
{
$em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
$em = $this->getMockBuilder(EntityManager::class)
->disableOriginalConstructor()
->getMock();
@ -151,7 +155,7 @@ JSON;
$user = new User();
$entry = new Entry($user);
$userRepository = $this->getMockBuilder('Wallabag\UserBundle\Repository\UserRepository')
$userRepository = $this->getMockBuilder(UserRepository::class)
->disableOriginalConstructor()
->getMock();
@ -162,11 +166,11 @@ JSON;
->with(123)
->willReturn(null);
$import = $this->getMockBuilder('Wallabag\ImportBundle\Import\AbstractImport')
$import = $this->getMockBuilder(AbstractImport::class)
->disableOriginalConstructor()
->getMock();
$dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
$dispatcher = $this->getMockBuilder(EventDispatcher::class)
->disableOriginalConstructor()
->getMock();
@ -188,7 +192,7 @@ JSON;
public function testMessageWithEntryProcessed()
{
$em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
$em = $this->getMockBuilder(EntityManager::class)
->disableOriginalConstructor()
->getMock();
@ -204,7 +208,7 @@ JSON;
$user = new User();
$userRepository = $this->getMockBuilder('Wallabag\UserBundle\Repository\UserRepository')
$userRepository = $this->getMockBuilder(UserRepository::class)
->disableOriginalConstructor()
->getMock();
@ -215,7 +219,7 @@ JSON;
->with(123)
->willReturn($user);
$import = $this->getMockBuilder('Wallabag\ImportBundle\Import\AbstractImport')
$import = $this->getMockBuilder(AbstractImport::class)
->disableOriginalConstructor()
->getMock();
@ -230,7 +234,7 @@ JSON;
->with(json_decode($body, true))
->willReturn(null);
$dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
$dispatcher = $this->getMockBuilder(EventDispatcher::class)
->disableOriginalConstructor()
->getMock();