Skip to content

Commit dab2c2e

Browse files
committed
Fix deprecated phpunit annotation
1 parent a77d5fe commit dab2c2e

File tree

5 files changed

+65
-128
lines changed

5 files changed

+65
-128
lines changed

Tests/Command/LintCommandTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,9 @@ public function testCustomTagsError()
8181
$this->assertSame(1, $ret, 'lint:yaml exits with code 1 in case of error');
8282
}
8383

84-
/**
85-
* @expectedException \RuntimeException
86-
*/
8784
public function testLintFileNotReadable()
8885
{
86+
$this->expectException('RuntimeException');
8987
$tester = $this->createCommandTester();
9088
$filename = $this->createFile('');
9189
unlink($filename);

Tests/DumperTest.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -234,20 +234,18 @@ public function testObjectSupportDisabledButNoExceptions()
234234
$this->assertEquals('{ foo: null, bar: 1 }', $dump, '->dump() does not dump objects when disabled');
235235
}
236236

237-
/**
238-
* @expectedException \Symfony\Component\Yaml\Exception\DumpException
239-
*/
240237
public function testObjectSupportDisabledWithExceptions()
241238
{
239+
$this->expectException('Symfony\Component\Yaml\Exception\DumpException');
242240
$this->dumper->dump(['foo' => new A(), 'bar' => 1], 0, 0, Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE);
243241
}
244242

245243
/**
246244
* @group legacy
247-
* @expectedException \Symfony\Component\Yaml\Exception\DumpException
248245
*/
249246
public function testObjectSupportDisabledWithExceptionsPassingTrue()
250247
{
248+
$this->expectException('Symfony\Component\Yaml\Exception\DumpException');
251249
$this->dumper->dump(['foo' => new A(), 'bar' => 1], 0, 0, true);
252250
}
253251

@@ -562,21 +560,17 @@ public function testCarriageReturnIsMaintainedWhenDumpingAsMultiLineLiteralBlock
562560
$this->assertSame("- \"a\\r\\nb\\nc\"\n", $this->dumper->dump(["a\r\nb\nc"], 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK));
563561
}
564562

565-
/**
566-
* @expectedException \InvalidArgumentException
567-
* @expectedExceptionMessage The indentation must be greater than zero
568-
*/
569563
public function testZeroIndentationThrowsException()
570564
{
565+
$this->expectException('InvalidArgumentException');
566+
$this->expectExceptionMessage('The indentation must be greater than zero');
571567
new Dumper(0);
572568
}
573569

574-
/**
575-
* @expectedException \InvalidArgumentException
576-
* @expectedExceptionMessage The indentation must be greater than zero
577-
*/
578570
public function testNegativeIndentationThrowsException()
579571
{
572+
$this->expectException('InvalidArgumentException');
573+
$this->expectExceptionMessage('The indentation must be greater than zero');
580574
new Dumper(-4);
581575
}
582576
}

Tests/InlineTest.php

Lines changed: 21 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,17 @@ public function getTestsForParsePhpConstants()
6565
];
6666
}
6767

68-
/**
69-
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
70-
* @expectedExceptionMessage The constant "WRONG_CONSTANT" is not defined
71-
*/
7268
public function testParsePhpConstantThrowsExceptionWhenUndefined()
7369
{
70+
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
71+
$this->expectExceptionMessage('The constant "WRONG_CONSTANT" is not defined');
7472
Inline::parse('!php/const WRONG_CONSTANT', Yaml::PARSE_CONSTANT);
7573
}
7674

77-
/**
78-
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
79-
* @expectedExceptionMessageRegExp #The string "!php/const PHP_INT_MAX" could not be parsed as a constant.*#
80-
*/
8175
public function testParsePhpConstantThrowsExceptionOnInvalidType()
8276
{
77+
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
78+
$this->expectExceptionMessageRegExp('#The string "!php/const PHP_INT_MAX" could not be parsed as a constant.*#');
8379
Inline::parse('!php/const PHP_INT_MAX', Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE);
8480
}
8581

@@ -152,46 +148,36 @@ public function testHashStringsResemblingExponentialNumericsShouldNotBeChangedTo
152148
$this->assertSame($value, Inline::parse(Inline::dump($value)));
153149
}
154150

