Skip to content

Commit e1d0c67

Browse files
OskarStarknicolas-grekas
authored andcommitted
Use createMock() and use import instead of FQCN
1 parent a306824 commit e1d0c67

20 files changed

+85
-56
lines changed

Tests/DataCollector/TranslationDataCollectorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@
1212
namespace Symfony\Component\Translation\Tests\DataCollector;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
1516
use Symfony\Component\Translation\DataCollector\TranslationDataCollector;
1617
use Symfony\Component\Translation\DataCollectorTranslator;
1718

1819
class TranslationDataCollectorTest extends TestCase
1920
{
2021
protected function setUp(): void
2122
{
22-
if (!class_exists(\Symfony\Component\HttpKernel\DataCollector\DataCollector::class)) {
23+
if (!class_exists(DataCollector::class)) {
2324
$this->markTestSkipped('The "DataCollector" is not available');
2425
}
2526
}

Tests/DependencyInjection/TranslationExtractorPassTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\DependencyInjection\ContainerBuilder;
16+
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
1617
use Symfony\Component\DependencyInjection\Reference;
1718
use Symfony\Component\Translation\DependencyInjection\TranslationExtractorPass;
1819

@@ -48,7 +49,7 @@ public function testProcessNoDefinitionFound()
4849

4950
public function testProcessMissingAlias()
5051
{
51-
$this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class);
52+
$this->expectException(RuntimeException::class);
5253
$this->expectExceptionMessage('The alias for the tag "translation.extractor" of service "foo.id" must be set.');
5354
$container = new ContainerBuilder();
5455
$container->register('translation.extractor');

Tests/IntervalTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Translation\Tests;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Translation\Exception\InvalidArgumentException;
1516
use Symfony\Component\Translation\Interval;
1617

1718
/**
@@ -29,7 +30,7 @@ public function testTest($expected, $number, $interval)
2930

3031
public function testTestException()
3132
{
32-
$this->expectException(\Symfony\Component\Translation\Exception\InvalidArgumentException::class);
33+
$this->expectException(InvalidArgumentException::class);
3334
Interval::test(1, 'foobar');
3435
}
3536

Tests/Loader/CsvFileLoaderTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Config\Resource\FileResource;
16+
use Symfony\Component\Translation\Exception\InvalidResourceException;
17+
use Symfony\Component\Translation\Exception\NotFoundResourceException;
1618
use Symfony\Component\Translation\Loader\CsvFileLoader;
1719

1820
class CsvFileLoaderTest extends TestCase
@@ -41,15 +43,15 @@ public function testLoadDoesNothingIfEmpty()
4143

4244
public function testLoadNonExistingResource()
4345
{
44-
$this->expectException(\Symfony\Component\Translation\Exception\NotFoundResourceException::class);
46+
$this->expectException(NotFoundResourceException::class);
4547
$loader = new CsvFileLoader();
4648
$resource = __DIR__.'/../fixtures/not-exists.csv';
4749
$loader->load($resource, 'en', 'domain1');
4850
}
4951

5052
public function testLoadNonLocalResource()
5153
{
52-
$this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class);
54+
$this->expectException(InvalidResourceException::class);
5355
$loader = new CsvFileLoader();
5456
$resource = 'http://example.com/resources.csv';
5557
$loader->load($resource, 'en', 'domain1');

Tests/Loader/IcuDatFileLoaderTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
namespace Symfony\Component\Translation\Tests\Loader;
1313

1414
use Symfony\Component\Config\Resource\FileResource;
15+
use Symfony\Component\Translation\Exception\InvalidResourceException;
16+
use Symfony\Component\Translation\Exception\NotFoundResourceException;
1517
use Symfony\Component\Translation\Loader\IcuDatFileLoader;
1618

1719
/**
@@ -21,7 +23,7 @@ class IcuDatFileLoaderTest extends LocalizedTestCase
2123
{
2224
public function testLoadInvalidResource()
2325
{
24-
$this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class);
26+
$this->expectException(InvalidResourceException::class);
2527
$loader = new IcuDatFileLoader();
2628
$loader->load(__DIR__.'/../fixtures/resourcebundle/corrupted/resources', 'es', 'domain2');
2729
}
@@ -53,7 +55,7 @@ public function testDatFrenchLoad()
5355

5456
public function testLoadNonExistingResource()
5557
{
56-
$this->expectException(\Symfony\Component\Translation\Exception\NotFoundResourceException::class);
58+
$this->expectException(NotFoundResourceException::class);
5759
$loader = new IcuDatFileLoader();
5860
$loader->load(__DIR__.'/../fixtures/non-existing.txt', 'en', 'domain1');
5961
}

Tests/Loader/IcuResFileLoaderTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
namespace Symfony\Component\Translation\Tests\Loader;
1313

1414
use Symfony\Component\Config\Resource\DirectoryResource;
15+
use Symfony\Component\Translation\Exception\InvalidResourceException;
16+
use Symfony\Component\Translation\Exception\NotFoundResourceException;
1517
use Symfony\Component\Translation\Loader\IcuResFileLoader;
1618

1719
/**
@@ -33,14 +35,14 @@ public function testLoad()
3335

3436
public function testLoadNonExistingResource()
3537
{
36-
$this->expectException(\Symfony\Component\Translation\Exception\NotFoundResourceException::class);
38+
$this->expectException(NotFoundResourceException::class);
3739
$loader = new IcuResFileLoader();
3840
$loader->load(__DIR__.'/../fixtures/non-existing.txt', 'en', 'domain1');
3941
}
4042

4143
public function testLoadInvalidResource()
4244
{
43-
$this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class);
45+
$this->expectException(InvalidResourceException::class);
4446
$loader = new IcuResFileLoader();
4547
$loader->load(__DIR__.'/../fixtures/resourcebundle/corrupted', 'en', 'domain1');
4648
}

Tests/Loader/IniFileLoaderTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Config\Resource\FileResource;
16+
use Symfony\Component\Translation\Exception\NotFoundResourceException;
1617
use Symfony\Component\Translation\Loader\IniFileLoader;
1718

1819
class IniFileLoaderTest extends TestCase
@@ -41,7 +42,7 @@ public function testLoadDoesNothingIfEmpty()
4142

4243
public function testLoadNonExistingResource()
4344
{
44-
$this->expectException(\Symfony\Component\Translation\Exception\NotFoundResourceException::class);
45+
$this->expectException(NotFoundResourceException::class);
4546
$loader = new IniFileLoader();
4647
$resource = __DIR__.'/../fixtures/non-existing.ini';
4748
$loader->load($resource, 'en', 'domain1');

Tests/Loader/JsonFileLoaderTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Config\Resource\FileResource;
16+
use Symfony\Component\Translation\Exception\InvalidResourceException;
17+
use Symfony\Component\Translation\Exception\NotFoundResourceException;
1618
use Symfony\Component\Translation\Loader\JsonFileLoader;
1719

1820
class JsonFileLoaderTest extends TestCase
@@ -41,15 +43,15 @@ public function testLoadDoesNothingIfEmpty()
4143

4244
public function testLoadNonExistingResource()
4345
{
44-
$this->expectException(\Symfony\Component\Translation\Exception\NotFoundResourceException::class);
46+
$this->expectException(NotFoundResourceException::class);
4547
$loader = new JsonFileLoader();
4648
$resource = __DIR__.'/../fixtures/non-existing.json';
4749
$loader->load($resource, 'en', 'domain1');
4850
}
4951

5052
public function testParseException()
5153
{
52-
$this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class);
54+
$this->expectException(InvalidResourceException::class);
5355
$this->expectExceptionMessage('Error parsing JSON: Syntax error, malformed JSON');
5456
$loader = new JsonFileLoader();
5557
$resource = __DIR__.'/../fixtures/malformed.json';

Tests/Loader/MoFileLoaderTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Config\Resource\FileResource;
16+
use Symfony\Component\Translation\Exception\InvalidResourceException;
17+
use Symfony\Component\Translation\Exception\NotFoundResourceException;
1618
use Symfony\Component\Translation\Loader\MoFileLoader;
1719

1820
class MoFileLoaderTest extends TestCase
@@ -44,15 +46,15 @@ public function testLoadPlurals()
4446

4547
public function testLoadNonExistingResource()
4648
{
47-
$this->expectException(\Symfony\Component\Translation\Exception\NotFoundResourceException::class);
49+
$this->expectException(NotFoundResourceException::class);
4850
$loader = new MoFileLoader();
4951
$resource = __DIR__.'/../fixtures/non-existing.mo';
5052
$loader->load($resource, 'en', 'domain1');
5153
}
5254

5355
public function testLoadInvalidResource()
5456
{
55-
$this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class);
57+
$this->expectException(InvalidResourceException::class);
5658
$loader = new MoFileLoader();
5759
$resource = __DIR__.'/../fixtures/empty.mo';
5860
$loader->load($resource, 'en', 'domain1');

Tests/Loader/PhpFileLoaderTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Config\Resource\FileResource;
16+
use Symfony\Component\Translation\Exception\InvalidResourceException;
17+
use Symfony\Component\Translation\Exception\NotFoundResourceException;
1618
use Symfony\Component\Translation\Loader\PhpFileLoader;
1719

1820
class PhpFileLoaderTest extends TestCase
@@ -30,15 +32,15 @@ public function testLoad()
3032

3133
public function testLoadNonExistingResource()
3234
{
33-
$this->expectException(\Symfony\Component\Translation\Exception\NotFoundResourceException::class);
35+
$this->expectException(NotFoundResourceException::class);
3436
$loader = new PhpFileLoader();
3537
$resource = __DIR__.'/../fixtures/non-existing.php';
3638
$loader->load($resource, 'en', 'domain1');
3739
}
3840

3941
public function testLoadThrowsAnExceptionIfFileNotLocal()
4042
{
41-
$this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class);
43+
$this->expectException(InvalidResourceException::class);
4244
$loader = new PhpFileLoader();
4345
$resource = 'http://example.com/resources.php';
4446
$loader->load($resource, 'en', 'domain1');

0 commit comments

Comments
 (0)