Skip to content

Commit f0a4a5c

Browse files
committed
making improvements on unit tests.
1 parent b9bd8f8 commit f0a4a5c

File tree

6 files changed

+126
-26
lines changed

6 files changed

+126
-26
lines changed

src/Pdp/Uri/Url.php

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,84 @@ public function toArray()
178178
'fragment' => $this->fragment,
179179
);
180180
}
181+
182+
/**
183+
* Get Scheme.
184+
*
185+
* @return string
186+
*/
187+
public function getScheme()
188+
{
189+
return $this->scheme;
190+
}
191+
192+
/**
193+
* Get User.
194+
*
195+
* @return string
196+
*/
197+
public function getUser()
198+
{
199+
return $this->user;
200+
}
201+
202+
/**
203+
* Get Pass.
204+
*
205+
* @return string
206+
*/
207+
public function getPass()
208+
{
209+
return $this->pass;
210+
}
211+
212+
/**
213+
* Get Host object.
214+
*
215+
* @return Host
216+
*/
217+
public function getHost()
218+
{
219+
return $this->host;
220+
}
221+
222+
/**
223+
* Get Port.
224+
*
225+
* @return int
226+
*/
227+
public function getPort()
228+
{
229+
return $this->port;
230+
}
231+
232+
/**
233+
* Get Path.
234+
*
235+
* @return string
236+
*/
237+
public function getPath()
238+
{
239+
return $this->path;
240+
}
241+
242+
/**
243+
* Get Query.
244+
*
245+
* @return string
246+
*/
247+
public function getQuery()
248+
{
249+
return $this->query;
250+
}
251+
252+
/**
253+
* Get Fragment.
254+
*
255+
* @return string
256+
*/
257+
public function getFragment()
258+
{
259+
return $this->fragment;
260+
}
181261
}