155-
/**
156-
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
157-
* @expectedExceptionMessage Found unknown escape character "\V".
158-
*/
159151
public function testParseScalarWithNonEscapedBlackslashShouldThrowException()
160152
{
153+
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
154+
$this->expectExceptionMessage('Found unknown escape character "\V".');
161155
Inline::parse('"Foo\Var"');
162156
}
163157

164-
/**
165-
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
166-
*/
167158
public function testParseScalarWithNonEscapedBlackslashAtTheEndShouldThrowException()
168159
{
160+
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
169161
Inline::parse('"Foo\\"');
170162
}
171163

172-
/**
173-
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
174-
*/
175164
public function testParseScalarWithIncorrectlyQuotedStringShouldThrowException()
176165
{
166+
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
177167
$value = "'don't do somthin' like that'";
178168
Inline::parse($value);
179169
}
180170

181-
/**
182-
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
183-
*/
184171
public function testParseScalarWithIncorrectlyDoubleQuotedStringShouldThrowException()
185172
{
173+
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
186174
$value = '"don"t do somthin" like that"';
187175
Inline::parse($value);
188176
}
189177

190-
/**
191-
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
192-
*/
193178
public function testParseInvalidMappingKeyShouldThrowException()
194179
{
180+
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
195181
$value = '{ "foo " bar": "bar" }';
196182
Inline::parse($value);
197183
}
@@ -206,19 +192,15 @@ public function testParseMappingKeyWithColonNotFollowedBySpace()
206192
Inline::parse('{1:""}');
207193
}
208194

209-
/**
210-
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
211-
*/
212195
public function testParseInvalidMappingShouldThrowException()
213196
{
197+
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
214198
Inline::parse('[foo] bar');
215199
}
216200

217-
/**
218-
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
219-
*/
220201
public function testParseInvalidSequenceShouldThrowException()
221202
{
203+
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
222204
Inline::parse('{ foo: bar } bar');
223205
}
224206

@@ -284,21 +266,17 @@ public function testParseMapReferenceInSequenceAsFifthArgument()
284266
$this->assertSame([$foo], Inline::parse('[*foo]', false, false, false, ['foo' => $foo]));
285267
}
286268

287-
/**
288-
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
289-
* @expectedExceptionMessage A reference must contain at least one character at line 1.
290-
*/
291269
public function testParseUnquotedAsterisk()
292270
{
271+
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
272+
$this->expectExceptionMessage('A reference must contain at least one character at line 1.');
293273
Inline::parse('{ foo: * }');
294274
}
295275

296-
/**
297-
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
298-
* @expectedExceptionMessage A reference must contain at least one character at line 1.
299-
*/
300276
public function testParseUnquotedAsteriskFollowedByAComment()
301277
{
278+
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
279+
$this->expectExceptionMessage('A reference must contain at least one character at line 1.');
302280
Inline::parse('{ foo: * #foo }');
303281
}
304282

@@ -688,10 +666,10 @@ public function getBinaryData()
688666

689667
/**
690668
* @dataProvider getInvalidBinaryData
691-
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
692669
*/
693670
public function testParseInvalidBinaryData($data, $expectedMessage)
694671
{
672+
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
695673
$this->expectExceptionMessageRegExp($expectedMessage);
696674

697675
Inline::parse($data);
@@ -707,12 +685,10 @@ public function getInvalidBinaryData()
707685
];
708686
}
709687

710-
/**
711-
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
712-
* @expectedExceptionMessage Malformed inline YAML string: {this, is not, supported} at line 1.
713-
*/
714688
public function testNotSupportedMissingValue()
715689
{
690+
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
691+
$this->expectExceptionMessage('Malformed inline YAML string: {this, is not, supported} at line 1.');
716692
Inline::parse('{this, is not, supported}');
717693
}
718694

@@ -796,12 +772,10 @@ public function testDeprecatedStrTag()
796772
$this->assertSame(['foo' => 'bar'], Inline::parse('{ foo: !str bar }'));
797773
}
798774

799-
/**
800-
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
801-
* @expectedExceptionMessage Unexpected end of line, expected one of ",}" at line 1 (near "{abc: 'def'").
802-
*/
803775
public function testUnfinishedInlineMap()
804776
{
777+
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
778+
$this->expectExceptionMessage('Unexpected end of line, expected one of ",}" at line 1 (near "{abc: \'def\'").');
805779
Inline::parse("{abc: 'def'");
806780
}
807781
}

0 commit comments

Comments
 (0)