11
11
12
12
use PHP_CodeSniffer \Ruleset ;
13
13
use PHP_CodeSniffer \Tests \ConfigDouble ;
14
- use PHPUnit \ Framework \ TestCase ;
14
+ use PHP_CodeSniffer \ Tests \ Core \ Ruleset \ AbstractRulesetTestCase ;
15
15
use ReflectionObject ;
16
16
17
17
/**
18
18
* These tests specifically focus on the changes made to work around the PHP 8.2 dynamic properties deprecation.
19
19
*
20
20
* @covers \PHP_CodeSniffer\Ruleset::setSniffProperty
21
21
*/
22
- final class SetSniffPropertyTest extends TestCase
22
+ final class SetSniffPropertyTest extends AbstractRulesetTestCase
23
23
{
24
24
25
25
@@ -135,15 +135,8 @@ public function testSetPropertyAppliesPropertyToMultipleSniffsInCategory()
135
135
*/
136
136
public function testSetPropertyThrowsErrorOnInvalidProperty ()
137
137
{
138
- $ exceptionClass = 'PHP_CodeSniffer\Exceptions\RuntimeException ' ;
139
- $ exceptionMsg = 'Ruleset invalid. Property "indentation" does not exist on sniff Generic.Arrays.ArrayIndent ' ;
140
- if (method_exists ($ this , 'expectException ' ) === true ) {
141
- $ this ->expectException ($ exceptionClass );
142
- $ this ->expectExceptionMessage ($ exceptionMsg );
143
- } else {
144
- // PHPUnit < 5.2.0.
145
- $ this ->setExpectedException ($ exceptionClass , $ exceptionMsg );
146
- }
138
+ $ exceptionMsg = 'Ruleset invalid. Property "indentation" does not exist on sniff Generic.Arrays.ArrayIndent ' ;
139
+ $ this ->expectRuntimeExceptionMessage ($ exceptionMsg );
147
140
148
141
// Set up the ruleset.
149
142
$ standard = __DIR__ .'/SetPropertyThrowsErrorOnInvalidPropertyTest.xml ' ;
@@ -162,15 +155,8 @@ public function testSetPropertyThrowsErrorOnInvalidProperty()
162
155
*/
163
156
public function testSetPropertyThrowsErrorWhenPropertyOnlyAllowedViaAttribute ()
164
157
{
165
- $ exceptionClass = 'PHP_CodeSniffer\Exceptions\RuntimeException ' ;
166
- $ exceptionMsg = 'Ruleset invalid. Property "arbitrarystring" does not exist on sniff TestStandard.SetProperty.NotAllowedViaAttribute ' ;
167
- if (method_exists ($ this , 'expectException ' ) === true ) {
168
- $ this ->expectException ($ exceptionClass );
169
- $ this ->expectExceptionMessage ($ exceptionMsg );
170
- } else {
171
- // PHPUnit < 5.2.0.
172
- $ this ->setExpectedException ($ exceptionClass , $ exceptionMsg );
173
- }
158
+ $ exceptionMsg = 'Ruleset invalid. Property "arbitrarystring" does not exist on sniff TestStandard.SetProperty.NotAllowedViaAttribute ' ;
159
+ $ this ->expectRuntimeExceptionMessage ($ exceptionMsg );
174
160
175
161
// Set up the ruleset.
176
162
$ standard = __DIR__ .'/SetPropertyNotAllowedViaAttributeTest.xml ' ;
0 commit comments