From 774334aa8878cee3bfe4d5d18d1cd7384fb6dc31 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Tue, 1 May 2018 09:34:56 +0200 Subject: [PATCH] updated tests --- lam/tests/lib/modules/ppolicyUserTest.php | 30 ++++++++++++++------- lam/tests/lib/modules/shadowAccountTest.php | 26 +++++++++++------- 2 files changed, 37 insertions(+), 19 deletions(-) diff --git a/lam/tests/lib/modules/ppolicyUserTest.php b/lam/tests/lib/modules/ppolicyUserTest.php index cc6b4086..ee89f855 100644 --- a/lam/tests/lib/modules/ppolicyUserTest.php +++ b/lam/tests/lib/modules/ppolicyUserTest.php @@ -1,9 +1,8 @@ job = $this->getMockBuilder('PPolicyPasswordNotifyJob') @@ -60,6 +60,8 @@ if (is_readable('lam/lib/modules/ppolicyUser.inc')) { )); $this->options['test_mailNotificationPeriod' . PPolicyUserPasswordNotifyJobTest::JOB_ID][0] = PPolicyUserPasswordNotifyJobTest::WARNING; $this->options['test_mailDefaultPolicy' . PPolicyUserPasswordNotifyJobTest::JOB_ID][0] = PPolicyUserPasswordNotifyJobTest::DEFAULT_POLICY; + $this->resultLog = new \LAM\JOB\JobResultLog(); + $this->assertFalse($this->resultLog->hasError()); } public function testNoAccounts() { @@ -69,7 +71,8 @@ if (is_readable('lam/lib/modules/ppolicyUser.inc')) { $this->job->expects($this->never())->method('sendMail'); $pdo = array(); - $this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false); + $this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false, $this->resultLog); + $this->assertFalse($this->resultLog->hasError()); } public function testAccountDoesNotExpire() { @@ -83,7 +86,8 @@ if (is_readable('lam/lib/modules/ppolicyUser.inc')) { $this->job->expects($this->never())->method('sendMail'); $pdo = array(); - $this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false); + $this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false, $this->resultLog); + $this->assertFalse($this->resultLog->hasError()); } public function testAccountLocked() { @@ -98,7 +102,8 @@ if (is_readable('lam/lib/modules/ppolicyUser.inc')) { $this->job->expects($this->never())->method('sendMail'); $pdo = array(); - $this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false); + $this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false, $this->resultLog); + $this->assertFalse($this->resultLog->hasError()); } public function testAccountExpired() { @@ -112,7 +117,8 @@ if (is_readable('lam/lib/modules/ppolicyUser.inc')) { $this->job->expects($this->never())->method('sendMail'); $pdo = array(); - $this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false); + $this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false, $this->resultLog); + $this->assertFalse($this->resultLog->hasError()); } public function testWarningNotReached() { @@ -130,7 +136,8 @@ if (is_readable('lam/lib/modules/ppolicyUser.inc')) { $this->job->expects($this->never())->method('sendMail'); $pdo = array(); - $this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false); + $this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false, $this->resultLog); + $this->assertFalse($this->resultLog->hasError()); } public function testAlreadyWarned() { @@ -149,7 +156,8 @@ if (is_readable('lam/lib/modules/ppolicyUser.inc')) { $this->job->expects($this->never())->method('sendMail'); $pdo = array(); - $this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false); + $this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false, $this->resultLog); + $this->assertFalse($this->resultLog->hasError()); } public function testWarning() { @@ -168,7 +176,8 @@ if (is_readable('lam/lib/modules/ppolicyUser.inc')) { $this->job->expects($this->once())->method('sendMail'); $pdo = array(); - $this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false); + $this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false, $this->resultLog); + $this->assertFalse($this->resultLog->hasError()); } public function testWarningDryRun() { @@ -187,7 +196,8 @@ if (is_readable('lam/lib/modules/ppolicyUser.inc')) { $this->job->expects($this->never())->method('sendMail'); $pdo = array(); - $this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, true); + $this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, true, $this->resultLog); + $this->assertFalse($this->resultLog->hasError()); } public function testGetWarningTimeInSeconds() { diff --git a/lam/tests/lib/modules/shadowAccountTest.php b/lam/tests/lib/modules/shadowAccountTest.php index bb3f9f80..bcf49312 100644 --- a/lam/tests/lib/modules/shadowAccountTest.php +++ b/lam/tests/lib/modules/shadowAccountTest.php @@ -1,9 +1,8 @@ job = $this->getMockBuilder('ShadowAccountPasswordNotifyJob') @@ -139,6 +139,7 @@ if (is_readable('lam/lib/passwordExpirationJob.inc')) { $this->job->method('getConfigPrefix')->willReturn('test'); $this->job->method('sendMail')->willReturn(true); $this->options['test_mailNotificationPeriod' . ShadowAccountPasswordNotifyJobTest::JOB_ID][0] = ShadowAccountPasswordNotifyJobTest::WARNING; + $this->resultLog = new \LAM\JOB\JobResultLog(); } public function testNoAccounts() { @@ -148,7 +149,8 @@ if (is_readable('lam/lib/passwordExpirationJob.inc')) { $this->job->expects($this->never())->method('sendMail'); $pdo = array(); - $this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false); + $this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false, $this->resultLog); + $this->assertFalse($this->resultLog->hasError()); } public function testAccountDoesNotExpire() { @@ -162,7 +164,8 @@ if (is_readable('lam/lib/passwordExpirationJob.inc')) { $this->job->expects($this->never())->method('sendMail'); $pdo = array(); - $this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false); + $this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false, $this->resultLog); + $this->assertFalse($this->resultLog->hasError()); } public function testAccountExpired() { @@ -176,7 +179,8 @@ if (is_readable('lam/lib/passwordExpirationJob.inc')) { $this->job->expects($this->never())->method('sendMail'); $pdo = array(); - $this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false); + $this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false, $this->resultLog); + $this->assertFalse($this->resultLog->hasError()); } public function testWarningNotReached() { @@ -193,7 +197,8 @@ if (is_readable('lam/lib/passwordExpirationJob.inc')) { $this->job->expects($this->never())->method('sendMail'); $pdo = array(); - $this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false); + $this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false, $this->resultLog); + $this->assertFalse($this->resultLog->hasError()); } public function testAlreadyWarned() { @@ -211,7 +216,8 @@ if (is_readable('lam/lib/passwordExpirationJob.inc')) { $this->job->expects($this->never())->method('sendMail'); $pdo = array(); - $this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false); + $this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false, $this->resultLog); + $this->assertFalse($this->resultLog->hasError()); } public function testWarning() { @@ -229,7 +235,8 @@ if (is_readable('lam/lib/passwordExpirationJob.inc')) { $this->job->expects($this->once())->method('sendMail'); $pdo = array(); - $this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false); + $this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false, $this->resultLog); + $this->assertFalse($this->resultLog->hasError()); } public function testWarningDryRun() { @@ -247,7 +254,8 @@ if (is_readable('lam/lib/passwordExpirationJob.inc')) { $this->job->expects($this->never())->method('sendMail'); $pdo = array(); - $this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, true); + $this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, true, $this->resultLog); + $this->assertFalse($this->resultLog->hasError()); } }