Skip to content

Commit 47b855b

Browse files
Merge branch '3.4' into 4.3
* 3.4: Fix tests Fix deprecated phpunit annotation
2 parents 8f4ad7e + dab2c2e commit 47b855b

File tree

5 files changed

+88
-173
lines changed

5 files changed

+88
-173
lines changed

Tests/Command/LintCommandTest.php

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

96-
/**
97-
* @expectedException \RuntimeException
98-
*/
9996
public function testLintFileNotReadable()
10097
{
98+
$this->expectException('RuntimeException');
10199
$tester = $this->createCommandTester();
102100
$filename = $this->createFile('');
103101
unlink($filename);

Tests/DumperTest.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,9 @@ public function testObjectSupportDisabledButNoExceptions()
195195
$this->assertEquals('{ foo: null, bar: 1 }', $dump, '->dump() does not dump objects when disabled');
196196
}
197197

198-
/**
199-
* @expectedException \Symfony\Component\Yaml\Exception\DumpException
200-
*/
201198
public function testObjectSupportDisabledWithExceptions()
202199
{
200+
$this->expectException('Symfony\Component\Yaml\Exception\DumpException');
203201
$this->dumper->dump(['foo' => new A(), 'bar' => 1], 0, 0, Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE);
204202
}
205203

@@ -496,21 +494,17 @@ public function testCarriageReturnIsMaintainedWhenDumpingAsMultiLineLiteralBlock
496494
$this->assertSame("- \"a\\r\\nb\\nc\"\n", $this->dumper->dump(["a\r\nb\nc"], 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK));
497495
}
498496

499-
/**
500-
* @expectedException \InvalidArgumentException
501-
* @expectedExceptionMessage The indentation must be greater than zero
502-
*/
503497
public function testZeroIndentationThrowsException()
504498
{
499+
$this->expectException('InvalidArgumentException');
500+
$this->expectExceptionMessage('The indentation must be greater than zero');
505501
new Dumper(0);
506502
}
507503

508-
/**
509-
* @expectedException \InvalidArgumentException
510-
* @expectedExceptionMessage The indentation must be greater than zero
511-
*/
512504
public function testNegativeIndentationThrowsException()
513505
{
506+
$this->expectException('InvalidArgumentException');
507+
$this->expectExceptionMessage('The indentation must be greater than zero');
514508
new Dumper(-4);
515509
}
516510
}

Tests/InlineTest.php

Lines changed: 27 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,17 @@ public function getTestsForParsePhpConstants()
6666
];
6767
}
6868

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

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

@@ -121,72 +117,56 @@ public function testHashStringsResemblingExponentialNumericsShouldNotBeChangedTo
121117
$this->assertSame($value, Inline::parse(Inline::dump($value)));
122118
}
123119

124-
/**
125-
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
126-
* @expectedExceptionMessage Found unknown escape character "\V".
127-
*/
128120
public function testParseScalarWithNonEscapedBlackslashShouldThrowException()
129121
{
122+
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
123+
$this->expectExceptionMessage('Found unknown escape character "\V".');
130124
Inline::parse('"Foo\Var"');
131125
}
132126

133-
/**
134-
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
135-
*/
136127
public function testParseScalarWithNonEscapedBlackslashAtTheEndShouldThrowException()
137128
{
129+
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
138130
Inline::parse('"Foo\\"');
139131
}
140132

141-
/**
142-
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
143-
*/
144133
public function testParseScalarWithIncorrectlyQuotedStringShouldThrowException()
145134
{
135+
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
146136
$value = "'don't do somthin' like that'";
147137
Inline::parse($value);
148138
}
149139

150-
/**
151-
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
152-
*/
153140
public function testParseScalarWithIncorrectlyDoubleQuotedStringShouldThrowException()
154141
{
142+
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
155143
$value = '"don"t do somthin" like that"';
156144
Inline::parse($value);
157145
}
158146

159-
/**
160-
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
161-
*/
162147
public function testParseInvalidMappingKeyShouldThrowException()
163148
{
149+
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
164150
$value = '{ "foo " bar": "bar" }';
165151
Inline::parse($value);
166152
}
167153

168-
/**
169-
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
170-
* @expectedExceptionMessage Colons must be followed by a space or an indication character (i.e. " ", ",", "[", "]", "{", "}")
171-
*/
172154
public function testParseMappingKeyWithColonNotFollowedBySpace()
173155
{
156+
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
157+
$this->expectExceptionMessage('Colons must be followed by a space or an indication character (i.e. " ", ",", "[", "]", "{", "}")');
174158
Inline::parse('{foo:""}');
175159
}
176160

