ProviderTestCase.php
45 lines
| 1 | <?php |
| 2 | namespace MailPoetVendor\Symfony\Component\Translation\Test; |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | use MailPoetVendor\PHPUnit\Framework\TestCase; |
| 5 | use MailPoetVendor\Psr\Log\LoggerInterface; |
| 6 | use MailPoetVendor\Symfony\Component\HttpClient\MockHttpClient; |
| 7 | use MailPoetVendor\Symfony\Component\Translation\Dumper\XliffFileDumper; |
| 8 | use MailPoetVendor\Symfony\Component\Translation\Loader\LoaderInterface; |
| 9 | use MailPoetVendor\Symfony\Component\Translation\Provider\ProviderInterface; |
| 10 | use MailPoetVendor\Symfony\Contracts\HttpClient\HttpClientInterface; |
| 11 | abstract class ProviderTestCase extends TestCase |
| 12 | { |
| 13 | protected $client; |
| 14 | protected $logger; |
| 15 | protected $defaultLocale; |
| 16 | protected $loader; |
| 17 | protected $xliffFileDumper; |
| 18 | public static abstract function createProvider(HttpClientInterface $client, LoaderInterface $loader, LoggerInterface $logger, string $defaultLocale, string $endpoint) : ProviderInterface; |
| 19 | public static abstract function toStringProvider() : iterable; |
| 20 | public function testToString(ProviderInterface $provider, string $expected) |
| 21 | { |
| 22 | $this->assertSame($expected, (string) $provider); |
| 23 | } |
| 24 | protected function getClient() : MockHttpClient |
| 25 | { |
| 26 | return $this->client ?? ($this->client = new MockHttpClient()); |
| 27 | } |
| 28 | protected function getLoader() : LoaderInterface |
| 29 | { |
| 30 | return $this->loader ?? ($this->loader = $this->createMock(LoaderInterface::class)); |
| 31 | } |
| 32 | protected function getLogger() : LoggerInterface |
| 33 | { |
| 34 | return $this->logger ?? ($this->logger = $this->createMock(LoggerInterface::class)); |
| 35 | } |
| 36 | protected function getDefaultLocale() : string |
| 37 | { |
| 38 | return $this->defaultLocale ?? ($this->defaultLocale = 'en'); |
| 39 | } |
| 40 | protected function getXliffFileDumper() : XliffFileDumper |
| 41 | { |
| 42 | return $this->xliffFileDumper ?? ($this->xliffFileDumper = $this->createMock(XliffFileDumper::class)); |
| 43 | } |
| 44 | } |
| 45 |