2015-05-29 17:05:26 +02:00
|
|
|
<?php
|
|
|
|
namespace Framadate\Services;
|
|
|
|
|
|
|
|
use Framadate\FramaTestCase;
|
|
|
|
|
|
|
|
class MailServiceUnitTest extends FramaTestCase {
|
2015-05-29 17:06:03 +02:00
|
|
|
const MSG_KEY = '666';
|
2015-05-29 17:05:26 +02:00
|
|
|
|
2018-04-06 09:46:30 +02:00
|
|
|
public function test_should_send_a_2nd_mail_after_a_good_interval() {
|
2015-05-29 17:06:03 +02:00
|
|
|
// Given
|
|
|
|
$mailService = new MailService(true);
|
2015-05-29 17:41:50 +02:00
|
|
|
$_SESSION[MailService::MAILSERVICE_KEY] = [self::MSG_KEY => time() - 1000];
|
2015-05-29 17:06:03 +02:00
|
|
|
|
|
|
|
// When
|
|
|
|
$canSendMsg = $mailService->canSendMsg(self::MSG_KEY);
|
|
|
|
|
|
|
|
// Then
|
2018-02-19 00:18:43 +01:00
|
|
|
$this->assertSame(true, $canSendMsg);
|
2015-05-29 17:06:03 +02:00
|
|
|
}
|
|
|
|
|
2018-04-06 09:46:30 +02:00
|
|
|
public function test_should_not_send_2_mails_in_a_short_interval() {
|
2015-05-29 17:06:03 +02:00
|
|
|
// Given
|
|
|
|
$mailService = new MailService(true);
|
2015-05-29 17:41:50 +02:00
|
|
|
$_SESSION[MailService::MAILSERVICE_KEY] = [self::MSG_KEY => time()];
|
2015-05-29 17:06:03 +02:00
|
|
|
|
|
|
|
// When
|
|
|
|
$canSendMsg = $mailService->canSendMsg(self::MSG_KEY);
|
|
|
|
|
|
|
|
// Then
|
2018-02-19 00:18:43 +01:00
|
|
|
$this->assertSame(false, $canSendMsg);
|
2015-05-29 17:05:26 +02:00
|
|
|
}
|
|
|
|
}
|