1212use SimpleSAML \XMLSecurity \Key \PublicKey ;
1313use SimpleSAML \XMLSecurity \Key \SymmetricKey ;
1414use SimpleSAML \XMLSecurity \Key \X509Certificate ;
15+ use TypeError ;
1516
1617/**
1718 * Tests for SimpleSAML\XMLSecurity\Alg\Signature\HMAC.
@@ -158,15 +159,10 @@ public function testVerificationFailure()
158159 public function testVerifyWithCertificate ()
159160 {
160161 $ cert = X509Certificate::fromFile ('tests/mycert.pem ' );
161- if (version_compare (phpversion (), '7.0 ' , '>= ' )) {
162- // test type errors when possible
163- $ this ->expectException (\TypeError::class);
164- new HMAC ($ cert );
165- } else {
166- // test via factory
167- $ this ->expectException (\RuntimeException::class);
168- $ this ->factory ->getAlgorithm (Constants::SIG_HMAC_SHA1 , $ cert );
169- }
162+
163+ // test type errors when possible
164+ $ this ->expectException (TypeError::class);
165+ new HMAC ($ cert );
170166 }
171167
172168
@@ -176,15 +172,10 @@ public function testVerifyWithCertificate()
176172 public function testVerifyWithPublicKey ()
177173 {
178174 $ key = PublicKey::fromFile ('tests/pubkey.pem ' );
179- if (version_compare (phpversion (), '7.0 ' , '>= ' )) {
180- // test type errors when possible
181- $ this ->expectException (\TypeError::class);
182- new HMAC ($ key );
183- } else {
184- // test via factory
185- $ this ->expectException (RuntimeException::class);
186- $ this ->factory ->getAlgorithm (Constants::SIG_HMAC_SHA1 , $ key );
187- }
175+
176+ // test type errors when possible
177+ $ this ->expectException (TypeError::class);
178+ new HMAC ($ key );
188179 }
189180
190181
@@ -194,14 +185,9 @@ public function testVerifyWithPublicKey()
194185 public function testVerifyWithPrivateKey ()
195186 {
196187 $ key = PrivateKey::fromFile ('tests/privkey.pem ' );
197- if (version_compare (phpversion (), '7.0 ' , '>= ' )) {
198- // test type errors when possible
199- $ this ->expectException (\TypeError::class);
200- new HMAC ($ key );
201- } else {
202- // test via factory
203- $ this ->expectException (RuntimeException::class);
204- $ this ->factory ->getAlgorithm (Constants::SIG_HMAC_SHA1 , $ key );
205- }
188+
189+ // test type errors when possible
190+ $ this ->expectException (TypeError::class);
191+ new HMAC ($ key );
206192 }
207193}
0 commit comments