Skip to content

Commit

Permalink
[Coding Style] Use camel case for method names in remaining tests (#2…
Browse files Browse the repository at this point in the history
…2160)

* [Coding Style] Use camel case for method names in remaining tests

* rename expected test files
  • Loading branch information
sgiehl authored Apr 25, 2024
1 parent 4b877ae commit f5e16d2
Show file tree
Hide file tree
Showing 62 changed files with 274 additions and 273 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function setUp(): void
$t->doTrackPageView('incredible title ');
}

public function test_ShouldThrowException_IfPeriodNotAllowed()
public function testShouldThrowExceptionIfPeriodNotAllowed()
{
$invalidPeriods = [
'day' => ['week', 'month', 'year'],
Expand All @@ -69,7 +69,7 @@ public function test_ShouldThrowException_IfPeriodNotAllowed()
}
}

public function test_ShouldReturnData_IfPeriodAllowed()
public function testShouldReturnDataIfPeriodAllowed()
{
$validPeriods = [
'day' => ['day'],
Expand All @@ -93,7 +93,7 @@ public function test_ShouldReturnData_IfPeriodAllowed()
}
}

public function test_ShouldThrowException_IfInvalidLimitBeforeGroup()
public function testShouldThrowExceptionIfInvalidLimitBeforeGroup()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('limitBeforeGrouping has to be an integer.');
Expand All @@ -108,7 +108,7 @@ public function test_ShouldThrowException_IfInvalidLimitBeforeGroup()
);
}

public function test_ShouldPass_IfLimitBeforeGroupPassingIntAsString()
public function testShouldPassIfLimitBeforeGroupPassingIntAsString()
{
$report = $this->api->getTransitionsForAction(
'http://example.org/page/one.html',
Expand All @@ -122,7 +122,7 @@ public function test_ShouldPass_IfLimitBeforeGroupPassingIntAsString()
$this->assertIsArray($report);
}

public function test_ShouldThrowException_IfRangeDayCountIsLargerThanDayPeriod()
public function testShouldThrowExceptionIfRangeDayCountIsLargerThanDayPeriod()
{
Config::setSetting('Transitions_1', 'max_period_allowed', 'day');
$this->expectException(\Exception::class);
Expand All @@ -136,7 +136,7 @@ public function test_ShouldThrowException_IfRangeDayCountIsLargerThanDayPeriod()
);
}

public function test_ShouldThrowException_IfRangeDayCountIsLargerThanWeekPeriod()
public function testShouldThrowExceptionIfRangeDayCountIsLargerThanWeekPeriod()
{
Config::setSetting('Transitions_1', 'max_period_allowed', 'day');
$this->expectException(\Exception::class);
Expand All @@ -150,7 +150,7 @@ public function test_ShouldThrowException_IfRangeDayCountIsLargerThanWeekPeriod(
);
}

public function test_ShouldThrowException_IfRangeDayCountIsLargerThanMonthPeriod()
public function testShouldThrowExceptionIfRangeDayCountIsLargerThanMonthPeriod()
{
Config::setSetting('Transitions_1', 'max_period_allowed', 'day');
$this->expectException(\Exception::class);
Expand All @@ -164,7 +164,7 @@ public function test_ShouldThrowException_IfRangeDayCountIsLargerThanMonthPeriod
);
}

public function test_ShouldThrowException_IfRangeDayCountIsLargerThanYearPeriod()
public function testShouldThrowExceptionIfRangeDayCountIsLargerThanYearPeriod()
{
Config::setSetting('Transitions_1', 'max_period_allowed', 'day');
$this->expectException(\Exception::class);
Expand All @@ -178,7 +178,7 @@ public function test_ShouldThrowException_IfRangeDayCountIsLargerThanYearPeriod(
);
}

public function test_ShouldUseSiteConfigInsteadOfGeneral_IfSiteConfigExists()
public function testShouldUseSiteConfigInsteadOfGeneralIfSiteConfigExists()
{
Config::setSetting('Transitions_1', 'max_period_allowed', null);
Config::setSetting('Transitions', 'max_period_allowed', 'month');
Expand Down
4 changes: 2 additions & 2 deletions plugins/TwoFactorAuth/tests/Integration/APITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function setUp(): void
$this->twoFa = StaticContainer::get(TwoFactorAuthentication::class);
}

public function test_resetTwoFactorAuth_failsWhenNotPermissions()
public function testResetTwoFactorAuthFailsWhenNotPermissions()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('checkUserHasSuperUserAccess Fake exception');
Expand All @@ -67,7 +67,7 @@ public function test_resetTwoFactorAuth_failsWhenNotPermissions()
$this->api->resetTwoFactorAuth('login', Fixture::ADMIN_USER_PASSWORD);
}

