Use FQCN as service name for Predis client

This commit is contained in:
Yassine Guedidi 2022-04-24 18:20:46 +02:00
parent 60777e0573
commit a5f22ff835
14 changed files with 34 additions and 23 deletions

View file

@ -190,7 +190,7 @@ services:
- "@security.token_storage"
- "@router"
wallabag_core.redis.client:
Predis\Client:
class: Predis\Client
arguments:
-

View file

@ -2,6 +2,7 @@
namespace Wallabag\ImportBundle\Controller;
use Predis\Client;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Annotation\Route;
use Wallabag\ImportBundle\Import\ImportChain;
@ -51,7 +52,7 @@ class ImportController extends Controller
$rabbitNotInstalled = true;
}
} elseif ($this->get('craue_config')->get('import_with_redis')) {
$redis = $this->get('wallabag_core.redis.client');
$redis = $this->get(Client::class);
try {
$nbRedisMessages = $redis->llen('wallabag.import.pocket')

View file

@ -4,7 +4,7 @@ services:
wallabag_import.queue.redis.readability:
class: Simpleue\Queue\RedisQueue
arguments:
- "@wallabag_core.redis.client"
- '@Predis\Client'
- "wallabag.import.readability"
wallabag_import.producer.redis.readability:
@ -25,7 +25,7 @@ services:
wallabag_import.queue.redis.instapaper:
class: Simpleue\Queue\RedisQueue
arguments:
- "@wallabag_core.redis.client"
- '@Predis\Client'
- "wallabag.import.instapaper"
wallabag_import.producer.redis.instapaper:
@ -46,7 +46,7 @@ services:
wallabag_import.queue.redis.pinboard:
class: Simpleue\Queue\RedisQueue
arguments:
- "@wallabag_core.redis.client"
- '@Predis\Client'
- "wallabag.import.pinboard"
wallabag_import.producer.redis.pinboard:
@ -67,7 +67,7 @@ services:
wallabag_import.queue.redis.delicious:
class: Simpleue\Queue\RedisQueue
arguments:
- "@wallabag_core.redis.client"
- '@Predis\Client'
- "wallabag.import.delicious"
wallabag_import.producer.redis.delicious:
@ -88,7 +88,7 @@ services:
wallabag_import.queue.redis.pocket:
class: Simpleue\Queue\RedisQueue
arguments:
- "@wallabag_core.redis.client"
- '@Predis\Client'
- "wallabag.import.pocket"
wallabag_import.producer.redis.pocket:
@ -109,7 +109,7 @@ services:
wallabag_import.queue.redis.wallabag_v1:
class: Simpleue\Queue\RedisQueue
arguments:
- "@wallabag_core.redis.client"
- '@Predis\Client'
- "wallabag.import.wallabag_v1"
wallabag_import.producer.redis.wallabag_v1:
@ -130,7 +130,7 @@ services:
wallabag_import.queue.redis.wallabag_v2:
class: Simpleue\Queue\RedisQueue
arguments:
- "@wallabag_core.redis.client"
- '@Predis\Client'
- "wallabag.import.wallabag_v2"
wallabag_import.producer.redis.wallabag_v2:
@ -151,7 +151,7 @@ services:
wallabag_import.queue.redis.elcurator:
class: Simpleue\Queue\RedisQueue
arguments:
- "@wallabag_core.redis.client"
- '@Predis\Client'
- "wallabag.import.elcurator"
wallabag_import.producer.redis.elcurator:
@ -172,7 +172,7 @@ services:
wallabag_import.queue.redis.firefox:
class: Simpleue\Queue\RedisQueue
arguments:
- "@wallabag_core.redis.client"
- '@Predis\Client'
- "wallabag.import.firefox"
wallabag_import.producer.redis.firefox:
@ -193,7 +193,7 @@ services:
wallabag_import.queue.redis.chrome:
class: Simpleue\Queue\RedisQueue
arguments:
- "@wallabag_core.redis.client"
- '@Predis\Client'
- "wallabag.import.chrome"
wallabag_import.producer.redis.chrome:

View file

@ -164,7 +164,7 @@ abstract class WallabagCoreTestCase extends WebTestCase
protected function checkRedis()
{
try {
$this->client->getContainer()->get('wallabag_core.redis.client')->connect();
$this->client->getContainer()->get(\Predis\Client::class)->connect();
} catch (\Exception $e) {
$this->markTestSkipped('Redis is not installed/activated');
}

View file

@ -3,6 +3,7 @@
namespace Tests\Wallabag\ImportBundle\Command;
use M6Web\Component\RedisMock\RedisMockFactory;
use Predis\Client;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
@ -51,7 +52,7 @@ class RedisWorkerCommandTest extends WallabagCoreTestCase
$factory = new RedisMockFactory();
$redisMock = $factory->getAdapter('Predis\Client', true);
$application->getKernel()->getContainer()->set('wallabag_core.redis.client', $redisMock);
$application->getKernel()->getContainer()->set(Client::class, $redisMock);
// put a fake message in the queue so the worker will stop after reading that message
// instead of waiting for others

View file

@ -2,6 +2,7 @@
namespace Tests\Wallabag\ImportBundle\Controller;
use Predis\Client;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
@ -82,7 +83,7 @@ class ChromeControllerTest extends WallabagCoreTestCase
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertStringContainsString('flashes.import.notice.summary', $body[0]);
$this->assertNotEmpty($client->getContainer()->get('wallabag_core.redis.client')->lpop('wallabag.import.chrome'));
$this->assertNotEmpty($client->getContainer()->get(Client::class)->lpop('wallabag.import.chrome'));
$client->getContainer()->get('craue_config')->set('import_with_redis', 0);
}

View file

@ -2,6 +2,7 @@
namespace Tests\Wallabag\ImportBundle\Controller;
use Predis\Client;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
@ -82,7 +83,7 @@ class DeliciousControllerTest extends WallabagCoreTestCase
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertStringContainsString('flashes.import.notice.summary', $body[0]);
$this->assertNotEmpty($client->getContainer()->get('wallabag_core.redis.client')->lpop('wallabag.import.delicious'));
$this->assertNotEmpty($client->getContainer()->get(Client::class)->lpop('wallabag.import.delicious'));
$client->getContainer()->get('craue_config')->set('import_with_redis', 0);
}

View file

@ -2,6 +2,7 @@
namespace Tests\Wallabag\ImportBundle\Controller;
use Predis\Client;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
@ -83,7 +84,7 @@ class ElcuratorControllerTest extends WallabagCoreTestCase
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertStringContainsString('flashes.import.notice.summary', $body[0]);
$this->assertNotEmpty($client->getContainer()->get('wallabag_core.redis.client')->lpop('wallabag.import.elcurator'));
$this->assertNotEmpty($client->getContainer()->get(Client::class)->lpop('wallabag.import.elcurator'));
$client->getContainer()->get('craue_config')->set('import_with_redis', 0);
}

