1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-08-11 17:51:02 +00:00

Merge pull request #7289 from yguedidi/run-tests-in-no-debug-mode

Run tests in no debug mode
This commit is contained in:
Yassine Guedidi 2024-02-26 16:38:08 +01:00 committed by GitHub
commit 353e8698d4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 27 additions and 34 deletions

View file

@ -125,6 +125,9 @@ fos_rest:
# for an unknown reason, EACH REQUEST goes to FOS\RestBundle\EventListener\FormatListener # for an unknown reason, EACH REQUEST goes to FOS\RestBundle\EventListener\FormatListener
# so we need to add custom rule for custom api export but also for all other routes of the application... # so we need to add custom rule for custom api export but also for all other routes of the application...
- { path: '^/', priorities: ['text/html', '*/*'], fallback_format: html, prefer_extension: false } - { path: '^/', priorities: ['text/html', '*/*'], fallback_format: html, prefer_extension: false }
exception:
messages:
Symfony\Component\HttpKernel\Exception\BadRequestHttpException: true
nelmio_api_doc: nelmio_api_doc:
areas: areas:

View file

@ -1,21 +1,4 @@
services: services:
# see https://github.com/symfony/symfony/issues/24543
fos_user.user_manager.test:
alias: fos_user.user_manager
public: true
fos_user.security.login_manager.test:
alias: fos_user.security.login_manager
public: true
wallabag.entry_repository.test:
alias: Wallabag\Repository\EntryRepository
public: true
wallabag_user.user_repository.test:
alias: Wallabag\Repository\UserRepository
public: true
filesystem_cache: filesystem_cache:
class: Doctrine\Common\Cache\FilesystemCache class: Doctrine\Common\Cache\FilesystemCache
arguments: arguments:

View file

@ -8,7 +8,7 @@ parameters:
- tests - tests
symfony: symfony:
container_xml_path: %rootDir%/../../../var/cache/test/AppKernelTestDebugContainer.xml container_xml_path: %rootDir%/../../../var/cache/dev/AppKernelDevDebugContainer.xml
doctrine: doctrine:
objectManagerLoader: tests/object-manager.php objectManagerLoader: tests/object-manager.php

View file

@ -16,6 +16,8 @@
<php> <php>
<ini name="error_reporting" value="-1" /> <ini name="error_reporting" value="-1" />
<server name="KERNEL_CLASS" value="AppKernel" /> <server name="KERNEL_CLASS" value="AppKernel" />
<server name="APP_ENV" value="test" />
<server name="APP_DEBUG" value="0" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak" /> <env name="SYMFONY_DEPRECATIONS_HELPER" value="weak" />
</php> </php>

View file

@ -528,7 +528,7 @@ class EntryRestController extends WallabagRestController
$limit = $this->getParameter('wallabag.api_limit_mass_actions'); $limit = $this->getParameter('wallabag.api_limit_mass_actions');
if (\count($urls) > $limit) { if (\count($urls) > $limit) {
throw new HttpException(400, 'API limit reached'); throw new BadRequestHttpException('API limit reached');
} }
$results = []; $results = [];

View file

