Migrate from Guzzle to Symfony HttpClient - 3

This commit is contained in:
Yassine Guedidi 2025-01-09 22:36:41 +01:00
parent 784b54cd98
commit f42d530491
3 changed files with 12 additions and 15 deletions

View file

@ -220,7 +220,7 @@ services:
Wallabag\Helper\HttpClientFactory:
calls:
- ['addSubscriber', ['@Wallabag\Guzzle\AuthenticatorSubscriber']]
- ['addSubscriber', ['@Wallabag\HttpClient\Authenticator']]
RulerZ\RulerZ:
alias: rulerz

View file

@ -1,6 +1,6 @@
<?php
namespace Wallabag\Guzzle;
namespace Wallabag\HttpClient;
use GuzzleHttp\Psr7\Uri;
use Psr\Http\Message\UriInterface;
@ -12,7 +12,7 @@ use Wallabag\SiteConfig\LoginFormAuthenticator;
use Wallabag\SiteConfig\SiteConfig;
use Wallabag\SiteConfig\SiteConfigBuilder;
class AuthenticatorSubscriber implements LoggerAwareInterface
class Authenticator implements LoggerAwareInterface
{
/** @var SiteConfigBuilder */
private $configBuilder;
@ -23,9 +23,6 @@ class AuthenticatorSubscriber implements LoggerAwareInterface
/** @var LoggerInterface */
private $logger;
/**
* AuthenticatorSubscriber constructor.
*/
public function __construct(SiteConfigBuilder $configBuilder, LoginFormAuthenticator $authenticator)
{
$this->configBuilder = $configBuilder;

View file

@ -1,16 +1,16 @@
<?php
namespace Tests\Wallabag\Guzzle;
namespace Tests\Wallabag\HttpClient;
use Monolog\Handler\TestHandler;
use Monolog\Logger;
use PHPUnit\Framework\TestCase;
use Symfony\Contracts\HttpClient\ResponseInterface;
use Wallabag\Guzzle\AuthenticatorSubscriber;
use Wallabag\HttpClient\Authenticator;
use Wallabag\SiteConfig\ArraySiteConfigBuilder;
use Wallabag\SiteConfig\LoginFormAuthenticator;
class AuthenticatorSubscriberTest extends TestCase
class AuthenticatorTest extends TestCase
{
public function testLoginIfRequiredNotRequired()
{
@ -19,7 +19,7 @@ class AuthenticatorSubscriberTest extends TestCase
->getMock();
$builder = new ArraySiteConfigBuilder(['example.com' => []]);
$subscriber = new AuthenticatorSubscriber($builder, $authenticator);
$subscriber = new \Wallabag\HttpClient\Authenticator($builder, $authenticator);
$logger = new Logger('foo');
$handler = new TestHandler();
@ -51,7 +51,7 @@ class AuthenticatorSubscriberTest extends TestCase
->method('login');
$builder = new ArraySiteConfigBuilder(['example.com' => ['requiresLogin' => true]]);
$subscriber = new AuthenticatorSubscriber($builder, $authenticator);
$subscriber = new Authenticator($builder, $authenticator);
$logger = new Logger('foo');
$handler = new TestHandler();
@ -76,7 +76,7 @@ class AuthenticatorSubscriberTest extends TestCase
->getMock();
$builder = new ArraySiteConfigBuilder(['example.com' => []]);
$subscriber = new AuthenticatorSubscriber($builder, $authenticator);
$subscriber = new Authenticator($builder, $authenticator);
$logger = new Logger('foo');
$handler = new TestHandler();
@ -117,7 +117,7 @@ class AuthenticatorSubscriberTest extends TestCase
'requiresLogin' => true,
'notLoggedInXpath' => '//html',
]]);
$subscriber = new AuthenticatorSubscriber($builder, $authenticator);
$subscriber = new Authenticator($builder, $authenticator);
$logger = new Logger('foo');
$handler = new TestHandler();
@ -165,7 +165,7 @@ class AuthenticatorSubscriberTest extends TestCase
'requiresLogin' => true,
'notLoggedInXpath' => '//html',
]]);
$subscriber = new AuthenticatorSubscriber($builder, $authenticator);
$subscriber = new Authenticator($builder, $authenticator);
$logger = new Logger('foo');
$handler = new TestHandler();
@ -206,7 +206,7 @@ class AuthenticatorSubscriberTest extends TestCase
'requiresLogin' => true,
'notLoggedInXpath' => '//html',
]]);
$subscriber = new AuthenticatorSubscriber($builder, $authenticator);
$subscriber = new Authenticator($builder, $authenticator);
$logger = new Logger('foo');
$handler = new TestHandler();