package and depencies
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Translation\Test;
|
||||
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpClient\MockHttpClient;
|
||||
@@ -20,6 +21,7 @@ use Symfony\Component\Translation\Exception\UnsupportedSchemeException;
|
||||
use Symfony\Component\Translation\Loader\LoaderInterface;
|
||||
use Symfony\Component\Translation\Provider\Dsn;
|
||||
use Symfony\Component\Translation\Provider\ProviderFactoryInterface;
|
||||
use Symfony\Component\Translation\TranslatorBagInterface;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
|
||||
/**
|
||||
@@ -31,11 +33,12 @@ use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
*/
|
||||
abstract class ProviderFactoryTestCase extends TestCase
|
||||
{
|
||||
protected $client;
|
||||
protected $logger;
|
||||
protected $defaultLocale;
|
||||
protected $loader;
|
||||
protected $xliffFileDumper;
|
||||
protected HttpClientInterface $client;
|
||||
protected LoggerInterface|MockObject $logger;
|
||||
protected string $defaultLocale;
|
||||
protected LoaderInterface|MockObject $loader;
|
||||
protected XliffFileDumper|MockObject $xliffFileDumper;
|
||||
protected TranslatorBagInterface|MockObject $translatorBag;
|
||||
|
||||
abstract public function createFactory(): ProviderFactoryInterface;
|
||||
|
||||
@@ -122,26 +125,31 @@ abstract class ProviderFactoryTestCase extends TestCase
|
||||
|
||||
protected function getClient(): HttpClientInterface
|
||||
{
|
||||
return $this->client ?? $this->client = new MockHttpClient();
|
||||
return $this->client ??= new MockHttpClient();
|
||||
}
|
||||
|
||||
protected function getLogger(): LoggerInterface
|
||||
{
|
||||
return $this->logger ?? $this->logger = $this->createMock(LoggerInterface::class);
|
||||
return $this->logger ??= $this->createMock(LoggerInterface::class);
|
||||
}
|
||||
|
||||
protected function getDefaultLocale(): string
|
||||
{
|
||||
return $this->defaultLocale ?? $this->defaultLocale = 'en';
|
||||
return $this->defaultLocale ??= 'en';
|
||||
}
|
||||
|
||||
protected function getLoader(): LoaderInterface
|
||||
{
|
||||
return $this->loader ?? $this->loader = $this->createMock(LoaderInterface::class);
|
||||
return $this->loader ??= $this->createMock(LoaderInterface::class);
|
||||
}
|
||||
|
||||
protected function getXliffFileDumper(): XliffFileDumper
|
||||
{
|
||||
return $this->xliffFileDumper ?? $this->xliffFileDumper = $this->createMock(XliffFileDumper::class);
|
||||
return $this->xliffFileDumper ??= $this->createMock(XliffFileDumper::class);
|
||||
}
|
||||
|
||||
protected function getTranslatorBag(): TranslatorBagInterface
|
||||
{
|
||||
return $this->translatorBag ??= $this->createMock(TranslatorBagInterface::class);
|
||||
}
|
||||
}
|
||||
|
@@ -11,12 +11,14 @@
|
||||
|
||||
namespace Symfony\Component\Translation\Test;
|
||||
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpClient\MockHttpClient;
|
||||
use Symfony\Component\Translation\Dumper\XliffFileDumper;
|
||||
use Symfony\Component\Translation\Loader\LoaderInterface;
|
||||
use Symfony\Component\Translation\Provider\ProviderInterface;
|
||||
use Symfony\Component\Translation\TranslatorBagInterface;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
|
||||
/**
|
||||
@@ -28,11 +30,12 @@ use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
*/
|
||||
abstract class ProviderTestCase extends TestCase
|
||||
{
|
||||
protected $client;
|
||||
protected $logger;
|
||||
protected $defaultLocale;
|
||||
protected $loader;
|
||||
protected $xliffFileDumper;
|
||||
protected HttpClientInterface $client;
|
||||
protected LoggerInterface|MockObject $logger;
|
||||
protected string $defaultLocale;
|
||||
protected LoaderInterface|MockObject $loader;
|
||||
protected XliffFileDumper|MockObject $xliffFileDumper;
|
||||
protected TranslatorBagInterface|MockObject $translatorBag;
|
||||
|
||||
abstract public function createProvider(HttpClientInterface $client, LoaderInterface $loader, LoggerInterface $logger, string $defaultLocale, string $endpoint): ProviderInterface;
|
||||
|
||||
@@ -51,26 +54,31 @@ abstract class ProviderTestCase extends TestCase
|
||||
|
||||
protected function getClient(): MockHttpClient
|
||||
{
|
||||
return $this->client ?? $this->client = new MockHttpClient();
|
||||
return $this->client ??= new MockHttpClient();
|
||||
}
|
||||
|
||||
protected function getLoader(): LoaderInterface
|
||||
{
|
||||
return $this->loader ?? $this->loader = $this->createMock(LoaderInterface::class);
|
||||
return $this->loader ??= $this->createMock(LoaderInterface::class);
|
||||
}
|
||||
|
||||
protected function getLogger(): LoggerInterface
|
||||
{
|
||||
return $this->logger ?? $this->logger = $this->createMock(LoggerInterface::class);
|
||||
return $this->logger ??= $this->createMock(LoggerInterface::class);
|
||||
}
|
||||
|
||||
protected function getDefaultLocale(): string
|
||||
{
|
||||
return $this->defaultLocale ?? $this->defaultLocale = 'en';
|
||||
return $this->defaultLocale ??= 'en';
|
||||
}
|
||||
|
||||
protected function getXliffFileDumper(): XliffFileDumper
|
||||
{
|
||||
return $this->xliffFileDumper ?? $this->xliffFileDumper = $this->createMock(XliffFileDumper::class);
|
||||
return $this->xliffFileDumper ??= $this->createMock(XliffFileDumper::class);
|
||||
}
|
||||
|
||||
protected function getTranslatorBag(): TranslatorBagInterface
|
||||
{
|
||||
return $this->translatorBag ??= $this->createMock(TranslatorBagInterface::class);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user