From 2c3dfa8f5951e430de80ad91aae51e8e0acc23e6 Mon Sep 17 00:00:00 2001
From: Thomas Citharel <tcit@tcit.fr>
Date: Fri, 6 Apr 2018 09:46:30 +0200
Subject: [PATCH] Improve tests a bit

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
---
 app/tests/Framadate/FramaTestCase.php         |  4 ++-
 .../Services/InputServiceUnitTest.php         | 35 +++++++++----------
 .../Services/MailServiceUnitTest.php          | 10 ++----
 3 files changed, 22 insertions(+), 27 deletions(-)

diff --git a/app/tests/Framadate/FramaTestCase.php b/app/tests/Framadate/FramaTestCase.php
index eba5b695..6210a31d 100644
--- a/app/tests/Framadate/FramaTestCase.php
+++ b/app/tests/Framadate/FramaTestCase.php
@@ -1,7 +1,9 @@
 <?php
 namespace Framadate;
 
-abstract class FramaTestCase extends \PHPUnit_Framework_TestCase {
+use PHPUnit\Framework\TestCase;
+
+abstract class FramaTestCase extends TestCase {
     protected function getTestResourcePath($resourcepath) {
         return __DIR__ . '/../resources/' . $resourcepath;
     }
diff --git a/app/tests/Framadate/Services/InputServiceUnitTest.php b/app/tests/Framadate/Services/InputServiceUnitTest.php
index d4646c6d..88579511 100644
--- a/app/tests/Framadate/Services/InputServiceUnitTest.php
+++ b/app/tests/Framadate/Services/InputServiceUnitTest.php
@@ -5,29 +5,28 @@ use Framadate\FramaTestCase;
 
 class InputServiceUnitTest extends FramaTestCase
 {
+    public function liste_emails() {
+        return [
+            // valids addresses
+            "valid address" 		=> ["example@example.com", "example@example.com"],
+            "local address"			=> ["test@localhost", "test@localhost"],
+            "IP address"			=> ["ip.email@127.0.0.1", "ip.email@127.0.0.1"],
+            "with spaces arround" 	=> ["  with@spaces  ", "with@spaces"],
+            "unicode caracters" 	=> ["unicode.éà@idn-œ.com", "unicode.éà@idn-œ.com"],
+            // invalids addresses
+            "without domain" 		=> ["without-domain", FALSE],
+            "space inside" 			=> ["example example@example.com", FALSE],
+            "forbidden chars" 		=> ["special_chars.@example.com", FALSE],
+        ];
+    }
+
 	/**
-	 * @test
 	 * @dataProvider liste_emails
 	 */
-	function test_filterMail($email, $expected) {
+	public function test_filterMail($email, $expected) {
 		$inputService = new InputService();
 		$filtered = $inputService->filterMail($email);
-		
+
 		$this->assertSame($expected, $filtered);
 	}
-	
-	function liste_emails() {
-		return [
-			// valids addresses
-			"valid address" 		=> ["example@example.com", "example@example.com"],
-			"local address"			=> ["test@localhost", "test@localhost"],
-			"IP address"			=> ["ip.email@127.0.0.1", "ip.email@127.0.0.1"],
-			"with spaces arround" 	=> ["  with@spaces  ", "with@spaces"],
-			"unicode caracters" 	=> ["unicode.éà@idn-œ.com", "unicode.éà@idn-œ.com"],
-			// invalids addresses
-			"without domain" 		=> ["without-domain", FALSE],
-			"space inside" 			=> ["example example@example.com", FALSE],
-			"forbidden chars" 		=> ["special_chars.@example.com", FALSE],
-		];
-	}
 }
diff --git a/app/tests/Framadate/Services/MailServiceUnitTest.php b/app/tests/Framadate/Services/MailServiceUnitTest.php
index 0ffdb39c..f70e687c 100644
--- a/app/tests/Framadate/Services/MailServiceUnitTest.php
+++ b/app/tests/Framadate/Services/MailServiceUnitTest.php
@@ -6,10 +6,7 @@ use Framadate\FramaTestCase;
 class MailServiceUnitTest extends FramaTestCase {
     const MSG_KEY = '666';
 
-    /**
-     * @test
-     */
-    function should_send_a_2nd_mail_after_a_good_interval() {
+    public function test_should_send_a_2nd_mail_after_a_good_interval() {
         // Given
         $mailService = new MailService(true);
         $_SESSION[MailService::MAILSERVICE_KEY] = [self::MSG_KEY => time() - 1000];
@@ -21,10 +18,7 @@ class MailServiceUnitTest extends FramaTestCase {
         $this->assertSame(true, $canSendMsg);
     }
 
-    /**
-     * @test
-     */
-    function should_not_send_2_mails_in_a_short_interval() {
+    public function test_should_not_send_2_mails_in_a_short_interval() {
         // Given
         $mailService = new MailService(true);
         $_SESSION[MailService::MAILSERVICE_KEY] = [self::MSG_KEY => time()];
-- 
GitLab