public function test_resetTwoFactorAuth_resetsSecret()
public function testResetTwoFactorAuthResetsSecret()
{
$this->recoveryCodes->createRecoveryCodesForLogin('mylogin1');
$this->recoveryCodes->createRecoveryCodesForLogin('mylogin2');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ public function setUp(): void
$this->dao = StaticContainer::get(RecoveryCodeDao::class);
}

public function test_shouldInstallTable()
public function testShouldInstallTable()
{
$columns = DbHelper::getTableColumns($this->dao->getPrefixedTableName());
$columns = array_keys($columns);

$this->assertEquals(['idrecoverycode', 'login', 'recovery_code'], $columns);
}

public function test_getAllRecoveryCodesForLogin_emptyByDefault()
public function testGetAllRecoveryCodesForLoginEmptyByDefault()
{
$this->assertEquals([], $this->dao->getAllRecoveryCodesForLogin('login1'));
}

public function test_insertRecoveryCode_getAllRecoveryCodesForLogin()
public function testInsertRecoveryCodeGetAllRecoveryCodesForLogin()
{
$this->dao->insertRecoveryCode('login1', '123456');
$this->dao->insertRecoveryCode('login1', '654321');
Expand All @@ -55,7 +55,7 @@ public function test_insertRecoveryCode_getAllRecoveryCodesForLogin()
$this->assertEquals(['333111'], $this->dao->getAllRecoveryCodesForLogin('login2'));
}

public function test_deleteRecoveryCode()
public function testDeleteRecoveryCode()
{
$this->insertManyCodesDifferentLogins();
$this->assertEquals(['123456', '654321'], $this->dao->getAllRecoveryCodesForLogin('login1'));
Expand All @@ -74,7 +74,7 @@ public function test_deleteRecoveryCode()
$this->assertEquals(0, $this->dao->deleteRecoveryCode('login2', '654321')); // cannot be deleted again
}

public function test_deleteAllRecoveryCodesForLogin()
public function testDeleteAllRecoveryCodesForLogin()
{
$this->insertManyCodesDifferentLogins();
$this->assertEquals(['123456', '654321'], $this->dao->getAllRecoveryCodesForLogin('login1'));
Expand All @@ -87,7 +87,7 @@ public function test_deleteAllRecoveryCodesForLogin()
$this->assertEquals([], $this->dao->getAllRecoveryCodesForLogin('login2'));
}

public function test_useRecoveryCode()
public function testUseRecoveryCode()
{
$this->insertManyCodesDifferentLogins();
$this->assertEquals(['123456', '654321'], $this->dao->getAllRecoveryCodesForLogin('login1'));
Expand All @@ -109,7 +109,7 @@ public function test_useRecoveryCode()
$this->assertEquals([], $this->dao->getAllRecoveryCodesForLogin('login2'));
}

public function test_createRecoveryCodesForLogin()
public function testCreateRecoveryCodesForLogin()
{
$this->assertEquals([], $this->dao->getAllRecoveryCodesForLogin('login1'));
$this->dao->createRecoveryCodesForLogin('login1');
Expand All @@ -135,7 +135,7 @@ public function test_createRecoveryCodesForLogin()
}
}

public function test_createRecoveryCodesForLogin_DifferentPerLogin()
public function testCreateRecoveryCodesForLoginDifferentPerLogin()
{
$this->dao->createRecoveryCodesForLogin('login1');
$this->dao->createRecoveryCodesForLogin('login2');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ public function setUp(): void
$this->generator = new RecoveryCodeRandomGenerator();
}

public function test_generatorCode_length()
public function testGeneratorCodeLength()
{
$this->assertSame(16, mb_strlen($this->generator->generateCode()));
}

public function test_generatorCode_alwaysDifferent()
public function testGeneratorCodeAlwaysDifferent()
{
$this->assertNotEquals($this->generator->generateCode(), $this->generator->generateCode());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ public function setUp(): void
$this->generator = new RecoveryCodeStaticGenerator();
}

public function test_generatorCode_length()
public function testGeneratorCodeLength()
{
$this->assertSame(16, mb_strlen($this->generator->generateCode()));
}

public function test_generatorCode_alwaysDifferent()
public function testGeneratorCodeAlwaysDifferent()
{
$this->assertNotEquals($this->generator->generateCode(), $this->generator->generateCode());
}

