diff options
author | Stefan Giehl <stefan@matomo.org> | 2020-02-27 13:08:45 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-27 13:08:45 +0300 |
commit | 93aef4865cfdee9fcfa5acc9ff1950459a0af42e (patch) | |
tree | aa8ad643d8ad233ffb2b033a437bcd2b71274877 /plugins/TwoFactorAuth | |
parent | f28c7fa6cb6c63c8f459206448c7dcb93568099e (diff) |
Update to PHPUnit 8.5 (#15581)
* use latest phpunit/phpunit ~8.5
* submodule updates
* fixes
Diffstat (limited to 'plugins/TwoFactorAuth')
12 files changed, 30 insertions, 35 deletions
diff --git a/plugins/TwoFactorAuth/tests/Fixtures/SimpleFixtureTrackFewVisits.php b/plugins/TwoFactorAuth/tests/Fixtures/SimpleFixtureTrackFewVisits.php index b8b4468407..882f165747 100644 --- a/plugins/TwoFactorAuth/tests/Fixtures/SimpleFixtureTrackFewVisits.php +++ b/plugins/TwoFactorAuth/tests/Fixtures/SimpleFixtureTrackFewVisits.php @@ -20,14 +20,14 @@ class SimpleFixtureTrackFewVisits extends Fixture public $dateTime = '2013-01-23 01:23:45'; public $idSite = 1; - public function setUp() + public function setUp(): void { $this->setUpWebsite(); Fixture::createSuperUser(true); $this->createSuperUser = true; } - public function tearDown() + public function tearDown(): void { // empty } diff --git a/plugins/TwoFactorAuth/tests/Fixtures/TwoFactorFixture.php b/plugins/TwoFactorAuth/tests/Fixtures/TwoFactorFixture.php index 3b71c0eba7..f5b047ced5 100644 --- a/plugins/TwoFactorAuth/tests/Fixtures/TwoFactorFixture.php +++ b/plugins/TwoFactorAuth/tests/Fixtures/TwoFactorFixture.php @@ -42,7 +42,7 @@ class TwoFactorFixture extends Fixture */ private $twoFa; - public function setUp() + public function setUp(): void { $this->dao = StaticContainer::get(RecoveryCodeDao::class); $this->twoFa = StaticContainer::get(TwoFactorAuthentication::class); @@ -52,7 +52,7 @@ class TwoFactorFixture extends Fixture $this->trackFirstVisit(); } - public function tearDown() + public function tearDown(): void { // empty } diff --git a/plugins/TwoFactorAuth/tests/Integration/APITest.php b/plugins/TwoFactorAuth/tests/Integration/APITest.php index 4f8b738138..500076d246 100644 --- a/plugins/TwoFactorAuth/tests/Integration/APITest.php +++ b/plugins/TwoFactorAuth/tests/Integration/APITest.php @@ -39,7 +39,7 @@ class APITest extends IntegrationTestCase */ private $twoFa; - public function setUp() + public function setUp(): void { parent::setUp(); @@ -56,12 +56,11 @@ class APITest extends IntegrationTestCase $this->twoFa = StaticContainer::get(TwoFactorAuthentication::class); } - /** - * @expectedExceptionMessage checkUserHasSuperUserAccess Fake exception - * @expectedException \Exception - */ public function test_resetTwoFactorAuth_failsWhenNotPermissions() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('checkUserHasSuperUserAccess Fake exception'); + $this->setAdminUser(); $this->api->resetTwoFactorAuth('login'); } diff --git a/plugins/TwoFactorAuth/tests/Integration/Dao/RecoveryCodeDaoTest.php b/plugins/TwoFactorAuth/tests/Integration/Dao/RecoveryCodeDaoTest.php index 9eda0e9531..b084c85080 100644 --- a/plugins/TwoFactorAuth/tests/Integration/Dao/RecoveryCodeDaoTest.php +++ b/plugins/TwoFactorAuth/tests/Integration/Dao/RecoveryCodeDaoTest.php @@ -25,7 +25,7 @@ class RecoveryCodeDaoTest extends IntegrationTestCase */ private $dao; - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/plugins/TwoFactorAuth/tests/Integration/Dao/RecoveryCodeRandomGeneratorTest.php b/plugins/TwoFactorAuth/tests/Integration/Dao/RecoveryCodeRandomGeneratorTest.php index e3449386c1..cc51316e33 100644 --- a/plugins/TwoFactorAuth/tests/Integration/Dao/RecoveryCodeRandomGeneratorTest.php +++ b/plugins/TwoFactorAuth/tests/Integration/Dao/RecoveryCodeRandomGeneratorTest.php @@ -24,7 +24,7 @@ class RecoveryCodeRandomGeneratorTest extends IntegrationTestCase */ private $generator; - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/plugins/TwoFactorAuth/tests/Integration/Dao/RecoveryCodeStaticGeneratorTest.php b/plugins/TwoFactorAuth/tests/Integration/Dao/RecoveryCodeStaticGeneratorTest.php index 3ffc97b7a9..1d5193208d 100644 --- a/plugins/TwoFactorAuth/tests/Integration/Dao/RecoveryCodeStaticGeneratorTest.php +++ b/plugins/TwoFactorAuth/tests/Integration/Dao/RecoveryCodeStaticGeneratorTest.php @@ -24,7 +24,7 @@ class RecoveryCodeStaticGeneratorTest extends IntegrationTestCase */ private $generator; - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/plugins/TwoFactorAuth/tests/Integration/Dao/TwoFaSecretRandomGeneratorTest.php b/plugins/TwoFactorAuth/tests/Integration/Dao/TwoFaSecretRandomGeneratorTest.php index 2a0cf55384..bdd847205e 100644 --- a/plugins/TwoFactorAuth/tests/Integration/Dao/TwoFaSecretRandomGeneratorTest.php +++ b/plugins/TwoFactorAuth/tests/Integration/Dao/TwoFaSecretRandomGeneratorTest.php @@ -24,7 +24,7 @@ class TwoFaSecretRandomGeneratorTest extends IntegrationTestCase */ private $generator; - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/plugins/TwoFactorAuth/tests/Integration/Dao/TwoFaSecretStaticGeneratorTest.php b/plugins/TwoFactorAuth/tests/Integration/Dao/TwoFaSecretStaticGeneratorTest.php index e5fa4883c4..84d1e9116a 100644 --- a/plugins/TwoFactorAuth/tests/Integration/Dao/TwoFaSecretStaticGeneratorTest.php +++ b/plugins/TwoFactorAuth/tests/Integration/Dao/TwoFaSecretStaticGeneratorTest.php @@ -23,7 +23,7 @@ class TwoFaSecretStaticGeneratorTest extends IntegrationTestCase */ private $generator; - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/plugins/TwoFactorAuth/tests/Integration/SystemSettingsTest.php b/plugins/TwoFactorAuth/tests/Integration/SystemSettingsTest.php index fb9d507e26..ad043450d1 100644 --- a/plugins/TwoFactorAuth/tests/Integration/SystemSettingsTest.php +++ b/plugins/TwoFactorAuth/tests/Integration/SystemSettingsTest.php @@ -24,7 +24,7 @@ class SystemSettingsTest extends IntegrationTestCase */ private $settings; - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/plugins/TwoFactorAuth/tests/Integration/TwoFactorAuthTest.php b/plugins/TwoFactorAuth/tests/Integration/TwoFactorAuthTest.php index 07429e2916..797620443c 100644 --- a/plugins/TwoFactorAuth/tests/Integration/TwoFactorAuthTest.php +++ b/plugins/TwoFactorAuth/tests/Integration/TwoFactorAuthTest.php @@ -44,7 +44,7 @@ class TwoFactorAuthTest extends IntegrationTestCase private $userPassword = '123abcDk3_l3'; private $user2faSecret = '123456'; - public function setUp() + public function setUp(): void { parent::setUp(); @@ -64,7 +64,7 @@ class TwoFactorAuthTest extends IntegrationTestCase unset($_GET['authCode']); } - public function tearDown() + public function tearDown(): void { unset($_GET['authCode']); } @@ -87,24 +87,22 @@ class TwoFactorAuthTest extends IntegrationTestCase $this->assertEquals(32, strlen($token)); } - /** - * @expectedException \Exception - * @expectedExceptionMessage TwoFactorAuth_MissingAuthCodeAPI - */ public function test_onApiGetTokenAuth_throwsErrorWhenMissingTokenWhenUsing2FaAndAuthenticatedCorrectly() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('TwoFactorAuth_MissingAuthCodeAPI'); + Request::processRequest('UsersManager.getTokenAuth', array( 'userLogin' => $this->userWith2Fa, 'md5Password' => md5($this->userPassword) )); } - /** - * @expectedException \Exception - * @expectedExceptionMessage TwoFactorAuth_InvalidAuthCode - */ public function test_onApiGetTokenAuth_throwsErrorWhenInvalidTokenWhenUsing2FaAndAuthenticatedCorrectly() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('TwoFactorAuth_InvalidAuthCode'); + $_GET['authCode'] = '111222'; Request::processRequest('UsersManager.getTokenAuth', array( 'userLogin' => $this->userWith2Fa, diff --git a/plugins/TwoFactorAuth/tests/Integration/TwoFactorAuthenticationTest.php b/plugins/TwoFactorAuth/tests/Integration/TwoFactorAuthenticationTest.php index 154e343cce..d70bc8010e 100644 --- a/plugins/TwoFactorAuth/tests/Integration/TwoFactorAuthenticationTest.php +++ b/plugins/TwoFactorAuth/tests/Integration/TwoFactorAuthenticationTest.php @@ -39,7 +39,7 @@ class TwoFactorAuthenticationTest extends IntegrationTestCase */ private $twoFa; - public function setUp() + public function setUp(): void { parent::setUp(); @@ -92,21 +92,19 @@ class TwoFactorAuthenticationTest extends IntegrationTestCase $this->assertEquals([], $this->dao->getAllRecoveryCodesForLogin('mylogin')); } - /** - * @expectedExceptionMessage Anonymous cannot use - * @expectedException \Exception - */ public function test_saveSecret_neverWorksForAnonymous() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Anonymous cannot use'); + $this->twoFa->saveSecret('anonymous', '123456'); } - /** - * @expectedExceptionMessage no recovery codes have been created - * @expectedException \Exception - */ public function test_saveSecret_notWorksWhenNoRecoveryCodesCreated() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('no recovery codes have been created'); + $this->twoFa->saveSecret('not', '123456'); } diff --git a/plugins/TwoFactorAuth/tests/System/TwoFactorAuthTest.php b/plugins/TwoFactorAuth/tests/System/TwoFactorAuthTest.php index 4f32be9264..129f1c4275 100644 --- a/plugins/TwoFactorAuth/tests/System/TwoFactorAuthTest.php +++ b/plugins/TwoFactorAuth/tests/System/TwoFactorAuthTest.php @@ -47,7 +47,7 @@ class TwoFactorAuthTest extends SystemTestCase */ private $twoFa; - public function setUp() + public function setUp(): void { parent::setUp(); |