Skip to content

Commit 602f10a

Browse files
author
Piotr Jura
committed
Simple unit tests for e-mail and date. The validation is done by PHP internals anyway, so basic checks should do.
1 parent 6140007 commit 602f10a

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace Coduo\PHPMatcher\Tests\Matcher\Pattern\Expander;
4+
5+
use Coduo\PHPMatcher\Matcher;
6+
use Coduo\PHPMatcher\Matcher\Pattern\Expander\IsDateTime;
7+
8+
class IsDateTimeTest extends \PHPUnit_Framework_TestCase
9+
{
10+
/**
11+
* @dataProvider examplesDatesProvider
12+
*/
13+
public function test_dates($date, $expectedResult)
14+
{
15+
$expander = new IsDateTime();
16+
$this->assertEquals($expectedResult, $expander->match($date));
17+
}
18+
19+
public static function examplesDatesProvider()
20+
{
21+
return array(
22+
array("201-20-44", false),
23+
array("2012-10-11", true),
24+
array("invalid", false),
25+
array("Monday, 15-Aug-2005 15:52:01 UTC", true)
26+
);
27+
}
28+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace Coduo\PHPMatcher\Tests\Matcher\Pattern\Expander;
4+
5+
use Coduo\PHPMatcher\Matcher;
6+
use Coduo\PHPMatcher\Matcher\Pattern\Expander\IsEmail;
7+
8+
class IsEmailTest extends \PHPUnit_Framework_TestCase
9+
{
10+
/**
11+
* @dataProvider examplesEmailsProvider
12+
*/
13+
public function test_emails($email, $expectedResult)
14+
{
15+
$expander = new IsEmail();
16+
$this->assertEquals($expectedResult, $expander->match($email));
17+
}
18+
19+
public static function examplesEmailsProvider()
20+
{
21+
return array(
22+
array("[email protected]", true),
23+
array("[email protected]", true),
24+
array("[email protected]", false),
25+
array("2222----###@domain.co", true)
26+
);
27+
}
28+
}

0 commit comments

Comments
 (0)