@ -6,6 +6,8 @@ use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Tester\CommandTester; use Symfony\Component\Console\Tester\CommandTester;
use Tests\Wallabag\WallabagTestCase; use Tests\Wallabag\WallabagTestCase;
use Wallabag\Entity\Entry; use Wallabag\Entity\Entry;
use Wallabag\Repository\EntryRepository;
use Wallabag\Repository\UserRepository;
class ReloadEntryCommandTest extends WallabagTestCase class ReloadEntryCommandTest extends WallabagTestCase
{ {
@ -35,7 +37,7 @@ class ReloadEntryCommandTest extends WallabagTestCase
{ {
parent::setUp(); parent::setUp();
$userRepository = $this->getTestClient()->getContainer()->get('wallabag_user.user_repository.test'); $userRepository = static::getContainer()->get(UserRepository::class);
$user = $userRepository->findOneByUserName('admin'); $user = $userRepository->findOneByUserName('admin');
$this->adminEntry = new Entry($user); $this->adminEntry = new Entry($user);
@ -80,9 +82,8 @@ class ReloadEntryCommandTest extends WallabagTestCase
'interactive' => false, 'interactive' => false,
]); ]);
$reloadedEntries = $this->getTestClient() $reloadedEntries = static::getContainer()
->getContainer() ->get(EntryRepository::class)
->get('wallabag.entry_repository.test')
->findById([$this->adminEntry->getId(), $this->bobEntry->getId()]); ->findById([$this->adminEntry->getId(), $this->bobEntry->getId()]);
foreach ($reloadedEntries as $reloadedEntry) { foreach ($reloadedEntries as $reloadedEntry) {
@ -107,7 +108,7 @@ class ReloadEntryCommandTest extends WallabagTestCase
'interactive' => false, 'interactive' => false,
]); ]);
$entryRepository = $this->getTestClient()->getContainer()->get('wallabag.entry_repository.test'); $entryRepository = static::getContainer()->get(EntryRepository::class);
$reloadedAdminEntry = $entryRepository->find($this->adminEntry->getId()); $reloadedAdminEntry = $entryRepository->find($this->adminEntry->getId());
$this->assertNotEmpty($reloadedAdminEntry->getContent()); $this->assertNotEmpty($reloadedAdminEntry->getContent());
@ -128,7 +129,7 @@ class ReloadEntryCommandTest extends WallabagTestCase
'--only-not-parsed' => true, '--only-not-parsed' => true,
]); ]);
$entryRepository = $this->getTestClient()->getContainer()->get('wallabag.entry_repository.test'); $entryRepository = static::getContainer()->get(EntryRepository::class);
$reloadedBobParsedEntry = $entryRepository->find($this->bobParsedEntry->getId()); $reloadedBobParsedEntry = $entryRepository->find($this->bobParsedEntry->getId());
$this->assertEmpty($reloadedBobParsedEntry->getContent()); $this->assertEmpty($reloadedBobParsedEntry->getContent());

View file

