Skip to content

Commit 930f176

Browse files
Merge branch '4.4' into 5.1
* 4.4: Use createMock() and use import instead of FQCN
2 parents 77e720d + 8a15571 commit 930f176

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,14 +12,15 @@
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

1819
class CollatorTest extends AbstractCollatorTest
1920
{
2021
public function testConstructorWithUnsupportedLocale()
2122
{
22-
$this->expectException(\Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException::class);
23+
$this->expectException(MethodArgumentValueNotImplementedException::class);
2324
$this->getCollator('pt_BR');
2425
}
2526

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
class IntlDateFormatterTest extends AbstractIntlDateFormatterTest
@@ -36,7 +40,7 @@ public function testConstructorWithoutCalendar()
3640

3741
public function testConstructorWithUnsupportedLocale()
3842
{
39-
$this->expectException(\Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException::class);
43+
$this->expectException(MethodArgumentValueNotImplementedException::class);
4044
$this->getDateFormatter('pt_BR', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT);
4145
}
4246

@@ -66,23 +70,23 @@ public function testFormatWithUnsupportedTimestampArgument()
6670
try {
6771
$formatter->format($localtime);
6872
} catch (\Exception $e) {
69-
$this->assertInstanceOf(\Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException::class, $e);
73+
$this->assertInstanceOf(MethodArgumentValueNotImplementedException::class, $e);
7074

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

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

8387
public function testFormatWithNonIntegerTimestamp()
8488
{
85-
$this->expectException(\Symfony\Component\Intl\Exception\NotImplementedException::class);
89+
$this->expectException(NotImplementedException::class);
8690
$formatter = $this->getDefaultDateFormatter();
8791
$formatter->format([]);
8892
}
@@ -107,42 +111,42 @@ public function testIsLenient()
107111

108112
public function testLocaltime()
109113
{
110-
$this->expectException(\Symfony\Component\Intl\Exception\MethodNotImplementedException::class);
114+
$this->expectException(MethodNotImplementedException::class);
111115
$formatter = $this->getDefaultDateFormatter();
112116
$formatter->localtime('Wednesday, December 31, 1969 4:00:00 PM PT');
113117
}
114118

115119
public function testParseWithNotNullPositionValue()
116120
{
117-
$this->expectException(\Symfony\Component\Intl\Exception\MethodArgumentNotImplementedException::class);
121+
$this->expectException(MethodArgumentNotImplementedException::class);
118122
$position = 0;
119123
$formatter = $this->getDefaultDateFormatter('y');
120124
$this->assertSame(0, $formatter->parse('1970', $position));
121125
}
122126

123127
public function testSetCalendar()
124128
{
125-
$this->expectException(\Symfony\Component\Intl\Exception\MethodNotImplementedException::class);
129+
$this->expectException(MethodNotImplementedException::class);
126130
$formatter = $this->getDefaultDateFormatter();
127131
$formatter->setCalendar(IntlDateFormatter::GREGORIAN);
128132
}
129133

130134
public function testSetLenient()
131135
{
132-
$this->expectException(\Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException::class);
136+
$this->expectException(MethodArgumentValueNotImplementedException::class);
133137
$formatter = $this->getDefaultDateFormatter();
134138
$formatter->setLenient(true);
135139
}
136140

137141
public function testFormatWithGmtTimeZoneAndMinutesOffset()
138142
{
139-
$this->expectException(\Symfony\Component\Intl\Exception\NotImplementedException::class);
143+
$this->expectException(NotImplementedException::class);
140144
parent::testFormatWithGmtTimeZoneAndMinutesOffset();
141145
}
142146

143147
public function testFormatWithNonStandardTimezone()
144148
{
145-
$this->expectException(\Symfony\Component\Intl\Exception\NotImplementedException::class);
149+
$this->expectException(NotImplementedException::class);
146150
parent::testFormatWithNonStandardTimezone();
147151
}
148152

0 commit comments

Comments
 (0)