View file

@ -2,6 +2,7 @@
namespace Tests\Wallabag\ImportBundle\Controller;
use Predis\Client;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
@ -82,7 +83,7 @@ class FirefoxControllerTest extends WallabagCoreTestCase
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertStringContainsString('flashes.import.notice.summary', $body[0]);
$this->assertNotEmpty($client->getContainer()->get('wallabag_core.redis.client')->lpop('wallabag.import.firefox'));
$this->assertNotEmpty($client->getContainer()->get(Client::class)->lpop('wallabag.import.firefox'));
$client->getContainer()->get('craue_config')->set('import_with_redis', 0);
}

View file

@ -2,6 +2,7 @@
namespace Tests\Wallabag\ImportBundle\Controller;
use Predis\Client;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
@ -82,7 +83,7 @@ class InstapaperControllerTest extends WallabagCoreTestCase
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertStringContainsString('flashes.import.notice.summary', $body[0]);
$this->assertNotEmpty($client->getContainer()->get('wallabag_core.redis.client')->lpop('wallabag.import.instapaper'));
$this->assertNotEmpty($client->getContainer()->get(Client::class)->lpop('wallabag.import.instapaper'));
$client->getContainer()->get('craue_config')->set('import_with_redis', 0);
}

View file

@ -2,6 +2,7 @@
namespace Tests\Wallabag\ImportBundle\Controller;
use Predis\Client;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
@ -82,7 +83,7 @@ class PinboardControllerTest extends WallabagCoreTestCase
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertStringContainsString('flashes.import.notice.summary', $body[0]);
$this->assertNotEmpty($client->getContainer()->get('wallabag_core.redis.client')->lpop('wallabag.import.pinboard'));
$this->assertNotEmpty($client->getContainer()->get(Client::class)->lpop('wallabag.import.pinboard'));
$client->getContainer()->get('craue_config')->set('import_with_redis', 0);
}

View file

@ -2,6 +2,7 @@
namespace Tests\Wallabag\ImportBundle\Controller;
use Predis\Client;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
@ -82,7 +83,7 @@ class ReadabilityControllerTest extends WallabagCoreTestCase
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertStringContainsString('flashes.import.notice.summary', $body[0]);
$this->assertNotEmpty($client->getContainer()->get('wallabag_core.redis.client')->lpop('wallabag.import.readability'));
$this->assertNotEmpty($client->getContainer()->get(Client::class)->lpop('wallabag.import.readability'));
$client->getContainer()->get('craue_config')->set('import_with_redis', 0);
}

View file

@ -2,6 +2,7 @@
namespace Tests\Wallabag\ImportBundle\Controller;
use Predis\Client;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
@ -83,7 +84,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertStringContainsString('flashes.import.notice.summary', $body[0]);
$this->assertNotEmpty($client->getContainer()->get('wallabag_core.redis.client')->lpop('wallabag.import.wallabag_v1'));
$this->assertNotEmpty($client->getContainer()->get(Client::class)->lpop('wallabag.import.wallabag_v1'));
$client->getContainer()->get('craue_config')->set('import_with_redis', 0);
}

View file

@ -2,6 +2,7 @@
namespace Tests\Wallabag\ImportBundle\Controller;
use Predis\Client;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
@ -83,7 +84,7 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertStringContainsString('flashes.import.notice.summary', $body[0]);
$this->assertNotEmpty($client->getContainer()->get('wallabag_core.redis.client')->lpop('wallabag.import.wallabag_v2'));
$this->assertNotEmpty($client->getContainer()->get(Client::class)->lpop('wallabag.import.wallabag_v2'));
$client->getContainer()->get('craue_config')->set('import_with_redis', 0);
}