@ -132,7 +132,7 @@ class DeveloperControllerTest extends WallabagTestCase
{ {
$client = $this->getTestClient(); $client = $this->getTestClient();
$em = $client->getContainer()->get(EntityManagerInterface::class); $em = $client->getContainer()->get(EntityManagerInterface::class);
$userManager = $client->getContainer()->get('fos_user.user_manager.test'); $userManager = static::getContainer()->get('fos_user.user_manager');
$user = $userManager->findUserBy(['username' => $username]); $user = $userManager->findUserBy(['username' => $username]);
$apiClient = new Client($user); $apiClient = new Client($user);
$apiClient->setName('My app'); $apiClient->setName('My app');

View file

@ -43,10 +43,10 @@ abstract class WallabagApiTestCase extends WebTestCase
protected function createAuthorizedClient() protected function createAuthorizedClient()
{ {
$client = $this->createUnauthorizedClient(); $client = $this->createUnauthorizedClient();
$container = $client->getContainer(); $container = static::getContainer();
/** @var UserManager $userManager */ /** @var UserManager $userManager */
$userManager = $container->get('fos_user.user_manager.test'); $userManager = $container->get('fos_user.user_manager');
$firewallName = $container->getParameter('fos_user.firewall_name'); $firewallName = $container->getParameter('fos_user.firewall_name');
$this->user = $userManager->findUserBy(['username' => 'admin']); $this->user = $userManager->findUserBy(['username' => 'admin']);

View file

@ -1313,7 +1313,8 @@ class ConfigControllerTest extends WallabagTestCase
$client->submit($form, $data); $client->submit($form, $data);
$this->assertSame(302, $client->getResponse()->getStatusCode()); $this->assertSame(302, $client->getResponse()->getStatusCode());
$user = $client->getContainer()->get('fos_user.user_manager.test')->findUserBy(['username' => 'admin']); $user = static::getContainer()->get('fos_user.user_manager')->findUserBy(['username' => 'admin']);
\assert($user instanceof User);
$taggingRules = $user->getConfig()->getTaggingRules()->toArray(); $taggingRules = $user->getConfig()->getTaggingRules()->toArray();
$this->assertCount(5, $taggingRules); $this->assertCount(5, $taggingRules);
$this->assertSame('title matches "football"', $taggingRules[4]->getRule()); $this->assertSame('title matches "football"', $taggingRules[4]->getRule());

View file

@ -5,6 +5,7 @@ namespace Tests\Wallabag\Controller;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Tests\Wallabag\WallabagTestCase; use Tests\Wallabag\WallabagTestCase;
use Wallabag\Entity\Entry; use Wallabag\Entity\Entry;
use Wallabag\Repository\UserRepository;
class ExportControllerTest extends WallabagTestCase class ExportControllerTest extends WallabagTestCase
{ {
@ -328,11 +329,9 @@ class ExportControllerTest extends WallabagTestCase
private function setUpForJsonExportFromSearch() private function setUpForJsonExportFromSearch()
{ {
$client = $this->getTestClient();
$em = $this->getEntityManager(); $em = $this->getEntityManager();
$userRepository = $client->getContainer() $userRepository = static::getContainer()->get(UserRepository::class);
->get('wallabag_user.user_repository.test');
$user = $userRepository->findOneByUserName('admin'); $user = $userRepository->findOneByUserName('admin');
$this->adminEntry = new Entry($user); $this->adminEntry = new Entry($user);

View file

@ -86,9 +86,9 @@ abstract class WallabagTestCase extends WebTestCase
*/ */
public function logInAs($username) public function logInAs($username)
{ {
$container = $this->client->getContainer(); $container = static::getContainer();
$userManager = $container->get('fos_user.user_manager.test'); $userManager = $container->get('fos_user.user_manager');
$firewallName = $container->getParameter('fos_user.firewall_name'); $firewallName = $container->getParameter('fos_user.firewall_name');
$user = $userManager->findUserBy(['username' => $username]); $user = $userManager->findUserBy(['username' => $username]);

View file

@ -14,6 +14,7 @@ if (!isPartialRun()) {
'doctrine:database:drop', 'doctrine:database:drop',
'--force', '--force',
'--env=test', '--env=test',
'--no-debug',
]))->run(function ($type, $buffer) { ]))->run(function ($type, $buffer) {
echo $buffer; echo $buffer;
}); });
@ -23,6 +24,7 @@ if (!isPartialRun()) {
__DIR__ . '/../bin/console', __DIR__ . '/../bin/console',
'doctrine:database:create', 'doctrine:database:create',
'--env=test', '--env=test',
'--no-debug',
]))->mustRun(function ($type, $buffer) { ]))->mustRun(function ($type, $buffer) {
echo $buffer; echo $buffer;
}); });
@ -33,6 +35,7 @@ if (!isPartialRun()) {
'doctrine:migrations:migrate', 'doctrine:migrations:migrate',
'--no-interaction', '--no-interaction',
'--env=test', '--env=test',
'--no-debug',
'-vv', '-vv',
]))->mustRun(function ($type, $buffer) { ]))->mustRun(function ($type, $buffer) {
echo $buffer; echo $buffer;
@ -45,6 +48,7 @@ if (!isPartialRun()) {
'doctrine:fixtures:load', 'doctrine:fixtures:load',
'--no-interaction', '--no-interaction',
'--env=test', '--env=test',
'--no-debug',
]))->mustRun(function ($type, $buffer) { ]))->mustRun(function ($type, $buffer) {
echo $buffer; echo $buffer;
}); });