Skip to content

Commit 5e7dca8

Browse files
Merge branch '2.8' into 3.2
* 2.8: Refactored other PHPUnit method calls to work with namespaced PHPUnit 6 Further refactorings to PHPUnit namespaces resolve parameters in definition classes
2 parents e8068b4 + 8580ade commit 5e7dca8

9 files changed

+27
-17
lines changed

Tests/ButtonBuilderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function getInvalidNames()
5353
*/
5454
public function testInvalidNames($name)
5555
{
56-
$this->setExpectedException(
56+
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(
5757
'\Symfony\Component\Form\Exception\InvalidArgumentException',
5858
'Buttons cannot have empty names.'
5959
);

Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public function testTransformWrapsIntlErrors()
187187

188188
// HOW TO REPRODUCE?
189189
190-
//$this->setExpectedException('Symfony\Component\Form\Extension\Core\DataTransformer\TransformationFailedException');
190+
//$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Extension\Core\DataTransformer\TransformationFailedException');
191191

192192
//$transformer->transform(1.5);
193193
}

Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function testTransformExpectsDateTime()
110110
{
111111
$transformer = new DateTimeToStringTransformer();
112112

113-
$this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException');
113+
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\TransformationFailedException');
114114

115115
$transformer->transform('1234');
116116
}
@@ -161,7 +161,7 @@ public function testReverseTransformExpectsString()
161161
{
162162
$reverseTransformer = new DateTimeToStringTransformer();
163163

164-
$this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException');
164+
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\TransformationFailedException');
165165

166166
$reverseTransformer->reverseTransform(1234);
167167
}
@@ -170,7 +170,7 @@ public function testReverseTransformExpectsValidDateString()
170170
{
171171
$reverseTransformer = new DateTimeToStringTransformer();
172172

173-
$this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException');
173+
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\TransformationFailedException');
174174

175175
$reverseTransformer->reverseTransform('2010-2010-2010');
176176
}
@@ -179,7 +179,7 @@ public function testReverseTransformWithNonExistingDate()
179179
{
180180
$reverseTransformer = new DateTimeToStringTransformer();
181181

182-
$this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException');
182+
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\TransformationFailedException');
183183

184184
$reverseTransformer->reverseTransform('2010-04-31');
185185
}

Tests/Extension/Core/DataTransformer/DateTimeToTimestampTransformerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function testTransformExpectsDateTime()
7171
{
7272
$transformer = new DateTimeToTimestampTransformer();
7373

74-
$this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException');
74+
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\TransformationFailedException');
7575

7676
$transformer->transform('1234');
7777
}
@@ -108,7 +108,7 @@ public function testReverseTransformExpectsValidTimestamp()
108108
{
109109
$reverseTransformer = new DateTimeToTimestampTransformer();
110110

111-
$this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException');
111+
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\TransformationFailedException');
112112

113113
$reverseTransformer->reverseTransform('2010-2010-2010');
114114
}

Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function testTransformExpectsNumeric()
3333
{
3434
$transformer = new MoneyToLocalizedStringTransformer(null, null, null, 100);
3535

36-
$this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException');
36+
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\TransformationFailedException');
3737

3838
$transformer->transform('abcd');
3939
}
@@ -61,7 +61,7 @@ public function testReverseTransformExpectsString()
6161
{
6262
$transformer = new MoneyToLocalizedStringTransformer(null, null, null, 100);
6363

64-
$this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException');
64+
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\TransformationFailedException');
6565

6666
$transformer->reverseTransform(12345);
6767
}

Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public function testTransformExpectsNumeric()
106106
{
107107
$transformer = new PercentToLocalizedStringTransformer();
108108

109-
$this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException');
109+
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\TransformationFailedException');
110110

111111
$transformer->transform('foo');
112112
}
@@ -115,7 +115,7 @@ public function testReverseTransformExpectsString()
115115
{
116116
$transformer = new PercentToLocalizedStringTransformer();
117117

118-
$this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException');
118+
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\TransformationFailedException');
119119

120120
$transformer->reverseTransform(1);
121121
}

Tests/Extension/Core/Type/CollectionTypeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function testThrowsExceptionIfObjectIsNotTraversable()
5858
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array(
5959
'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\TextType',
6060
));
61-
$this->setExpectedException('Symfony\Component\Form\Exception\UnexpectedTypeException');
61+
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\UnexpectedTypeException');
6262
$form->setData(new \stdClass());
6363
}
6464

Tests/FormBuilderTest.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ public function testNoSetName()
4949

5050
public function testAddNameNoStringAndNoInteger()
5151
{
52-
$this->setExpectedException('Symfony\Component\Form\Exception\UnexpectedTypeException');
52+
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\UnexpectedTypeException');
5353
$this->builder->add(true);
5454
}
5555

5656
public function testAddTypeNoString()
5757
{
58-
$this->setExpectedException('Symfony\Component\Form\Exception\UnexpectedTypeException');
58+
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\UnexpectedTypeException');
5959
$this->builder->add('foo', 1234);
6060
}
6161

@@ -165,7 +165,13 @@ public function testAddButton()
165165

166166
public function testGetUnknown()
167167
{
168-
$this->setExpectedException('Symfony\Component\Form\Exception\InvalidArgumentException', 'The child with the name "foo" does not exist.');
168+
if (method_exists($this, 'expectException')) {
169+
$this->expectException('Symfony\Component\Form\Exception\InvalidArgumentException');
170+
$this->expectExceptionMessage('The child with the name "foo" does not exist.');
171+
} else {
172+
$this->setExpectedException('Symfony\Component\Form\Exception\InvalidArgumentException', 'The child with the name "foo" does not exist.');
173+
}
174+
169175
$this->builder->get('foo');
170176
}
171177

Tests/Resources/TranslationFilesTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ class TranslationFilesTest extends TestCase
2020
*/
2121
public function testTranslationFileIsValid($filePath)
2222
{
23-
\PHPUnit_Util_XML::loadfile($filePath, false, false, true);
23+
if (class_exists('PHPUnit_Util_XML')) {
24+
\PHPUnit_Util_XML::loadfile($filePath, false, false, true);
25+
} else {
26+
\PHPUnit\Util\XML::loadfile($filePath, false, false, true);
27+
}
2428
}
2529

2630
public function provideTranslationFiles()

0 commit comments

Comments
 (0)