Skip to content

Commit c48ac83

Browse files
committed
deprecate the ProviderFactoryTestCase
1 parent 4511394 commit c48ac83

14 files changed

+174
-147
lines changed

UPGRADE-7.2.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ String
7777
Translation
7878
-----------
7979

80+
* Deprecate `ProviderFactoryTestCase`, extend `AbstractTransportFactoryTestCase` instead
81+
82+
The `testIncompleteDsnException()` test is no longer provided by default. If you make use of it by implementing the `incompleteDsnProvider()` data providers,
83+
you now need to use the `IncompleteDsnTestTrait`.
84+
8085
* Deprecate passing an escape character to `CsvFileLoader::setCsvControl()`
8186

8287
TwigBridge

src/Symfony/Component/Translation/Bridge/Crowdin/Tests/CrowdinProviderFactoryTest.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,19 @@
1111

1212
namespace Symfony\Component\Translation\Bridge\Crowdin\Tests;
1313

14+
use Psr\Log\NullLogger;
15+
use Symfony\Component\HttpClient\MockHttpClient;
1416
use Symfony\Component\Translation\Bridge\Crowdin\CrowdinProviderFactory;
17+
use Symfony\Component\Translation\Dumper\XliffFileDumper;
18+
use Symfony\Component\Translation\Loader\LoaderInterface;
1519
use Symfony\Component\Translation\Provider\ProviderFactoryInterface;
16-
use Symfony\Component\Translation\Test\ProviderFactoryTestCase;
20+
use Symfony\Component\Translation\Test\AbstractProviderFactoryTestCase;
21+
use Symfony\Component\Translation\Test\IncompleteDsnTestTrait;
1722

