Improve tests a bit
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
37df499a37
commit
2c3dfa8f59
|
@ -1,7 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
namespace Framadate;
|
namespace Framadate;
|
||||||
|
|
||||||
abstract class FramaTestCase extends \PHPUnit_Framework_TestCase {
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
abstract class FramaTestCase extends TestCase {
|
||||||
protected function getTestResourcePath($resourcepath) {
|
protected function getTestResourcePath($resourcepath) {
|
||||||
return __DIR__ . '/../resources/' . $resourcepath;
|
return __DIR__ . '/../resources/' . $resourcepath;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,18 +5,7 @@ use Framadate\FramaTestCase;
|
||||||
|
|
||||||
class InputServiceUnitTest extends FramaTestCase
|
class InputServiceUnitTest extends FramaTestCase
|
||||||
{
|
{
|
||||||
/**
|
public function liste_emails() {
|
||||||
* @test
|
|
||||||
* @dataProvider liste_emails
|
|
||||||
*/
|
|
||||||
function test_filterMail($email, $expected) {
|
|
||||||
$inputService = new InputService();
|
|
||||||
$filtered = $inputService->filterMail($email);
|
|
||||||
|
|
||||||
$this->assertSame($expected, $filtered);
|
|
||||||
}
|
|
||||||
|
|
||||||
function liste_emails() {
|
|
||||||
return [
|
return [
|
||||||
// valids addresses
|
// valids addresses
|
||||||
"valid address" => ["example@example.com", "example@example.com"],
|
"valid address" => ["example@example.com", "example@example.com"],
|
||||||
|
@ -30,4 +19,14 @@ class InputServiceUnitTest extends FramaTestCase
|
||||||
"forbidden chars" => ["special_chars.@example.com", FALSE],
|
"forbidden chars" => ["special_chars.@example.com", FALSE],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider liste_emails
|
||||||
|
*/
|
||||||
|
public function test_filterMail($email, $expected) {
|
||||||
|
$inputService = new InputService();
|
||||||
|
$filtered = $inputService->filterMail($email);
|
||||||
|
|
||||||
|
$this->assertSame($expected, $filtered);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,10 +6,7 @@ use Framadate\FramaTestCase;
|
||||||
class MailServiceUnitTest extends FramaTestCase {
|
class MailServiceUnitTest extends FramaTestCase {
|
||||||
const MSG_KEY = '666';
|
const MSG_KEY = '666';
|
||||||
|
|
||||||
/**
|
public function test_should_send_a_2nd_mail_after_a_good_interval() {
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
function should_send_a_2nd_mail_after_a_good_interval() {
|
|
||||||
// Given
|
// Given
|
||||||
$mailService = new MailService(true);
|
$mailService = new MailService(true);
|
||||||
$_SESSION[MailService::MAILSERVICE_KEY] = [self::MSG_KEY => time() - 1000];
|
$_SESSION[MailService::MAILSERVICE_KEY] = [self::MSG_KEY => time() - 1000];
|
||||||
|
@ -21,10 +18,7 @@ class MailServiceUnitTest extends FramaTestCase {
|
||||||
$this->assertSame(true, $canSendMsg);
|
$this->assertSame(true, $canSendMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function test_should_not_send_2_mails_in_a_short_interval() {
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
function should_not_send_2_mails_in_a_short_interval() {
|
|
||||||
// Given
|
// Given
|
||||||
$mailService = new MailService(true);
|
$mailService = new MailService(true);
|
||||||
$_SESSION[MailService::MAILSERVICE_KEY] = [self::MSG_KEY => time()];
|
$_SESSION[MailService::MAILSERVICE_KEY] = [self::MSG_KEY => time()];
|
||||||
|
|
Loading…
Reference in New Issue
Block a user