updated tests
This commit is contained in:
parent
735a7d3554
commit
774334aa88
|
@ -1,9 +1,8 @@
|
|||
<?php
|
||||
/*
|
||||
$Id$
|
||||
|
||||
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
||||
Copyright (C) 2016 Roland Gruber
|
||||
Copyright (C) 2016 - 2018 Roland Gruber
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -45,6 +44,7 @@ if (is_readable('lam/lib/modules/ppolicyUser.inc')) {
|
|||
const ONE_YEAR_POLICY = 'cn=policy1,dc=test';
|
||||
|
||||
private $options = array();
|
||||
private $resultLog = null;
|
||||
|
||||
public function setUp() {
|
||||
$this->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() {
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
<?php
|
||||
/*
|
||||
$Id$
|
||||
|
||||
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
||||
Copyright (C) 2016 - 2017 Roland Gruber
|
||||
Copyright (C) 2016 - 2018 Roland Gruber
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -131,6 +130,7 @@ if (is_readable('lam/lib/passwordExpirationJob.inc')) {
|
|||
const WARNING = '14';
|
||||
|
||||
private $options = array();
|
||||
private $resultLog = null;
|
||||
|
||||
public function setUp() {
|
||||
$this->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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue