date.chapril.org-framadate/app/tests/Framadate/Services/MailServiceUnitTest.php
Thomas Citharel 3157d6a590 Run php-cs-fixer with a custom config. This may break a lot of things
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2018-02-19 19:43:30 +01:00

39 lines
915 B
PHP

<?php
namespace Framadate\Services;
use Framadate\FramaTestCase;
class MailServiceUnitTest extends FramaTestCase {
const MSG_KEY = '666';
/**
* @test
*/
function should_send_a_2nd_mail_after_a_good_interval() {
// Given
$mailService = new MailService(true);
$_SESSION[MailService::MAILSERVICE_KEY] = [self::MSG_KEY => time() - 1000];
// When
$canSendMsg = $mailService->canSendMsg(self::MSG_KEY);
// Then
$this->assertSame(true, $canSendMsg);
}
/**
* @test
*/
function should_not_send_2_mails_in_a_short_interval() {
// Given
$mailService = new MailService(true);
$_SESSION[MailService::MAILSERVICE_KEY] = [self::MSG_KEY => time()];
// When
$canSendMsg = $mailService->canSendMsg(self::MSG_KEY);
// Then
$this->assertSame(false, $canSendMsg);
}
}