1111
1212use PHP_CodeSniffer \Ruleset ;
1313use PHP_CodeSniffer \Tests \ConfigDouble ;
14- use PHPUnit \ Framework \ TestCase ;
14+ use PHP_CodeSniffer \ Tests \ Core \ Ruleset \ AbstractRulesetTestCase ;
1515use ReflectionObject ;
1616
1717/**
1818 * These tests specifically focus on the changes made to work around the PHP 8.2 dynamic properties deprecation.
1919 *
2020 * @covers \PHP_CodeSniffer\Ruleset::setSniffProperty
2121 */
22- final class SetSniffPropertyTest extends TestCase
22+ final class SetSniffPropertyTest extends AbstractRulesetTestCase
2323{
2424
2525
@@ -135,15 +135,8 @@ public function testSetPropertyAppliesPropertyToMultipleSniffsInCategory()
135135 */
136136 public function testSetPropertyThrowsErrorOnInvalidProperty ()
137137 {
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 );
147140
148141 // Set up the ruleset.
149142 $ standard = __DIR__ .'/SetPropertyThrowsErrorOnInvalidPropertyTest.xml ' ;
@@ -162,15 +155,8 @@ public function testSetPropertyThrowsErrorOnInvalidProperty()
162155 */
163156 public function testSetPropertyThrowsErrorWhenPropertyOnlyAllowedViaAttribute ()
164157 {
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 );
174160
175161 // Set up the ruleset.
176162 $ standard = __DIR__ .'/SetPropertyNotAllowedViaAttributeTest.xml ' ;
0 commit comments