Skip to content

Commit db5ba0b

Browse files
Merge branch '5.2' into 5.x
* 5.2: Use createMock() and use import instead of FQCN
2 parents 1cfe3bc + 930f176 commit db5ba0b

File tree

12 files changed

+89
-67
lines changed

12 files changed

+89
-67
lines changed

Tests/Collator/CollatorTest.php

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

1414
use Symfony\Component\Intl\Collator\Collator;
15+
use Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException;
1516
use Symfony\Component\Intl\Exception\MethodNotImplementedException;
1617
use Symfony\Component\Intl\Globals\IntlGlobals;
1718

@@ -22,7 +23,7 @@ class CollatorTest extends AbstractCollatorTest
2223
{
2324
public function testConstructorWithUnsupportedLocale()
2425
{
25-
$this->expectException(\Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException::class);
26+
$this->expectException(MethodArgumentValueNotImplementedException::class);
2627
$this->getCollator('pt_BR');
2728
}
2829

Tests/CurrenciesTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Intl\Tests;
1313

1414
use Symfony\Component\Intl\Currencies;
15+
use Symfony\Component\Intl\Exception\MissingResourceException;
1516

1617
/**
1718
* @group intl-data
@@ -725,7 +726,7 @@ function ($value) { return [$value]; },
725726
*/
726727
public function testGetNumericCodeFailsIfNoNumericEquivalent($currency)
727728
{
728-
$this->expectException(\Symfony\Component\Intl\Exception\MissingResourceException::class);
729+
$this->expectException(MissingResourceException::class);
729730
Currencies::getNumericCode($currency);
730731
}
731732

@@ -770,13 +771,13 @@ function ($value) { return [$value]; },
770771
*/
771772
public function testForNumericCodeFailsIfInvalidNumericCode($currency)
772773
{
773-
$this->expectException(\Symfony\Component\Intl\Exception\MissingResourceException::class);
774+
$this->expectException(MissingResourceException::class);
774775
Currencies::forNumericCode($currency);
775776
}
776777

777778
public function testGetNameWithInvalidCurrencyCode()
778779
{
779-
$this->expectException(\Symfony\Component\Intl\Exception\MissingResourceException::class);
780+
$this->expectException(MissingResourceException::class);
780781
Currencies::getName('foo');
781782
}
782783

Tests/Data/Bundle/Reader/BundleEntryReaderTest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
use PHPUnit\Framework\MockObject\MockObject;
1515
use PHPUnit\Framework\TestCase;
1616
use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReader;
17+
use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface;
18+
use Symfony\Component\Intl\Exception\MissingResourceException;
1719
use Symfony\Component\Intl\Exception\ResourceBundleNotFoundException;
1820

1921
/**
@@ -64,7 +66,7 @@ class BundleEntryReaderTest extends TestCase
6466

6567
protected function setUp(): void
6668
{
67-
$this->readerImpl = $this->getMockBuilder(\Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface::class)->getMock();
69+
$this->readerImpl = $this->createMock(BundleEntryReaderInterface::class);
6870
$this->reader = new BundleEntryReader($this->readerImpl);
6971
}
7072

@@ -103,7 +105,7 @@ public function testReadExistingEntry()
103105

104106
public function testReadNonExistingEntry()
105107
{
106-
$this->expectException(\Symfony\Component\Intl\Exception\MissingResourceException::class);
108+
$this->expectException(MissingResourceException::class);
107109
$this->readerImpl->expects($this->once())
108110
->method('read')
109111
->with(self::RES_DIR, 'root')
@@ -127,7 +129,7 @@ public function testFallbackIfEntryDoesNotExist()
127129

128130
public function testDontFallbackIfEntryDoesNotExistAndFallbackDisabled()
129131
{
130-
$this->expectException(\Symfony\Component\Intl\Exception\MissingResourceException::class);
132+
$this->expectException(MissingResourceException::class);
131133
$this->readerImpl->expects($this->once())
132134
->method('read')
133135
->with(self::RES_DIR, 'en_GB')
@@ -154,7 +156,7 @@ public function testFallbackIfLocaleDoesNotExist()
154156

155157
public function testDontFallbackIfLocaleDoesNotExistAndFallbackDisabled()
156158
{
157-
$this->expectException(\Symfony\Component\Intl\Exception\MissingResourceException::class);
159+
$this->expectException(MissingResourceException::class);
158160
$this->readerImpl->expects($this->once())
159161
->method('read')
160162
->with(self::RES_DIR, 'en_GB')
@@ -279,7 +281,7 @@ public function testMergeExistingEntryWithNonExistingFallbackEntry($childData, $
279281

280282
public function testFailIfEntryFoundNeitherInParentNorChild()
281283
{
282-
$this->expectException(\Symfony\Component\Intl\Exception\MissingResourceException::class);
284+
$this->expectException(MissingResourceException::class);
283285
$this->readerImpl
284286
->method('read')
285287
->withConsecutive(

Tests/Data/Bundle/Reader/IntlBundleReaderTest.php

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

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Intl\Data\Bundle\Reader\IntlBundleReader;
16+
use Symfony\Component\Intl\Exception\ResourceBundleNotFoundException;
17+
use Symfony\Component\Intl\Exception\RuntimeException;
1618

1719
/**
1820
* @author Bernhard Schussek <[email protected]>
@@ -75,19 +77,19 @@ public function testReadDoesNotFollowFallbackAlias()
7577

7678
public function testReadFailsIfNonExistingLocale()
7779
{
78-
$this->expectException(\Symfony\Component\Intl\Exception\ResourceBundleNotFoundException::class);
80+
$this->expectException(ResourceBundleNotFoundException::class);
7981
$this->reader->read(__DIR__.'/Fixtures/res', 'foo');
8082
}
8183

8284
public function testReadFailsIfNonExistingFallbackLocale()
8385
{
84-
$this->expectException(\Symfony\Component\Intl\Exception\ResourceBundleNotFoundException::class);
86+
$this->expectException(ResourceBundleNotFoundException::class);
8587
$this->reader->read(__DIR__.'/Fixtures/res', 'ro_AT');
8688
}
8789

8890
public function testReadFailsIfNonExistingDirectory()
8991
{
90-
$this->expectException(\Symfony\Component\Intl\Exception\RuntimeException::class);
92+
$this->expectException(RuntimeException::class);
9193
$this->reader->read(__DIR__.'/foo', 'ro');
9294
}
9395
}

Tests/Data/Bundle/Reader/JsonBundleReaderTest.php

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

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Intl\Data\Bundle\Reader\JsonBundleReader;
16+
use Symfony\Component\Intl\Exception\ResourceBundleNotFoundException;
17+
use Symfony\Component\Intl\Exception\RuntimeException;
1618

1719
/**
1820
* @author Bernhard Schussek <[email protected]>
@@ -40,31 +42,31 @@ public function testReadReturnsArray()
4042

4143
public function testReadFailsIfNonExistingLocale()
4244
{
43-
$this->expectException(\Symfony\Component\Intl\Exception\ResourceBundleNotFoundException::class);
45+
$this->expectException(ResourceBundleNotFoundException::class);
4446
$this->reader->read(__DIR__.'/Fixtures/json', 'foo');
4547
}
4648

4749
public function testReadFailsIfNonExistingDirectory()
4850
{
49-
$this->expectException(\Symfony\Component\Intl\Exception\RuntimeException::class);
51+
$this->expectException(RuntimeException::class);
5052
$this->reader->read(__DIR__.'/foo', 'en');
5153
}
5254

5355
public function testReadFailsIfNotAFile()
5456
{
55-
$this->expectException(\Symfony\Component\Intl\Exception\RuntimeException::class);
57+
$this->expectException(RuntimeException::class);
5658
$this->reader->read(__DIR__.'/Fixtures/NotAFile', 'en');
5759
}
5860

5961
public function testReadFailsIfInvalidJson()
6062
{
61-
$this->expectException(\Symfony\Component\Intl\Exception\RuntimeException::class);
63+
$this->expectException(RuntimeException::class);
6264
$this->reader->read(__DIR__.'/Fixtures/json', 'en_Invalid');
6365
}
6466

6567
public function testReaderDoesNotBreakOutOfGivenPath()
6668
{
67-
$this->expectException(\Symfony\Component\Intl\Exception\ResourceBundleNotFoundException::class);
69+
$this->expectException(ResourceBundleNotFoundException::class);
6870
$this->reader->read(__DIR__.'/Fixtures/json', '../invalid_directory/en');
6971
}
7072
}

Tests/Data/Bundle/Reader/PhpBundleReaderTest.php

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

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Intl\Data\Bundle\Reader\PhpBundleReader;
16+
use Symfony\Component\Intl\Exception\ResourceBundleNotFoundException;
17+
use Symfony\Component\Intl\Exception\RuntimeException;
1618

1719
/**
1820
* @author Bernhard Schussek <[email protected]>
@@ -40,25 +42,25 @@ public function testReadReturnsArray()
4042

4143
public function testReadFailsIfNonExistingLocale()
4244
{
43-
$this->expectException(\Symfony\Component\Intl\Exception\ResourceBundleNotFoundException::class);
45+
$this->expectException(ResourceBundleNotFoundException::class);
4446
$this->reader->read(__DIR__.'/Fixtures/php', 'foo');
4547
}
4648

4749
public function testReadFailsIfNonExistingDirectory()
4850
{
49-
$this->expectException(\Symfony\Component\Intl\Exception\RuntimeException::class);
51+
$this->expectException(RuntimeException::class);
5052
$this->reader->read(__DIR__.'/foo', 'en');
5153
}
5254

5355
public function testReadFailsIfNotAFile()
5456
{
55-
$this->expectException(\Symfony\Component\Intl\Exception\RuntimeException::class);
57+
$this->expectException(RuntimeException::class);
5658
$this->reader->read(__DIR__.'/Fixtures/NotAFile', 'en');
5759
}
5860

5961
public function testReaderDoesNotBreakOutOfGivenPath()
6062
{
61-
$this->expectException(\Symfony\Component\Intl\Exception\ResourceBundleNotFoundException::class);
63+
$this->expectException(ResourceBundleNotFoundException::class);
6264
$this->reader->read(__DIR__.'/Fixtures/php', '../invalid_directory/en');
6365
}
6466
}

Tests/Data/Util/RingBufferTest.php

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

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Intl\Data\Util\RingBuffer;
16+
use Symfony\Component\Intl\Exception\OutOfBoundsException;
1617

1718
/**
1819
* @author Bernhard Schussek <[email protected]>
@@ -54,7 +55,7 @@ public function testWritePastBuffer()
5455

5556
public function testReadNonExistingFails()
5657
{
57-
$this->expectException(\Symfony\Component\Intl\Exception\OutOfBoundsException::class);
58+
$this->expectException(OutOfBoundsException::class);
5859
$this->buffer['foo'];
5960
}
6061

@@ -72,7 +73,7 @@ public function testUnsetNonExistingSucceeds()
7273

7374
public function testReadOverwrittenFails()
7475
{
75-
$this->expectException(\Symfony\Component\Intl\Exception\OutOfBoundsException::class);
76+
$this->expectException(OutOfBoundsException::class);
7677
$this->buffer[0] = 'foo';
7778
$this->buffer['bar'] = 'baz';
7879
$this->buffer[2] = 'bam';

Tests/DateFormatter/IntlDateFormatterTest.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
namespace Symfony\Component\Intl\Tests\DateFormatter;
1313

1414
use Symfony\Component\Intl\DateFormatter\IntlDateFormatter;
15+
use Symfony\Component\Intl\Exception\MethodArgumentNotImplementedException;
16+
use Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException;
17+
use Symfony\Component\Intl\Exception\MethodNotImplementedException;
18+
use Symfony\Component\Intl\Exception\NotImplementedException;
1519
use Symfony\Component\Intl\Globals\IntlGlobals;
1620

1721
/**
@@ -39,7 +43,7 @@ public function testConstructorWithoutCalendar()
3943

4044
public function testConstructorWithUnsupportedLocale()
4145
{
42-
$this->expectException(\Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException::class);
46+
$this->expectException(MethodArgumentValueNotImplementedException::class);
4347
$this->getDateFormatter('pt_BR', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT);
4448
}
4549

@@ -69,23 +73,23 @@ public function testFormatWithUnsupportedTimestampArgument()
6973
try {
7074
$formatter->format($localtime);
7175
} catch (\Exception $e) {
72-
$this->assertInstanceOf(\Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException::class, $e);
76+
$this->assertInstanceOf(MethodArgumentValueNotImplementedException::class, $e);
7377

7478
$this->assertStringEndsWith('Only integer Unix timestamps and DateTime objects are supported. Please install the "intl" extension for full localization capabilities.', $e->getMessage());
7579
}
7680
}
7781

7882
public function testFormatWithUnimplementedChars()
7983
{
80-
$this->expectException(\Symfony\Component\Intl\Exception\NotImplementedException::class);
84+
$this->expectException(NotImplementedException::class);
8185
$pattern = 'Y';
8286
$formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, 'UTC', IntlDateFormatter::GREGORIAN, $pattern);
8387
$formatter->format(0);
8488
}
8589

8690
public function testFormatWithNonIntegerTimestamp()
8791
{
88-
$this->expectException(\Symfony\Component\Intl\Exception\NotImplementedException::class);
92+
$this->expectException(NotImplementedException::class);
8993
$formatter = $this->getDefaultDateFormatter();
9094
$formatter->format([]);
9195
}
@@ -110,42 +114,42 @@ public function testIsLenient()
110114

111115
public function testLocaltime()
112116
{
113-
$this->expectException(\Symfony\Component\Intl\Exception\MethodNotImplementedException::class);
117+
$this->expectException(MethodNotImplementedException::class);
114118
$formatter = $this->getDefaultDateFormatter();
115119
$formatter->localtime('Wednesday, December 31, 1969 4:00:00 PM PT');
116120
}
117121

118122
public function testParseWithNotNullPositionValue()
119123
{
120-
$this->expectException(\Symfony\Component\Intl\Exception\MethodArgumentNotImplementedException::class);
124+
$this->expectException(MethodArgumentNotImplementedException::class);
121125
$position = 0;
122126
$formatter = $this->getDefaultDateFormatter('y');
123127
$this->assertSame(0, $formatter->parse('1970', $position));
124128
}
125129

126130
public function testSetCalendar()
127131
{
128-
$this->expectException(\Symfony\Component\Intl\Exception\MethodNotImplementedException::class);
132+
$this->expectException(MethodNotImplementedException::class);
129133
$formatter = $this->getDefaultDateFormatter();
130134
$formatter->setCalendar(IntlDateFormatter::GREGORIAN);
131135
}
132136

133137
public function testSetLenient()
134138
{
135-
$this->expectException(\Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException::class);
139+
$this->expectException(MethodArgumentValueNotImplementedException::class);
136140
$formatter = $this->getDefaultDateFormatter();
137141
$formatter->setLenient(true);
138142
}
139143

140144
public function testFormatWithGmtTimeZoneAndMinutesOffset()
141145
{
142-
$this->expectException(\Symfony\Component\Intl\Exception\NotImplementedException::class);
146+
$this->expectException(NotImplementedException::class);
143147
parent::testFormatWithGmtTimeZoneAndMinutesOffset();
144148
}
145149

146150
public function testFormatWithNonStandardTimezone()
147151
{
148-
$this->expectException(\Symfony\Component\Intl\Exception\NotImplementedException::class);
152+
$this->expectException(NotImplementedException::class);
149153
parent::testFormatWithNonStandardTimezone();
150154
}
151155

0 commit comments

Comments
 (0)