Merge pull request #6815 from yguedidi/phpstan-level-3

PHPStan level 3
This commit is contained in:
Jérémy Benoist 2023-08-21 15:27:37 +02:00 committed by GitHub
commit c12239c4f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 86 additions and 74 deletions

View File

@ -1,10 +1,25 @@
parameters: parameters:
ignoreErrors: ignoreErrors:
-
message: "#^Method Wallabag\\\\AnnotationBundle\\\\Controller\\\\WallabagAnnotationController\\:\\:postAnnotationAction\\(\\) should return Symfony\\\\Component\\\\HttpFoundation\\\\JsonResponse but returns Symfony\\\\Component\\\\Form\\\\FormInterface\\<mixed\\>\\.$#"
count: 1
path: src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php
-
message: "#^Method Wallabag\\\\AnnotationBundle\\\\Controller\\\\WallabagAnnotationController\\:\\:putAnnotationAction\\(\\) should return Symfony\\\\Component\\\\HttpFoundation\\\\JsonResponse but returns Symfony\\\\Component\\\\Form\\\\FormInterface\\<mixed\\>\\.$#"
count: 1
path: src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php
- -
message: "#^Call to an undefined method Wallabag\\\\CoreBundle\\\\Entity\\\\RuleInterface\\:\\:getConfig\\(\\)\\.$#" message: "#^Call to an undefined method Wallabag\\\\CoreBundle\\\\Entity\\\\RuleInterface\\:\\:getConfig\\(\\)\\.$#"
count: 1 count: 1
path: src/Wallabag/CoreBundle/Controller/ConfigController.php path: src/Wallabag/CoreBundle/Controller/ConfigController.php
-
message: "#^Method FOS\\\\UserBundle\\\\Model\\\\UserManagerInterface\\:\\:updateUser\\(\\) invoked with 2 parameters, 1 required\\.$#"
count: 7
path: src/Wallabag/CoreBundle/Controller/ConfigController.php
- -
message: "#^Call to an undefined method Lexik\\\\Bundle\\\\FormFilterBundle\\\\Filter\\\\Query\\\\QueryInterface\\:\\:getExpressionBuilder\\(\\)\\.$#" message: "#^Call to an undefined method Lexik\\\\Bundle\\\\FormFilterBundle\\\\Filter\\\\Query\\\\QueryInterface\\:\\:getExpressionBuilder\\(\\)\\.$#"
count: 1 count: 1
@ -40,27 +55,12 @@ parameters:
count: 2 count: 2
path: src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php path: src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php
-
message: "#^PHPDoc type Symfony\\\\Component\\\\Mailer\\\\MailerInterface of property Wallabag\\\\UserBundle\\\\Mailer\\\\UserMailer\\:\\:\\$mailer is not covariant with PHPDoc type Swift_Mailer of overridden property FOS\\\\UserBundle\\\\Mailer\\\\TwigSwiftMailer\\:\\:\\$mailer\\.$#"
count: 1
path: src/Wallabag/UserBundle/Mailer/UserMailer.php
- -
message: "#^Call to an undefined method DOMNode\\:\\:getAttribute\\(\\)\\.$#" message: "#^Call to an undefined method DOMNode\\:\\:getAttribute\\(\\)\\.$#"
count: 1 count: 1
path: tests/Wallabag/CoreBundle/Controller/FeedControllerTest.php path: tests/Wallabag/CoreBundle/Controller/FeedControllerTest.php
-
message: "#^Call to method generate\\(\\) on an unknown class PHPUnit_Framework_MockObject_MockObject\\.$#"
count: 2
path: tests/Wallabag/CoreBundle/Helper/RedirectTest.php
-
message: "#^Property Tests\\\\Wallabag\\\\CoreBundle\\\\Helper\\\\RedirectTest\\:\\:\\$routerMock has unknown class PHPUnit_Framework_MockObject_MockObject as its type\\.$#"
count: 1
path: tests/Wallabag/CoreBundle/Helper/RedirectTest.php
-
message: "#^Method Symfony\\\\Contracts\\\\EventDispatcher\\\\EventDispatcherInterface\\:\\:dispatch()#"
count: 15
path: src/*
-
message: "#^Method FOS\\\\UserBundle\\\\Model\\\\UserManagerInterface\\:\\:updateUser()#"
count: 7
path: src/Wallabag/CoreBundle/Controller/ConfigController.php

View File

@ -2,7 +2,7 @@ includes:
- phpstan-baseline.neon - phpstan-baseline.neon
parameters: parameters:
level: 2 level: 3
paths: paths:
- src - src
- tests - tests
@ -14,3 +14,6 @@ parameters:
- vendor/bin/.phpunit/phpunit-8.5-0/vendor/autoload.php - vendor/bin/.phpunit/phpunit-8.5-0/vendor/autoload.php
inferPrivatePropertyTypeFromConstructor: true inferPrivatePropertyTypeFromConstructor: true
ignoreErrors:
- "#^Method Symfony\\\\Contracts\\\\EventDispatcher\\\\EventDispatcherInterface\\:\\:dispatch\\(\\) invoked with 2 parameters, 1 required\\.$#"

View File

@ -4,8 +4,8 @@ namespace Wallabag\ApiBundle\Controller;
use Nelmio\ApiDocBundle\Annotation\Operation; use Nelmio\ApiDocBundle\Annotation\Operation;
use OpenApi\Annotations as OA; use OpenApi\Annotations as OA;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use Wallabag\AnnotationBundle\Entity\Annotation; use Wallabag\AnnotationBundle\Entity\Annotation;
use Wallabag\CoreBundle\Entity\Entry; use Wallabag\CoreBundle\Entity\Entry;
@ -36,7 +36,7 @@ class AnnotationRestController extends WallabagRestController
* *
* @Route("/api/annotations/{entry}.{_format}", methods={"GET"}, name="api_get_annotations", defaults={"_format": "json"}) * @Route("/api/annotations/{entry}.{_format}", methods={"GET"}, name="api_get_annotations", defaults={"_format": "json"})
* *
* @return JsonResponse * @return Response
*/ */
public function getAnnotationsAction(Entry $entry) public function getAnnotationsAction(Entry $entry)
{ {
@ -102,7 +102,7 @@ class AnnotationRestController extends WallabagRestController
* *
* @Route("/api/annotations/{entry}.{_format}", methods={"POST"}, name="api_post_annotation", defaults={"_format": "json"}) * @Route("/api/annotations/{entry}.{_format}", methods={"POST"}, name="api_post_annotation", defaults={"_format": "json"})
* *
* @return JsonResponse * @return Response
*/ */
public function postAnnotationAction(Request $request, Entry $entry) public function postAnnotationAction(Request $request, Entry $entry)
{ {
@ -138,7 +138,7 @@ class AnnotationRestController extends WallabagRestController
* *
* @Route("/api/annotations/{annotation}.{_format}", methods={"PUT"}, name="api_put_annotation", defaults={"_format": "json"}) * @Route("/api/annotations/{annotation}.{_format}", methods={"PUT"}, name="api_put_annotation", defaults={"_format": "json"})
* *
* @return JsonResponse * @return Response
*/ */
public function putAnnotationAction(int $annotation, Request $request) public function putAnnotationAction(int $annotation, Request $request)
{ {
@ -174,7 +174,7 @@ class AnnotationRestController extends WallabagRestController
* *
* @Route("/api/annotations/{annotation}.{_format}", methods={"DELETE"}, name="api_delete_annotation", defaults={"_format": "json"}) * @Route("/api/annotations/{annotation}.{_format}", methods={"DELETE"}, name="api_delete_annotation", defaults={"_format": "json"})
* *
* @return JsonResponse * @return Response
*/ */
public function deleteAnnotationAction(int $annotation) public function deleteAnnotationAction(int $annotation)
{ {

View File

@ -5,6 +5,7 @@ namespace Wallabag\CoreBundle\Controller;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Form; use Symfony\Component\Form\Form;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
@ -138,7 +139,7 @@ class IgnoreOriginInstanceRuleController extends AbstractController
* *
* @param IgnoreOriginInstanceRule $ignoreOriginInstanceRule The ignore origin instance rule entity * @param IgnoreOriginInstanceRule $ignoreOriginInstanceRule The ignore origin instance rule entity
* *
* @return Form The form * @return FormInterface The form
*/ */
private function createDeleteForm(IgnoreOriginInstanceRule $ignoreOriginInstanceRule) private function createDeleteForm(IgnoreOriginInstanceRule $ignoreOriginInstanceRule)
{ {

View File

@ -6,6 +6,7 @@ use Craue\ConfigBundle\Util\Config;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Form; use Symfony\Component\Form\Form;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
@ -173,7 +174,7 @@ class SiteCredentialController extends AbstractController
* *
* @param SiteCredential $siteCredential The site credential entity * @param SiteCredential $siteCredential The site credential entity
* *
* @return Form The form * @return FormInterface The form
*/ */
private function createDeleteForm(SiteCredential $siteCredential) private function createDeleteForm(SiteCredential $siteCredential)
{ {

View File

@ -132,12 +132,16 @@ class Config
private $user; private $user;
/** /**
* @var ArrayCollection<TaggingRule>
*
* @ORM\OneToMany(targetEntity="Wallabag\CoreBundle\Entity\TaggingRule", mappedBy="config", cascade={"remove"}) * @ORM\OneToMany(targetEntity="Wallabag\CoreBundle\Entity\TaggingRule", mappedBy="config", cascade={"remove"})
* @ORM\OrderBy({"id" = "ASC"}) * @ORM\OrderBy({"id" = "ASC"})
*/ */
private $taggingRules; private $taggingRules;
/** /**
@var ArrayCollection<IgnoreOriginUserRule>
* @ORM\OneToMany(targetEntity="Wallabag\CoreBundle\Entity\IgnoreOriginUserRule", mappedBy="config", cascade={"remove"}) * @ORM\OneToMany(targetEntity="Wallabag\CoreBundle\Entity\IgnoreOriginUserRule", mappedBy="config", cascade={"remove"})
* @ORM\OrderBy({"id" = "ASC"}) * @ORM\OrderBy({"id" = "ASC"})
*/ */
@ -371,12 +375,9 @@ class Config
return $this; return $this;
} }
/** public function getDisplayThumbnails(): bool
* @return bool
*/
public function getDisplayThumbnails(): ?bool
{ {
return $this->displayThumbnails; return (bool) $this->displayThumbnails;
} }
/** /**
@ -384,7 +385,7 @@ class Config
*/ */
public function setDisplayThumbnails(bool $displayThumbnails) public function setDisplayThumbnails(bool $displayThumbnails)
{ {
$this->displayThumbnails = $displayThumbnails; $this->displayThumbnails = $displayThumbnails ? 1 : 0;
return $this; return $this;
} }

View File

@ -55,7 +55,7 @@ class Entry
private $id; private $id;
/** /**
* @var string * @var string|null
* *
* @ORM\Column(name="uid", type="string", length=23, nullable=true) * @ORM\Column(name="uid", type="string", length=23, nullable=true)
* *
@ -132,7 +132,7 @@ class Entry
private $isArchived = false; private $isArchived = false;
/** /**
* @var \DateTime * @var \DateTimeInterface
* *
* @ORM\Column(name="archived_at", type="datetime", nullable=true) * @ORM\Column(name="archived_at", type="datetime", nullable=true)
* *
@ -161,7 +161,7 @@ class Entry
private $content; private $content;
/** /**
* @var \DateTime * @var \DateTimeInterface
* *
* @ORM\Column(name="created_at", type="datetime") * @ORM\Column(name="created_at", type="datetime")
* *
@ -170,7 +170,7 @@ class Entry
private $createdAt; private $createdAt;
/** /**
* @var \DateTime * @var \DateTimeInterface
* *
* @ORM\Column(name="updated_at", type="datetime") * @ORM\Column(name="updated_at", type="datetime")
* *
@ -179,7 +179,7 @@ class Entry
private $updatedAt; private $updatedAt;
/** /**
* @var \DateTime * @var \DateTimeInterface
* *
* @ORM\Column(name="published_at", type="datetime", nullable=true) * @ORM\Column(name="published_at", type="datetime", nullable=true)
* *
@ -197,7 +197,7 @@ class Entry
private $publishedBy; private $publishedBy;
/** /**
* @var \DateTime * @var \DateTimeInterface
* *
* @ORM\Column(name="starred_at", type="datetime", nullable=true) * @ORM\Column(name="starred_at", type="datetime", nullable=true)
* *
@ -400,7 +400,7 @@ class Entry
} }
/** /**
* @return \DateTime|null * @return \DateTimeInterface|null
*/ */
public function getArchivedAt() public function getArchivedAt()
{ {
@ -408,7 +408,7 @@ class Entry
} }
/** /**
* @param \DateTime|null $archivedAt * @param \DateTimeInterface|null $archivedAt
* *
* @return Entry * @return Entry
*/ */
@ -482,7 +482,7 @@ class Entry
public function toggleStar() public function toggleStar()
{ {
$this->isStarred = $this->isStarred() ^ 1; $this->isStarred = !$this->isStarred();
return $this; return $this;
} }
@ -560,7 +560,7 @@ class Entry
} }
/** /**
* @return \DateTime * @return \DateTimeInterface
*/ */
public function getCreatedAt() public function getCreatedAt()
{ {
@ -568,7 +568,7 @@ class Entry
} }
/** /**
* @return \DateTime * @return \DateTimeInterface
*/ */
public function getUpdatedAt() public function getUpdatedAt()
{ {
@ -576,7 +576,7 @@ class Entry
} }
/** /**
* @return \DateTime|null * @return \DateTimeInterface|null
*/ */
public function getStarredAt() public function getStarredAt()
{ {
@ -584,7 +584,7 @@ class Entry
} }
/** /**
* @param \DateTime|null $starredAt * @param \DateTimeInterface|null $starredAt
* *
* @return Entry * @return Entry
*/ */
@ -881,7 +881,7 @@ class Entry
} }
/** /**
* @return \DateTime * @return \DateTimeInterface
*/ */
public function getPublishedAt() public function getPublishedAt()
{ {
@ -891,7 +891,7 @@ class Entry
/** /**
* @return Entry * @return Entry
*/ */
public function setPublishedAt(\DateTime $publishedAt) public function setPublishedAt(\DateTimeInterface $publishedAt)
{ {
$this->publishedAt = $publishedAt; $this->publishedAt = $publishedAt;

View File

@ -49,7 +49,7 @@ class StringToListTransformer implements DataTransformerInterface
public function reverseTransform($string) public function reverseTransform($string)
{ {
if (null === $string) { if (null === $string) {
return; return null;
} }
return array_values(array_filter(array_map('trim', explode($this->separator, $string)))); return array_values(array_filter(array_map('trim', explode($this->separator, $string))));

View File

@ -3,6 +3,7 @@
namespace Wallabag\CoreBundle\Helper; namespace Wallabag\CoreBundle\Helper;
use Pagerfanta\Adapter\AdapterInterface; use Pagerfanta\Adapter\AdapterInterface;
use Pagerfanta\Adapter\NullAdapter;
use Pagerfanta\Pagerfanta; use Pagerfanta\Pagerfanta;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Wallabag\UserBundle\Entity\User; use Wallabag\UserBundle\Entity\User;
@ -19,7 +20,7 @@ class PreparePagerForEntries
/** /**
* @param User $user If user isn't logged in, we can force it (like for feed) * @param User $user If user isn't logged in, we can force it (like for feed)
* *
* @return Pagerfanta|null * @return Pagerfanta
*/ */
public function prepare(AdapterInterface $adapter, User $user = null) public function prepare(AdapterInterface $adapter, User $user = null)
{ {
@ -28,7 +29,7 @@ class PreparePagerForEntries
} }
if (!$user instanceof User) { if (!$user instanceof User) {
return; return new Pagerfanta(new NullAdapter());
} }
$entries = new Pagerfanta($adapter); $entries = new Pagerfanta($adapter);

View File

@ -2,6 +2,7 @@
namespace Wallabag\CoreBundle\Helper; namespace Wallabag\CoreBundle\Helper;
use Doctrine\Common\Collections\ArrayCollection;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use RulerZ\RulerZ; use RulerZ\RulerZ;
use Wallabag\CoreBundle\Entity\Entry; use Wallabag\CoreBundle\Entity\Entry;
@ -120,7 +121,7 @@ class RuleBasedTagger
/** /**
* Retrieves the tagging rules for a given user. * Retrieves the tagging rules for a given user.
* *
* @return array<TaggingRule> * @return ArrayCollection<TaggingRule>
*/ */
private function getRulesForUser(User $user) private function getRulesForUser(User $user)
{ {

View File

@ -429,7 +429,7 @@ class EntryRepository extends ServiceEntityRepository
/** /**
* Find all entries which have an empty value for hash. * Find all entries which have an empty value for hash.
* *
* @return Entry|false * @return Entry[]
*/ */
public function findByEmptyHashedUrlAndUserId(int $userId) public function findByEmptyHashedUrlAndUserId(int $userId)
{ {

View File

@ -42,7 +42,7 @@ class SiteCredentialRepository extends ServiceEntityRepository
->getOneOrNullResult(); ->getOneOrNullResult();
if (null === $res) { if (null === $res) {
return; return null;
} }
// decrypt user & password before returning them // decrypt user & password before returning them

View File

@ -145,7 +145,7 @@ class WallabagExtension extends AbstractExtension implements GlobalsInterface
$user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null; $user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null;
if (!$user instanceof User) { if (!$user instanceof User) {
return 0; return '';
} }
$query = $this->entryRepository->getBuilderForArchiveByUser($user->getId()) $query = $this->entryRepository->getBuilderForArchiveByUser($user->getId())

View File

@ -107,7 +107,7 @@ abstract class AbstractImport implements ImportInterface
/** /**
* Parse one entry. * Parse one entry.
* *
* @return Entry * @return Entry|null
*/ */
abstract public function parseEntry(array $importedEntry); abstract public function parseEntry(array $importedEntry);

View File

@ -81,28 +81,28 @@ abstract class BrowserImport extends AbstractImport
if ($this->producer) { if ($this->producer) {
$this->parseEntriesForProducer($importedEntry); $this->parseEntriesForProducer($importedEntry);
return; return null;
} }
$this->parseEntries($importedEntry); $this->parseEntries($importedEntry);
return; return null;
} }
if (\array_key_exists('children', $importedEntry)) { if (\array_key_exists('children', $importedEntry)) {
if ($this->producer) { if ($this->producer) {
$this->parseEntriesForProducer($importedEntry['children']); $this->parseEntriesForProducer($importedEntry['children']);
return; return null;
} }
$this->parseEntries($importedEntry['children']); $this->parseEntries($importedEntry['children']);
return; return null;
} }
if (!\array_key_exists('uri', $importedEntry) && !\array_key_exists('url', $importedEntry)) { if (!\array_key_exists('uri', $importedEntry) && !\array_key_exists('url', $importedEntry)) {
return; return null;
} }
$url = \array_key_exists('uri', $importedEntry) ? $importedEntry['uri'] : $importedEntry['url']; $url = \array_key_exists('uri', $importedEntry) ? $importedEntry['uri'] : $importedEntry['url'];
@ -114,7 +114,7 @@ abstract class BrowserImport extends AbstractImport
if (false !== $existingEntry) { if (false !== $existingEntry) {
++$this->skippedEntries; ++$this->skippedEntries;
return; return null;
} }
$data = $this->prepareEntry($importedEntry); $data = $this->prepareEntry($importedEntry);

View File

@ -104,7 +104,7 @@ class DeliciousImport extends AbstractImport
if (false !== $existingEntry) { if (false !== $existingEntry) {
++$this->skippedEntries; ++$this->skippedEntries;
return; return null;
} }
$data = [ $data = [

View File

@ -132,7 +132,7 @@ class InstapaperImport extends AbstractImport
if (false !== $existingEntry) { if (false !== $existingEntry) {
++$this->skippedEntries; ++$this->skippedEntries;
return; return null;
} }
$entry = new Entry($this->user); $entry = new Entry($this->user);

View File

@ -104,7 +104,7 @@ class PinboardImport extends AbstractImport
if (false !== $existingEntry) { if (false !== $existingEntry) {
++$this->skippedEntries; ++$this->skippedEntries;
return; return null;
} }
$data = [ $data = [

View File

@ -186,7 +186,7 @@ class PocketImport extends AbstractImport
if (false !== $existingEntry) { if (false !== $existingEntry) {
++$this->skippedEntries; ++$this->skippedEntries;
return; return null;
} }
$entry = new Entry($this->user); $entry = new Entry($this->user);

View File

@ -104,7 +104,7 @@ class ReadabilityImport extends AbstractImport
if (false !== $existingEntry) { if (false !== $existingEntry) {
++$this->skippedEntries; ++$this->skippedEntries;
return; return null;
} }
$data = [ $data = [

View File

@ -110,7 +110,7 @@ abstract class WallabagImport extends AbstractImport
if (false !== $existingEntry) { if (false !== $existingEntry) {
++$this->skippedEntries; ++$this->skippedEntries;
return; return null;
} }
$data = $this->prepareEntry($importedEntry); $data = $this->prepareEntry($importedEntry);

View File

@ -13,6 +13,7 @@ use Scheb\TwoFactorBundle\Security\TwoFactor\Provider\Google\GoogleAuthenticator
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Form\Form; use Symfony\Component\Form\Form;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
@ -184,7 +185,7 @@ class ManageController extends AbstractController
* *
* @param User $user The User entity * @param User $user The User entity
* *
* @return Form The form * @return FormInterface The form
*/ */
private function createDeleteForm(User $user) private function createDeleteForm(User $user)
{ {

View File

@ -673,7 +673,7 @@ class EntryControllerTest extends WallabagCoreTestCase
->getRepository(Entry::class) ->getRepository(Entry::class)
->findOneById($entry->getId()); ->findOneById($entry->getId());
$this->assertSame(1, $res->isStarred()); $this->assertTrue($res->isStarred());
} }
public function testDelete() public function testDelete()
@ -1748,14 +1748,14 @@ class EntryControllerTest extends WallabagCoreTestCase
->getRepository(Entry::class) ->getRepository(Entry::class)
->find($entry1->getId()); ->find($entry1->getId());
$this->assertSame(1, $res->isStarred()); $this->assertTrue($res->isStarred());
$res = $client->getContainer() $res = $client->getContainer()
->get(EntityManagerInterface::class) ->get(EntityManagerInterface::class)
->getRepository(Entry::class) ->getRepository(Entry::class)
->find($entry2->getId()); ->find($entry2->getId());
$this->assertSame(1, $res->isStarred()); $this->assertTrue($res->isStarred());
// Mass actions : tag // Mass actions : tag
$client->request('POST', '/mass', [ $client->request('POST', '/mass', [

View File

@ -2,6 +2,7 @@
namespace Tests\Wallabag\CoreBundle\Helper; namespace Tests\Wallabag\CoreBundle\Helper;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Symfony\Component\Routing\Router; use Symfony\Component\Routing\Router;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
@ -12,7 +13,7 @@ use Wallabag\UserBundle\Entity\User;
class RedirectTest extends TestCase class RedirectTest extends TestCase
{ {
/** @var \PHPUnit_Framework_MockObject_MockObject */ /** @var Router&MockObject */
private $routerMock; private $routerMock;
/** @var Redirect */ /** @var Redirect */

View File

@ -138,6 +138,8 @@ abstract class WallabagCoreTestCase extends WebTestCase
$token = static::$kernel->getContainer()->get(TokenStorageInterface::class)->getToken(); $token = static::$kernel->getContainer()->get(TokenStorageInterface::class)->getToken();
if (null !== $token) { if (null !== $token) {
\assert($token->getUser() instanceof User);
return $token->getUser(); return $token->getUser();
} }