public function test_generatorCode_increases()
public function testGeneratorCodeIncreases()
{
$this->assertSame('1100000000000000', $this->generator->generateCode());
$this->assertSame('1200000000000000', $this->generator->generateCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ public function setUp(): void
$this->generator = new TwoFaSecretRandomGenerator();
}

public function test_generatorCode_length()
public function testGeneratorCodeLength()
{
$this->assertSame(16, mb_strlen($this->generator->generateSecret()));
}

public function test_generatorCode_alwaysDifferent()
public function testGeneratorCodeAlwaysDifferent()
{
$this->assertNotEquals($this->generator->generateSecret(), $this->generator->generateSecret());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ public function setUp(): void
$this->generator = new TwoFaSecretStaticGenerator();
}

public function test_generatorCode_alwaysSame()
public function testGeneratorCodeAlwaysSame()
{
$this->assertSame($this->generator->generateSecret(), $this->generator->generateSecret());
}

public function test_generatorCode_increases()
public function testGeneratorCodeIncreases()
{
$this->assertSame('1111111111111111', $this->generator->generateSecret());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ public function setUp(): void
$this->settings = new SystemSettings();
}

public function test_twoFactorAuthRequired_defaultDisabled()
public function testTwoFactorAuthRequiredDefaultDisabled()
{
$this->assertFalse($this->settings->twoFactorAuthRequired->getValue());
}

public function test_twoFactorAuthTitle_defaultTitle()
public function testTwoFactorAuthTitleDefaultTitle()
{
$this->assertEquals('Analytics - ' . Url::getCurrentHost(), $this->settings->twoFactorAuthTitle->getValue());
}
Expand Down
14 changes: 7 additions & 7 deletions plugins/TwoFactorAuth/tests/Integration/TwoFactorAuthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function tearDown(): void
unset($_GET['authCode']);
}

public function test_onCreateAppSpecificTokenAuth_canAuthenticateWhenUserNotUsesTwoFA()
public function testOnCreateAppSpecificTokenAuthCanAuthenticateWhenUserNotUsesTwoFA()
{
$token = Request::processRequest('UsersManager.createAppSpecificTokenAuth', array(
'userLogin' => $this->userWithout2Fa,
Expand All @@ -80,7 +80,7 @@ public function test_onCreateAppSpecificTokenAuth_canAuthenticateWhenUserNotUses
$this->assertEquals(32, strlen($token));
}

public function test_onCreateAppSpecificTokenAuth_failsWhenNotAuthenticatedEvenWhen2FAenabled()
public function testOnCreateAppSpecificTokenAuthFailsWhenNotAuthenticatedEvenWhen2FAenabled()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('UsersManager_CurrentPasswordNotCorrect');
Expand All @@ -92,7 +92,7 @@ public function test_onCreateAppSpecificTokenAuth_failsWhenNotAuthenticatedEvenW
));
}

public function test_onCreateAppSpecificTokenAuth_throwsErrorWhenMissingTokenWhenUsing2FaAndAuthenticatedCorrectly()
public function testOnCreateAppSpecificTokenAuthThrowsErrorWhenMissingTokenWhenUsing2FaAndAuthenticatedCorrectly()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('TwoFactorAuth_MissingAuthCodeAPI');
Expand All @@ -105,7 +105,7 @@ public function test_onCreateAppSpecificTokenAuth_throwsErrorWhenMissingTokenWhe
));
}

public function test_onCreateAppSpecificTokenAuth_throwsErrorWhenInvalidTokenWhenUsing2FaAndAuthenticatedCorrectly()
public function testOnCreateAppSpecificTokenAuthThrowsErrorWhenInvalidTokenWhenUsing2FaAndAuthenticatedCorrectly()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('TwoFactorAuth_InvalidAuthCode');
Expand All @@ -118,7 +118,7 @@ public function test_onCreateAppSpecificTokenAuth_throwsErrorWhenInvalidTokenWhe
));
}

public function test_onCreateAppSpecificTokenAuth_returnsCorrectTokenWhenProvidingCorrectAuthTokenOnAuthentication()
public function testOnCreateAppSpecificTokenAuthReturnsCorrectTokenWhenProvidingCorrectAuthTokenOnAuthentication()
{
$_GET['authCode'] = $this->generateValidAuthCode($this->user2faSecret);
$token = Request::processRequest('UsersManager.createAppSpecificTokenAuth', array(
Expand All @@ -129,7 +129,7 @@ public function test_onCreateAppSpecificTokenAuth_returnsCorrectTokenWhenProvidi
$this->assertEquals(32, strlen($token));
}

public function test_onDeleteUser_RemovesAllRecoveryCodesWhenUsingTwoFa()
public function testOnDeleteUserRemovesAllRecoveryCodesWhenUsingTwoFa()
{
$this->assertNotEmpty($this->dao->getAllRecoveryCodesForLogin($this->userWith2Fa));
Request::processRequest('UsersManager.deleteUser', array(
Expand All @@ -138,7 +138,7 @@ public function test_onDeleteUser_RemovesAllRecoveryCodesWhenUsingTwoFa()
$this->assertEmpty($this->dao->getAllRecoveryCodesForLogin($this->userWith2Fa));
}

public function test_onDeleteUser_DoesNotFailToDeleteUserNotUsingTwoFa()
public function testOnDeleteUserDoesNotFailToDeleteUserNotUsingTwoFa()
{
$this->expectNotToPerformAssertions();
Request::processRequest('UsersManager.deleteUser', array(
Expand Down
Loading

0 comments on commit f5e16d2

Please sign in to comment.