Skip to content

Commit 5533f13

Browse files
Merge branch '2.8' into 3.2
* 2.8: Update to PHPUnit namespaces Minor typo fix messsagesData -> messagesData remove translation data collector when not usable
2 parents 855429e + b44d255 commit 5533f13

File tree

1 file changed

+32
-30
lines changed

1 file changed

+32
-30
lines changed

Tests/OptionsResolverTest.php

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111

1212
namespace Symfony\Component\OptionsResolver\Tests;
1313

14+
use PHPUnit\Framework\Assert;
15+
use PHPUnit\Framework\TestCase;
1416
use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException;
1517
use Symfony\Component\OptionsResolver\Options;
1618
use Symfony\Component\OptionsResolver\OptionsResolver;
1719

18-
class OptionsResolverTest extends \PHPUnit_Framework_TestCase
20+
class OptionsResolverTest extends TestCase
1921
{
2022
/**
2123
* @var OptionsResolver
@@ -134,7 +136,7 @@ public function testSetLazyClosure()
134136
public function testClosureWithoutTypeHintNotInvoked()
135137
{
136138
$closure = function ($options) {
137-
\PHPUnit_Framework_Assert::fail('Should not be called');
139+
Assert::fail('Should not be called');
138140
};
139141

140142
$this->resolver->setDefault('foo', $closure);
@@ -145,7 +147,7 @@ public function testClosureWithoutTypeHintNotInvoked()
145147
public function testClosureWithoutParametersNotInvoked()
146148
{
147149
$closure = function () {
148-
\PHPUnit_Framework_Assert::fail('Should not be called');
150+
Assert::fail('Should not be called');
149151
};
150152

151153
$this->resolver->setDefault('foo', $closure);
@@ -160,7 +162,7 @@ public function testAccessPreviousDefaultValue()
160162

161163
// defined by subclass
162164
$this->resolver->setDefault('foo', function (Options $options, $previousValue) {
163-
\PHPUnit_Framework_Assert::assertEquals('bar', $previousValue);
165+
Assert::assertEquals('bar', $previousValue);
164166

165167
return 'lazy';
166168
});
@@ -177,7 +179,7 @@ public function testAccessPreviousLazyDefaultValue()
177179

178180
// defined by subclass
179181
$this->resolver->setDefault('foo', function (Options $options, $previousValue) {
180-
\PHPUnit_Framework_Assert::assertEquals('bar', $previousValue);
182+
Assert::assertEquals('bar', $previousValue);
181183

182184
return 'lazy';
183185
});
@@ -189,7 +191,7 @@ public function testPreviousValueIsNotEvaluatedIfNoSecondArgument()
189191
{
190192
// defined by superclass
191193
$this->resolver->setDefault('foo', function () {
192-
\PHPUnit_Framework_Assert::fail('Should not be called');
194+
Assert::fail('Should not be called');
193195
});
194196

195197
// defined by subclass, no $previousValue argument defined!
@@ -203,7 +205,7 @@ public function testPreviousValueIsNotEvaluatedIfNoSecondArgument()
203205
public function testOverwrittenLazyOptionNotEvaluated()
204206
{
205207
$this->resolver->setDefault('foo', function (Options $options) {
206-
\PHPUnit_Framework_Assert::fail('Should not be called');
208+
Assert::fail('Should not be called');
207209
});
208210

209211
$this->resolver->setDefault('foo', 'bar');
@@ -216,13 +218,13 @@ public function testInvokeEachLazyOptionOnlyOnce()
216218
$calls = 0;
217219

218220
$this->resolver->setDefault('lazy1', function (Options $options) use (&$calls) {
219-
\PHPUnit_Framework_Assert::assertSame(1, ++$calls);
221+
Assert::assertSame(1, ++$calls);
220222

221223
$options['lazy2'];
222224
});
223225

224226
$this->resolver->setDefault('lazy2', function (Options $options) use (&$calls) {
225-
\PHPUnit_Framework_Assert::assertSame(2, ++$calls);
227+
Assert::assertSame(2, ++$calls);
226228
});
227229

228230
$this->resolver->resolve();
@@ -996,7 +998,7 @@ public function testValidateTypeBeforeNormalization()
996998
$this->resolver->setAllowedTypes('foo', 'int');
997999

9981000
$this->resolver->setNormalizer('foo', function () {
999-
\PHPUnit_Framework_Assert::fail('Should not be called.');
1001+
Assert::fail('Should not be called.');
10001002
});
10011003

10021004
$this->resolver->resolve();
@@ -1012,7 +1014,7 @@ public function testValidateValueBeforeNormalization()
10121014
$this->resolver->setAllowedValues('foo', 'baz');
10131015

10141016
$this->resolver->setNormalizer('foo', function () {
1015-
\PHPUnit_Framework_Assert::fail('Should not be called.');
1017+
Assert::fail('Should not be called.');
10161018
});
10171019

10181020
$this->resolver->resolve();
@@ -1024,8 +1026,8 @@ public function testNormalizerCanAccessOtherOptions()
10241026
$this->resolver->setDefault('norm', 'baz');
10251027

10261028
$this->resolver->setNormalizer('norm', function (Options $options) {
1027-
/* @var \PHPUnit_Framework_TestCase $test */
1028-
\PHPUnit_Framework_Assert::assertSame('bar', $options['default']);
1029+
/* @var TestCase $test */
1030+
Assert::assertSame('bar', $options['default']);
10291031

10301032
return 'normalized';
10311033
});
@@ -1044,8 +1046,8 @@ public function testNormalizerCanAccessLazyOptions()
10441046
$this->resolver->setDefault('norm', 'baz');
10451047