tests/src/Pdp/CheckPublicSuffixTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
*/
1212
class CheckPublicSuffixTest extends \PHPUnit_Framework_TestCase
1313
{
14+
/**
15+
* @var Parser
16+
*/
1417
protected $parser;
1518

1619
protected function setUp()

tests/src/Pdp/ParserTest.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
class ParserTest extends \PHPUnit_Framework_TestCase
66
{
7+
/**
8+
* @var Parser
9+
*/
710
protected $parser;
811

912
protected function setUp()
@@ -73,7 +76,7 @@ public function testParseUrl($url, $publicSuffix, $registerableDomain, $subdomai
7376
public function testParseHost($url, $publicSuffix, $registerableDomain, $subdomain, $hostPart)
7477
{
7578
$pdpUrl = $this->parser->parseUrl($url);
76-
$this->assertEquals($hostPart, $pdpUrl->host);
79+
$this->assertEquals($hostPart, $pdpUrl->getHost());
7780

7881
$pdpHost = $this->parser->parseHost($hostPart);
7982
$this->assertInstanceOf('\Pdp\Uri\Url\Host', $pdpHost);
@@ -88,7 +91,7 @@ public function testParseHost($url, $publicSuffix, $registerableDomain, $subdoma
8891
public function testGetPublicSuffix($url, $publicSuffix, $registerableDomain, $subdomain, $hostPart)
8992
{
9093
$pdpUrl = $this->parser->parseUrl($url);
91-
$this->assertSame($publicSuffix, $pdpUrl->host->publicSuffix);
94+
$this->assertSame($publicSuffix, $pdpUrl->getHost()->getPublicSuffix());
9295
$this->assertSame($publicSuffix, $this->parser->getPublicSuffix($hostPart));
9396
}
9497

@@ -111,7 +114,7 @@ public function testGetPublicSuffixHandlesWrongCaseProperly()
111114
public function testGetRegisterableDomain($url, $publicSuffix, $registerableDomain, $subdomain, $hostPart)
112115
{
113116
$pdpUrl = $this->parser->parseUrl($url);
114-
$this->assertSame($registerableDomain, $pdpUrl->host->registerableDomain);
117+
$this->assertSame($registerableDomain, $pdpUrl->getHost()->getRegisterableDomain());
115118
$this->assertSame($registerableDomain, $this->parser->getRegisterableDomain($hostPart));
116119
}
117120

@@ -123,7 +126,7 @@ public function testGetRegisterableDomain($url, $publicSuffix, $registerableDoma
123126
public function testGetSubdomain($url, $publicSuffix, $registerableDomain, $subdomain, $hostPart)
124127
{
125128
$pdpUrl = $this->parser->parseUrl($url);
126-
$this->assertSame($subdomain, $pdpUrl->host->subdomain);
129+
$this->assertSame($subdomain, $pdpUrl->getHost()->getSubdomain());
127130
$this->assertSame($subdomain, $this->parser->getSubdomain($hostPart));
128131
}
129132

@@ -137,7 +140,7 @@ public function testGetSubdomainHandlesWrongCaseProperly()
137140
$subdomain = 'www';
138141
$pdpUrl = $this->parser->parseUrl($url);
139142

140-
$this->assertSame($subdomain, $pdpUrl->host->subdomain);
143+
$this->assertSame($subdomain, $pdpUrl->getHost()->getSubdomain());
141144
$this->assertSame($subdomain, $this->parser->getSubdomain($hostPart));
142145
}
143146

tests/src/Pdp/PublicSuffixListManagerTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Pdp;
44

55
use org\bovigo\vfs\vfsStream;
6+
use org\bovigo\vfs\vfsStreamDirectory;
67

78
class PublicSuffixListManagerTest extends \PHPUnit_Framework_TestCase
89
{
@@ -180,6 +181,7 @@ public function testGetListWithoutCache()
180181
$this->cacheDir . '/' . PublicSuffixListManager::PDP_PSL_PHP_FILE
181182
);
182183

184+
/** @var PublicSuffixListManager $listManager */
183185
$listManager = $this->getMock(
184186
'\Pdp\PublicSuffixListManager',
185187
array('refreshPublicSuffixList'),

tests/src/Pdp/Uri/Url/HostTest.php

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44

55
class HostTest extends \PHPUnit_Framework_TestCase
66
{
7-
/**
8-
* @dataProvider hostDataProvider
9-
*/
7+
/**
8+
* @param $publicSuffix
9+
* @param $registerableDomain
10+
* @param $subdomain
11+
* @param $hostPart
12+
*/
1013
public function test__toString($publicSuffix, $registerableDomain, $subdomain, $hostPart)
1114
{
1215
$host = new Host(
@@ -30,9 +33,12 @@ public function test__toStringWhenHostPartIsNull()
3033
$this->assertEquals('www.example.com', $host->__toString());
3134
}
3235

33-
/**
34-
* @dataProvider hostDataProvider
35-
*/
36+
/**
37+
* @param $publicSuffix
38+
* @param $registerableDomain
39+
* @param $subdomain
40+
* @param $hostPart
41+
*/
3642
public function test__get($publicSuffix, $registerableDomain, $subdomain, $hostPart)
3743
{
3844
$parts = array(
@@ -49,15 +55,18 @@ public function test__get($publicSuffix, $registerableDomain, $subdomain, $hostP
4955
$parts['host']
5056
);
5157

52-
$this->assertSame($hostPart, $host->host);
53-
$this->assertSame($parts['subdomain'], $host->subdomain);
54-
$this->assertEquals($parts['registerableDomain'], $host->registerableDomain);
55-
$this->assertEquals($parts['publicSuffix'], $host->publicSuffix);
58+
$this->assertSame($hostPart, $host->getHost());
59+
$this->assertSame($parts['subdomain'], $host->getSubdomain());
60+
$this->assertEquals($parts['registerableDomain'], $host->getRegisterableDomain());
61+
$this->assertEquals($parts['publicSuffix'], $host->getPublicSuffix());
5662
}
5763

58-
/**
59-
* @dataProvider hostDataProvider
60-
*/
64+
/**
65+
* @param $publicSuffix
66+
* @param $registerableDomain
67+
* @param $subdomain
68+
* @param $hostPart
69+
*/
6170
public function testToArray($publicSuffix, $registerableDomain, $subdomain, $hostPart)
6271
{
6372
$parts = array(
@@ -77,6 +86,9 @@ public function testToArray($publicSuffix, $registerableDomain, $subdomain, $hos
7786
$this->assertEquals($parts, $host->toArray());
7887
}
7988

89+
/**
90+
* @return array
91+
*/
8092
public function hostDataProvider()
8193
{
8294
// $publicSuffix, $registerableDomain, $subdomain, $hostPart

tests/src/Pdp/Uri/UrlTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ public function test__getProperties()
8787
'fragment' => 'anchor',
8888
);
8989

90-
$this->assertEquals($expected['scheme'], $this->url->scheme);
91-
$this->assertEquals($expected['user'], $this->url->user);
92-
$this->assertEquals($expected['pass'], $this->url->pass);
93-
$this->assertEquals($expected['host'], $this->url->host->__toString());
94-
$this->assertEquals($expected['port'], $this->url->port);
95-
$this->assertEquals($expected['path'], $this->url->path);
96-
$this->assertEquals($expected['query'], $this->url->query);
97-
$this->assertEquals($expected['fragment'], $this->url->fragment);
90+
$this->assertEquals($expected['scheme'], $this->url->getScheme());
91+
$this->assertEquals($expected['user'], $this->url->getUser());
92+
$this->assertEquals($expected['pass'], $this->url->getPass());
93+
$this->assertEquals($expected['host'], $this->url->getHost()->__toString());
94+
$this->assertEquals($expected['port'], $this->url->getPort());
95+
$this->assertEquals($expected['path'], $this->url->getPath());
96+
$this->assertEquals($expected['query'], $this->url->getQuery());
97+
$this->assertEquals($expected['fragment'], $this->url->getFragment());
9898
}
9999

100100
public function testToArray()

0 commit comments

Comments
 (0)