Skip to content

Commit a816a53

Browse files
committed
linting and added more tests
1 parent ed7aa2b commit a816a53

File tree

1 file changed

+45
-13
lines changed

1 file changed

+45
-13
lines changed

tests/VerbalExpressions/PHPVerbalExpressions/VerbalExpressionsTest.php

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,61 @@
44

55
class VerbalExpressionsTest extends \PHPUnit_Framework_TestCase
66
{
7+
/**
8+
* @dataProvider provideValidUrls
9+
* @group functional
10+
*/
11+
public function testShouldPassWhenValidUrlGiven($url)
12+
{
13+
$regex = new VerbalExpressions();
14+
$this->buildUrlPattern($regex);
15+
16+
$this->assertTrue($regex->test($url));
17+
}
18+
19+
static public function provideValidUrls()
20+
{
21+
return array(
22+
array('http://github.com'),
23+
array('http://www.github.com'),
24+
array('https://github.com'),
25+
array('https://github.com'),
26+
array('https://github.com/blog'),
27+
array('https://foobar.github.com')
28+
);
29+
}
730

831
/**
9-
* @dataProvider provideUrls
32+
* @dataProvider provideInvalidUrls
33+
* @group functional
1034
*/
11-
public function testUrlPatterns($url)
35+
public function testShouldFailWithInvalidUrls($url)
1236
{
1337
$regex = new VerbalExpressions();
38+
$this->buildUrlPattern($regex);
39+
40+
$this->assertFalse($regex->test($url));
41+
}
1442

15-
$regex->startOfLine()
43+
static public function provideInvalidUrls()
44+
{
45+
return array(
46+
array(' http://github.com'),
47+
array('foo'),
48+
array('htps://github.com'),
49+
array('http:/github.com'),
50+
array('https://github.com /blog'),
51+
);
52+
}
53+
54+
protected function buildUrlPattern(VerbalExpressions $regex)
55+
{
56+
return $regex->startOfLine()
1657
->then("http")
1758
->maybe("s")
1859
->then("://")
1960
->maybe("www.")
2061
->anythingBut(" ")
2162
->endOfLine();
22-
23-
$this->assertTrue($regex->test($url));
24-
}
25-
26-
static public function provideUrls()
27-
{
28-
return array(
29-
array('http://github.com')
30-
);
3163
}
32-
}
64+
}

0 commit comments

Comments
 (0)