10461048
$this->resolver->setNormalizer('norm', function (Options $options) {
1047-
/* @var \PHPUnit_Framework_TestCase $test */
1048-
\PHPUnit_Framework_Assert::assertEquals('bar', $options['lazy']);
1049+
/* @var TestCase $test */
1050+
Assert::assertEquals('bar', $options['lazy']);
10491051

10501052
return 'normalized';
10511053
});
@@ -1151,12 +1153,12 @@ public function testInvokeEachNormalizerOnlyOnce()
11511153
$this->resolver->setDefault('norm2', 'baz');
11521154

11531155
$this->resolver->setNormalizer('norm1', function ($options) use (&$calls) {
1154-
\PHPUnit_Framework_Assert::assertSame(1, ++$calls);
1156+
Assert::assertSame(1, ++$calls);
11551157

11561158
$options['norm2'];
11571159
});
11581160
$this->resolver->setNormalizer('norm2', function () use (&$calls) {
1159-
\PHPUnit_Framework_Assert::assertSame(2, ++$calls);
1161+
Assert::assertSame(2, ++$calls);
11601162
});
11611163

11621164
$this->resolver->resolve();
@@ -1169,7 +1171,7 @@ public function testNormalizerNotCalledForUnsetOptions()
11691171
$this->resolver->setDefined('norm');
11701172

11711173
$this->resolver->setNormalizer('norm', function () {
1172-
\PHPUnit_Framework_Assert::fail('Should not be called.');
1174+
Assert::fail('Should not be called.');
11731175
});
11741176

11751177
$this->assertEmpty($this->resolver->resolve());
@@ -1410,17 +1412,17 @@ public function testArrayAccess()
14101412
});
14111413

14121414
$this->resolver->setDefault('lazy2', function (Options $options) {
1413-
\PHPUnit_Framework_Assert::assertTrue(isset($options['default1']));
1414-
\PHPUnit_Framework_Assert::assertTrue(isset($options['default2']));
1415-
\PHPUnit_Framework_Assert::assertTrue(isset($options['required']));
1416-
\PHPUnit_Framework_Assert::assertTrue(isset($options['lazy1']));
1417-
\PHPUnit_Framework_Assert::assertTrue(isset($options['lazy2']));
1418-
\PHPUnit_Framework_Assert::assertFalse(isset($options['defined']));
1419-
1420-
\PHPUnit_Framework_Assert::assertSame(0, $options['default1']);
1421-
\PHPUnit_Framework_Assert::assertSame(42, $options['default2']);
1422-
\PHPUnit_Framework_Assert::assertSame('value', $options['required']);
1423-
\PHPUnit_Framework_Assert::assertSame('lazy', $options['lazy1']);
1415+
Assert::assertTrue(isset($options['default1']));
1416+
Assert::assertTrue(isset($options['default2']));
1417+
Assert::assertTrue(isset($options['required']));
1418+
Assert::assertTrue(isset($options['lazy1']));
1419+
Assert::assertTrue(isset($options['lazy2']));
1420+
Assert::assertFalse(isset($options['defined']));
1421+
1422+
Assert::assertSame(0, $options['default1']);
1423+
Assert::assertSame(42, $options['default2']);
1424+
Assert::assertSame('value', $options['required']);
1425+
Assert::assertSame('lazy', $options['lazy1']);
14241426

14251427
// Obviously $options['lazy'] and $options['defined'] cannot be
14261428
// accessed
@@ -1525,7 +1527,7 @@ public function testCount()
15251527
$this->resolver->setDefault('lazy1', function () {});
15261528

15271529
$this->resolver->setDefault('lazy2', function (Options $options) {
1528-
\PHPUnit_Framework_Assert::assertCount(4, $options);
1530+
Assert::assertCount(4, $options);
15291531
});
15301532

15311533
$this->assertCount(4, $this->resolver->resolve(array('required' => 'value')));

0 commit comments

Comments
 (0)