18-
class CrowdinProviderFactoryTest extends ProviderFactoryTestCase
23+
class CrowdinProviderFactoryTest extends AbstractProviderFactoryTestCase
1924
{
25+
use IncompleteDsnTestTrait;
26+
2027
public static function supportsProvider(): iterable
2128
{
2229
yield [true, 'crowdin://PROJECT_ID:API_TOKEN@default'];
@@ -48,6 +55,6 @@ public static function incompleteDsnProvider(): iterable
4855

4956
public function createFactory(): ProviderFactoryInterface
5057
{
51-
return new CrowdinProviderFactory($this->getClient(), $this->getLogger(), $this->getDefaultLocale(), $this->getLoader(), $this->getXliffFileDumper());
58+
return new CrowdinProviderFactory(new MockHttpClient(), new NullLogger(), 'en', $this->createMock(LoaderInterface::class), $this->createMock(XliffFileDumper::class));
5259
}
5360
}

src/Symfony/Component/Translation/Bridge/Crowdin/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"php": ">=8.2",
2424
"symfony/config": "^6.4|^7.0",
2525
"symfony/http-client": "^6.4|^7.0",
26-
"symfony/translation": "^6.4|^7.0"
26+
"symfony/translation": "^7.2"
2727
},
2828
"autoload": {
2929
"psr-4": { "Symfony\\Component\\Translation\\Bridge\\Crowdin\\": "" },

src/Symfony/Component/Translation/Bridge/Loco/Tests/LocoProviderFactoryTest.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,19 @@
1111

1212
namespace Symfony\Component\Translation\Bridge\Loco\Tests;
1313

14+
use Psr\Log\NullLogger;
15+
use Symfony\Component\HttpClient\MockHttpClient;
1416
use Symfony\Component\Translation\Bridge\Loco\LocoProviderFactory;
17+
use Symfony\Component\Translation\Loader\LoaderInterface;
1518
use Symfony\Component\Translation\Provider\ProviderFactoryInterface;
16-
use Symfony\Component\Translation\Test\ProviderFactoryTestCase;
19+
use Symfony\Component\Translation\Test\AbstractProviderFactoryTestCase;
20+
use Symfony\Component\Translation\Test\IncompleteDsnTestTrait;
21+
use Symfony\Component\Translation\TranslatorBagInterface;
1722

18-
class LocoProviderFactoryTest extends ProviderFactoryTestCase
23+
class LocoProviderFactoryTest extends AbstractProviderFactoryTestCase
1924
{
25+
use IncompleteDsnTestTrait;
26+
2027
public static function supportsProvider(): iterable
2128
{
2229
yield [true, 'loco://API_KEY@default'];
@@ -48,6 +55,6 @@ public static function incompleteDsnProvider(): iterable
4855

4956
public function createFactory(): ProviderFactoryInterface
5057
{
51-
return new LocoProviderFactory($this->getClient(), $this->getLogger(), $this->getDefaultLocale(), $this->getLoader(), $this->getTranslatorBag());
58+
return new LocoProviderFactory(new MockHttpClient(), new NullLogger(), 'en', $this->createMock(LoaderInterface::class), $this->createMock(TranslatorBagInterface::class));
5259
}
5360
}

src/Symfony/Component/Translation/Bridge/Loco/Tests/LocoProviderFactoryWithoutTranslatorBagTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@
1111

1212
namespace Symfony\Component\Translation\Bridge\Loco\Tests;
1313

14+
use Psr\Log\NullLogger;
15+
use Symfony\Component\HttpClient\MockHttpClient;
1416
use Symfony\Component\Translation\Bridge\Loco\LocoProviderFactory;
17+
use Symfony\Component\Translation\Loader\LoaderInterface;
1518
use Symfony\Component\Translation\Provider\ProviderFactoryInterface;
1619

1720
class LocoProviderFactoryWithoutTranslatorBagTest extends LocoProviderFactoryTest
1821
{
1922
public function createFactory(): ProviderFactoryInterface
2023
{
21-
return new LocoProviderFactory($this->getClient(), $this->getLogger(), $this->getDefaultLocale(), $this->getLoader(), null);
24+
return new LocoProviderFactory(new MockHttpClient(), new NullLogger(), 'en', $this->createMock(LoaderInterface::class), null);
2225
}
2326
}

src/Symfony/Component/Translation/Bridge/Loco/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"php": ">=8.2",
2020
"symfony/http-client": "^6.4|^7.0",
2121
"symfony/config": "^6.4|^7.0",
22-
"symfony/translation": "^6.4|^7.0"
22+
"symfony/translation": "^7.2"
2323
},
2424
"autoload": {
2525
"psr-4": { "Symfony\\Component\\Translation\\Bridge\\Loco\\": "" },

src/Symfony/Component/Translation/Bridge/Lokalise/Tests/LokaliseProviderFactoryTest.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,20 @@
1111

1212
namespace Symfony\Component\Translation\Bridge\Lokalise\Tests;
1313

14+
use Psr\Log\NullLogger;
1415
use Symfony\Component\HttpClient\MockHttpClient;
1516
use Symfony\Component\HttpClient\Response\JsonMockResponse;
1617
use Symfony\Component\Translation\Bridge\Lokalise\LokaliseProviderFactory;
18+
use Symfony\Component\Translation\Loader\LoaderInterface;
1719
use Symfony\Component\Translation\Provider\Dsn;
1820
use Symfony\Component\Translation\Provider\ProviderFactoryInterface;
19-
use Symfony\Component\Translation\Test\ProviderFactoryTestCase;
21+
use Symfony\Component\Translation\Test\AbstractProviderFactoryTestCase;
22+
use Symfony\Component\Translation\Test\IncompleteDsnTestTrait;
2023

21-
class LokaliseProviderFactoryTest extends ProviderFactoryTestCase
24+
class LokaliseProviderFactoryTest extends AbstractProviderFactoryTestCase
2225
{
26+
use IncompleteDsnTestTrait;
27+
2328
public static function supportsProvider(): iterable
2429
{
2530
yield [true, 'lokalise://PROJECT_ID:API_KEY@default'];
@@ -48,7 +53,7 @@ public function testBaseUri()
4853
{
4954
$response = new JsonMockResponse(['files' => []]);
5055
$httpClient = new MockHttpClient([$response]);
51-
$factory = new LokaliseProviderFactory($httpClient, $this->getLogger(), $this->getDefaultLocale(), $this->getLoader());
56+
$factory = new LokaliseProviderFactory($httpClient, new NullLogger(), 'en', $this->createMock(LoaderInterface::class));
5257
$provider = $factory->create(new Dsn('lokalise://PROJECT_ID:API_KEY@default'));
5358

5459
// Make a real HTTP request.
@@ -59,6 +64,6 @@ public function testBaseUri()
5964

6065
public function createFactory(): ProviderFactoryInterface
6166
{
62-
return new LokaliseProviderFactory($this->getClient(), $this->getLogger(), $this->getDefaultLocale(), $this->getLoader());
67+
return new LokaliseProviderFactory(new MockHttpClient(), new NullLogger(), 'en', $this->createMock(LoaderInterface::class));
6368
}
6469
}

src/Symfony/Component/Translation/Bridge/Lokalise/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"php": ">=8.2",
2020
"symfony/config": "^6.4|^7.0",
2121
"symfony/http-client": "^6.4|^7.0",
22-
"symfony/translation": "^6.4|^7.0"
22+
"symfony/translation": "^7.2"
2323
},
2424
"autoload": {
2525
"psr-4": { "Symfony\\Component\\Translation\\Bridge\\Lokalise\\": "" },

src/Symfony/Component/Translation/Bridge/Phrase/Tests/PhraseProviderFactoryTest.php

Lines changed: 6 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -12,79 +12,31 @@
1212
namespace Symfony\Component\Translation\Bridge\Phrase\Tests;
1313

1414
use PHPUnit\Framework\MockObject\MockObject;
15-
use PHPUnit\Framework\TestCase;
1615
use Psr\Cache\CacheItemPoolInterface;
1716
use Psr\Log\LoggerInterface;
1817
use Symfony\Component\HttpClient\MockHttpClient;
1918
use Symfony\Component\Translation\Bridge\Phrase\PhraseProviderFactory;
2019
use Symfony\Component\Translation\Dumper\XliffFileDumper;
21-
use Symfony\Component\Translation\Exception\IncompleteDsnException;
2220
use Symfony\Component\Translation\Exception\MissingRequiredOptionException;
23-
use Symfony\Component\Translation\Exception\UnsupportedSchemeException;
2421
use Symfony\Component\Translation\Loader\LoaderInterface;
2522
use Symfony\Component\Translation\Provider\Dsn;
23+
use Symfony\Component\Translation\Test\AbstractProviderFactoryTestCase;
24+
use Symfony\Component\Translation\Test\IncompleteDsnTestTrait;
2625

2726
/**
2827
* @author wicliff <wicliff.wolda@gmail.com>
2928
*/
30-
class PhraseProviderFactoryTest extends TestCase
29+
class PhraseProviderFactoryTest extends AbstractProviderFactoryTestCase
3130
{
31+
use IncompleteDsnTestTrait;
32+
3233
private MockObject&MockHttpClient $httpClient;
3334
private MockObject&LoggerInterface $logger;
3435
private MockObject&LoaderInterface $loader;
3536
private MockObject&XliffFileDumper $xliffFileDumper;
3637
private MockObject&CacheItemPoolInterface $cache;
3738
private string $defaultLocale;
3839

39-
/**
40-
* @dataProvider supportsProvider
41-
*/
42-
public function testSupports(bool $expected, string $dsn)
43-
{
44-
$factory = $this->createFactory();
45-
46-
$this->assertSame($expected, $factory->supports(new Dsn($dsn)));
47-
}
48-
49-
/**
50-
* @dataProvider createProvider
51-
*/
52-
public function testCreate(string $expected, string $dsn)
53-
{
54-
$factory = $this->createFactory();
55-
$provider = $factory->create(new Dsn($dsn));
56-
57-
$this->assertSame($expected, (string) $provider);
58-
}
59-
60-
/**
61-
* @dataProvider unsupportedSchemeProvider
62-
*/
63-
public function testUnsupportedSchemeException(string $dsn, string $message)
64-
{
65-
$factory = $this->createFactory();
66-
$dsn = new Dsn($dsn);
67-
68-
$this->expectException(UnsupportedSchemeException::class);
69-
$this->expectExceptionMessage($message);
70-
71-
$factory->create($dsn);
72-
}
73-
74-
/**
75-
* @dataProvider incompleteDsnProvider
76-
*/
77-
public function testIncompleteDsnException(string $dsn, string $message)
78-
{
79-
$factory = $this->createFactory();
80-
$dsn = new Dsn($dsn);
81-
82-
$this->expectException(IncompleteDsnException::class);
83-
$this->expectExceptionMessage($message);
84-
85-
$factory->create($dsn);
86-
}
87-
8840
public function testRequiredUserAgentOption()
8941
{
9042
$factory = $this->createFactory();
@@ -144,7 +96,7 @@ public static function supportsProvider(): \Generator
14496
yield 'not supported' => [false, 'unsupported://PROJECT_ID:API_TOKEN@default?userAgent=myProject'];
14597
}
14698

147-
private function createFactory(): PhraseProviderFactory
99+
public function createFactory(): PhraseProviderFactory
148100
{
149101
return new PhraseProviderFactory(
150102
$this->getHttpClient(),

src/Symfony/Component/Translation/Bridge/Phrase/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"psr/cache": "^3.0",
2121
"symfony/http-client": "^6.4|^7.0",
2222
"symfony/mime": "^6.4|^7.0",
23-
"symfony/translation": "^6.4|^7.0"
23+
"symfony/translation": "^7.2"
2424
},
2525
"autoload": {
2626
"psr-4": { "Symfony\\Component\\Translation\\Bridge\\Phrase\\": "" },

0 commit comments

Comments
 (0)