177-
/**
178-
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
179-
*/
180161
public function testParseInvalidMappingShouldThrowException()
181162
{
163+
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
182164
Inline::parse('[foo] bar');
183165
}
184166

185-
/**
186-
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
187-
*/
188167
public function testParseInvalidSequenceShouldThrowException()
189168
{
169+
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
190170
Inline::parse('{ foo: bar } bar');
191171
}
192172

@@ -230,21 +210,17 @@ public function testParseMapReferenceInSequence()
230210
$this->assertSame([$foo], Inline::parse('[*foo]', 0, ['foo' => $foo]));
231211
}
232212

233-
/**
234-
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
235-
* @expectedExceptionMessage A reference must contain at least one character at line 1.
236-
*/
237213
public function testParseUnquotedAsterisk()
238214
{
215+
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
216+
$this->expectExceptionMessage('A reference must contain at least one character at line 1.');
239217
Inline::parse('{ foo: * }');
240218
}
241219

242-
/**
243-
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
244-
* @expectedExceptionMessage A reference must contain at least one character at line 1.
245-
*/
246220
public function testParseUnquotedAsteriskFollowedByAComment()
247221
{
222+
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
223+
$this->expectExceptionMessage('A reference must contain at least one character at line 1.');
248224
Inline::parse('{ foo: * #foo }');
249225
}
250226

@@ -615,10 +591,10 @@ public function getBinaryData()
615591

616592
/**
617593
* @dataProvider getInvalidBinaryData
618-
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
619594
*/
620595
public function testParseInvalidBinaryData($data, $expectedMessage)
621596
{
597+
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
622598
$this->expectExceptionMessageRegExp($expectedMessage);
623599

624600
Inline::parse($data);
@@ -634,12 +610,10 @@ public function getInvalidBinaryData()
634610
];
635611
}
636612

637-
/**
638-
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
639-
* @expectedExceptionMessage Malformed inline YAML string: {this, is not, supported} at line 1.
640-
*/
641613
public function testNotSupportedMissingValue()
642614
{
615+
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
616+
$this->expectExceptionMessage('Malformed inline YAML string: {this, is not, supported} at line 1.');
643617
Inline::parse('{this, is not, supported}');
644618
}
645619

@@ -653,12 +627,10 @@ public function testVeryLongQuotedStrings()
653627
$this->assertEquals($longStringWithQuotes, $arrayFromYaml['longStringWithQuotes']);
654628
}
655629

656-
/**
657-
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
658-
* @expectedExceptionMessage Missing mapping key
659-
*/
660630
public function testMappingKeysCannotBeOmitted()
661631
{
632+
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
633+
$this->expectExceptionMessage('Missing mapping key');
662634
Inline::parse('{: foo}');
663635
}
664636

@@ -684,13 +656,13 @@ public function testTheEmptyStringIsAValidMappingKey()
684656
}
685657

686658
/**
687-
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
688-
* @expectedExceptionMessage Implicit casting of incompatible mapping keys to strings is not supported. Quote your evaluable mapping keys instead
689659
*
690660
* @dataProvider getNotPhpCompatibleMappingKeyData
691661
*/
692662
public function testImplicitStringCastingOfMappingKeysIsDeprecated($yaml, $expected)
693663
{
664+
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
665+
$this->expectExceptionMessage('Implicit casting of incompatible mapping keys to strings is not supported. Quote your evaluable mapping keys instead');
694666
$this->assertSame($expected, Inline::parse($yaml));
695667
}
696668

@@ -740,12 +712,10 @@ public function testTagWithEmptyValueInMapping()
740712
$this->assertSame('', $value['foo']->getValue());
741713
}
742714

743-
/**
744-
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
745-
* @expectedExceptionMessage Unexpected end of line, expected one of ",}" at line 1 (near "{abc: 'def'").
746-
*/
747715
public function testUnfinishedInlineMap()
748716
{
717+
$this->expectException('Symfony\Component\Yaml\Exception\ParseException');
718+
$this->expectExceptionMessage('Unexpected end of line, expected one of ",}" at line 1 (near "{abc: \'def\'").');
749719
Inline::parse("{abc: 'def'");
750720
}
751721
}

0 commit comments

Comments
 (0)