date.chapril.org-framadate/app/tests/Framadate/Services/MailServiceUnitTest.php

40 lines
925 B
PHP
Raw Normal View History

2015-05-29 17:05:26 +02:00
<?php
namespace Framadate\Services;
use Framadate\FramaTestCase;
class MailServiceUnitTest extends FramaTestCase {
const MSG_KEY = '666';
2015-05-29 17:05:26 +02:00
/**
* @test
*/
function should_send_a_2nd_mail_after_a_good_interval() {
// Given
$mailService = new MailService(true);
$_SESSION[MailService::MAILSERVICE_KEY] = [self::MSG_KEY => time() - 500];
// When
$canSendMsg = $mailService->canSendMsg(self::MSG_KEY);
// Then
$this->assertEquals(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() + 500];
// When
$canSendMsg = $mailService->canSendMsg(self::MSG_KEY);
// Then
$this->assertEquals(false, $canSendMsg);
2015-05-29 17:05:26 +02:00
}
}