mirror of
https://github.com/wallabag/wallabag.git
synced 2025-06-27 16:36:00 +00:00
PHPStan level 5
This commit is contained in:
parent
3ef7064ada
commit
36eb513e1b
22 changed files with 60 additions and 47 deletions
|
@ -5,6 +5,7 @@ namespace Tests\Wallabag\Controller\Api;
|
|||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Tests\Wallabag\WallabagTestCase;
|
||||
use Wallabag\Entity\Api\Client;
|
||||
use Wallabag\Entity\User;
|
||||
|
||||
class DeveloperControllerTest extends WallabagTestCase
|
||||
{
|
||||
|
@ -133,7 +134,10 @@ class DeveloperControllerTest extends WallabagTestCase
|
|||
$client = $this->getTestClient();
|
||||
$em = $client->getContainer()->get(EntityManagerInterface::class);
|
||||
$userManager = static::getContainer()->get('fos_user.user_manager');
|
||||
|
||||
$user = $userManager->findUserBy(['username' => $username]);
|
||||
\assert($user instanceof User);
|
||||
|
||||
$apiClient = new Client($user);
|
||||
$apiClient->setName('My app');
|
||||
$apiClient->setAllowedGrantTypes($grantTypes);
|
||||
|
|
|
@ -45,7 +45,7 @@ class UserRestControllerTest extends WallabagApiTestCase
|
|||
|
||||
public function testCreateNewUser()
|
||||
{
|
||||
$this->client->getContainer()->get(Config::class)->set('api_user_registration', 1);
|
||||
$this->client->getContainer()->get(Config::class)->set('api_user_registration', '1');
|
||||
$this->client->request('PUT', '/api/user.json', [
|
||||
'username' => 'google',
|
||||
'password' => 'googlegoogle',
|
||||
|
@ -73,14 +73,14 @@ class UserRestControllerTest extends WallabagApiTestCase
|
|||
|
||||
$this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
|
||||
|
||||
$this->client->getContainer()->get(Config::class)->set('api_user_registration', 0);
|
||||
$this->client->getContainer()->get(Config::class)->set('api_user_registration', '0');
|
||||
}
|
||||
|
||||
public function testCreateNewUserWithoutAuthentication()
|
||||
{
|
||||
// create a new client instead of using $this->client to be sure client isn't authenticated
|
||||
$client = $this->createUnauthorizedClient();
|
||||
$client->getContainer()->get(Config::class)->set('api_user_registration', 1);
|
||||
$client->getContainer()->get(Config::class)->set('api_user_registration', '1');
|
||||
$client->request('PUT', '/api/user.json', [
|
||||
'username' => 'google',
|
||||
'password' => 'googlegoogle',
|
||||
|
@ -109,13 +109,13 @@ class UserRestControllerTest extends WallabagApiTestCase
|
|||
|
||||
$this->assertSame('application/json', $client->getResponse()->headers->get('Content-Type'));
|
||||
|
||||
$client->getContainer()->get(Config::class)->set('api_user_registration', 0);
|
||||
$client->getContainer()->get(Config::class)->set('api_user_registration', '0');
|
||||
}
|
||||
|
||||
public function testCreateNewUserWithExistingEmail()
|
||||
{
|
||||
$client = $this->createUnauthorizedClient();
|
||||
$client->getContainer()->get(Config::class)->set('api_user_registration', 1);
|
||||
$client->getContainer()->get(Config::class)->set('api_user_registration', '1');
|
||||
$client->request('PUT', '/api/user.json', [
|
||||
'username' => 'admin',
|
||||
'password' => 'googlegoogle',
|
||||
|
@ -138,13 +138,13 @@ class UserRestControllerTest extends WallabagApiTestCase
|
|||
|
||||
$this->assertSame('application/json', $client->getResponse()->headers->get('Content-Type'));
|
||||
|
||||
$client->getContainer()->get(Config::class)->set('api_user_registration', 0);
|
||||
$client->getContainer()->get(Config::class)->set('api_user_registration', '0');
|
||||
}
|
||||
|
||||
public function testCreateNewUserWithTooShortPassword()
|
||||
{
|
||||
$client = $this->createUnauthorizedClient();
|
||||
$client->getContainer()->get(Config::class)->set('api_user_registration', 1);
|
||||
$client->getContainer()->get(Config::class)->set('api_user_registration', '1');
|
||||
$client->request('PUT', '/api/user.json', [
|
||||
'username' => 'facebook',
|
||||
'password' => 'face',
|
||||
|
@ -162,7 +162,7 @@ class UserRestControllerTest extends WallabagApiTestCase
|
|||
|
||||
$this->assertSame('application/json', $client->getResponse()->headers->get('Content-Type'));
|
||||
|
||||
$client->getContainer()->get(Config::class)->set('api_user_registration', 0);
|
||||
$client->getContainer()->get(Config::class)->set('api_user_registration', '0');
|
||||
}
|
||||
|
||||
public function testCreateNewUserWhenRegistrationIsDisabled()
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
namespace Tests\Wallabag\Controller\Api;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use FOS\UserBundle\Model\UserInterface;
|
||||
use FOS\UserBundle\Model\UserManager;
|
||||
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
@ -17,7 +16,7 @@ abstract class WallabagApiTestCase extends WebTestCase
|
|||
protected $client;
|
||||
|
||||
/**
|
||||
* @var UserInterface
|
||||
* @var User
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
|
@ -49,9 +48,12 @@ abstract class WallabagApiTestCase extends WebTestCase
|
|||
$userManager = $container->get('fos_user.user_manager');
|
||||
$firewallName = $container->getParameter('fos_user.firewall_name');
|
||||
|
||||
$this->user = $userManager->findUserBy(['username' => 'admin']);
|
||||
$adminUser = $userManager->findUserBy(['username' => 'admin']);
|
||||
\assert($adminUser instanceof User);
|
||||
|
||||
$client->loginUser($this->user, $firewallName);
|
||||
$this->user = $adminUser;
|
||||
|
||||
$client->loginUser($adminUser, $firewallName);
|
||||
|
||||
return $client;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ class WallabagRestControllerTest extends WallabagApiTestCase
|
|||
$this->markTestSkipped('fosuser_registration is not enabled.');
|
||||
}
|
||||
|
||||
$client->getContainer()->get(Config::class)->set('api_user_registration', 1);
|
||||
$client->getContainer()->get(Config::class)->set('api_user_registration', '1');
|
||||
|
||||
$client->request('GET', '/api/info');
|
||||
|
||||
|
@ -53,7 +53,7 @@ class WallabagRestControllerTest extends WallabagApiTestCase
|
|||
|
||||
$this->assertTrue($content['allowed_registration']);
|
||||
|
||||
$client->getContainer()->get(Config::class)->set('api_user_registration', 0);
|
||||
$client->getContainer()->get(Config::class)->set('api_user_registration', '0');
|
||||
|
||||
$client->request('GET', '/api/info');
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ class EntryControllerTest extends WallabagTestCase
|
|||
{
|
||||
if ($this->downloadImagesEnabled) {
|
||||
$client = static::createClient();
|
||||
$client->getContainer()->get(Config::class)->set('download_images_enabled', 0);
|
||||
$client->getContainer()->get(Config::class)->set('download_images_enabled', '0');
|
||||
|
||||
$this->downloadImagesEnabled = false;
|
||||
}
|
||||
|
@ -689,7 +689,7 @@ class EntryControllerTest extends WallabagTestCase
|
|||
->getRepository(Entry::class)
|
||||
->find($entry->getId());
|
||||
|
||||
$this->assertSame(1, $res->isArchived());
|
||||
$this->assertTrue($res->isArchived());
|
||||
}
|
||||
|
||||
public function testToggleStar()
|
||||
|
@ -1400,7 +1400,7 @@ class EntryControllerTest extends WallabagTestCase
|
|||
|
||||
$entry = new Entry($this->getLoggedInUser());
|
||||
$entry->setUrl('https://www.lemonde.fr/incorrect-url/');
|
||||
$entry->setHttpStatus(404);
|
||||
$entry->setHttpStatus('404');
|
||||
$this->getEntityManager()->persist($entry);
|
||||
|
||||
$this->getEntityManager()->flush();
|
||||
|
@ -1418,12 +1418,12 @@ class EntryControllerTest extends WallabagTestCase
|
|||
|
||||
$entry = new Entry($this->getLoggedInUser());
|
||||
$entry->setUrl($this->url);
|
||||
$entry->setHttpStatus(200);
|
||||
$entry->setHttpStatus('200');
|
||||
$this->getEntityManager()->persist($entry);
|
||||
|
||||
$entry = new Entry($this->getLoggedInUser());
|
||||
$entry->setUrl('http://www.nextinpact.com/news/101235-wallabag-alternative-libre-a-pocket-creuse-petit-a-petit-son-nid.htm');
|
||||
$entry->setHttpStatus(200);
|
||||
$entry->setHttpStatus('200');
|
||||
$this->getEntityManager()->persist($entry);
|
||||
|
||||
$this->getEntityManager()->flush();
|
||||
|
@ -1868,14 +1868,14 @@ class EntryControllerTest extends WallabagTestCase
|
|||
->getRepository(Entry::class)
|
||||
->find($entry1->getId());
|
||||
|
||||
$this->assertSame(1, $res->isArchived());
|
||||
$this->assertTrue($res->isArchived());
|
||||
|
||||
$res = $client->getContainer()
|
||||
->get(EntityManagerInterface::class)
|
||||
->getRepository(Entry::class)
|
||||
->find($entry2->getId());
|
||||
|
||||
$this->assertSame(1, $res->isArchived());
|
||||
$this->assertTrue($res->isArchived());
|
||||
|
||||
$crawler = $client->request('GET', '/all/list');
|
||||
$token = $crawler->filter('#form_mass_action input[name=token]')->attr('value');
|
||||
|
|
|
@ -127,7 +127,7 @@ class FeedControllerTest extends WallabagTestCase
|
|||
$client = $this->getTestClient();
|
||||
$client->request('GET', '/feed/admin/SUPERTOKEN/starred');
|
||||
|
||||
$this->assertSame(200, $client->getResponse()->getStatusCode(), 1);
|
||||
$this->assertSame(200, $client->getResponse()->getStatusCode());
|
||||
|
||||
$this->validateDom($client->getResponse()->getContent(), 'starred');
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ TWIG;
|
|||
|
||||
$user = new User();
|
||||
$user->setEmailTwoFactor(true);
|
||||
$user->setEmailAuthCode(666666);
|
||||
$user->setEmailAuthCode('666666');
|
||||
$user->setEmail('test@wallabag.io');
|
||||
$user->setName('Bob');
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue