@@ -74,25 +74,37 @@ protected function tearDown()
74
74
75
75
public function testRefreshPublicSuffixList ()
76
76
{
77
- $ content = file_get_contents ($ this ->dataDir . '/ ' . PublicSuffixListManager::PDP_PSL_TEXT_FILE );
77
+ $ content = file_get_contents (
78
+ $ this ->dataDir . '/ ' . PublicSuffixListManager::PDP_PSL_TEXT_FILE
79
+ );
78
80
79
81
$ this ->httpAdapter ->expects ($ this ->once ())
80
82
->method ('getContent ' )
81
83
->with ($ this ->publicSuffixListUrl )
82
84
->will ($ this ->returnValue ($ content ));
83
85
84
- $ this ->assertFalse (file_exists ($ this ->cacheDir . '/ ' . PublicSuffixListManager::PDP_PSL_TEXT_FILE ));
85
- $ this ->assertFalse (file_exists ($ this ->cacheDir . '/ ' . PublicSuffixListManager::PDP_PSL_PHP_FILE ));
86
+ $ this ->assertFileNotExists (
87
+ $ this ->cacheDir . '/ ' . PublicSuffixListManager::PDP_PSL_TEXT_FILE
88
+ );
89
+ $ this ->assertFileNotExists (
90
+ $ this ->cacheDir . '/ ' . PublicSuffixListManager::PDP_PSL_PHP_FILE
91
+ );
86
92
87
93
$ this ->listManager ->refreshPublicSuffixList ();
88
94
89
- $ this ->assertFileExists ($ this ->cacheDir . '/ ' . PublicSuffixListManager::PDP_PSL_TEXT_FILE );
90
- $ this ->assertFileExists ($ this ->cacheDir . '/ ' . PublicSuffixListManager::PDP_PSL_PHP_FILE );
95
+ $ this ->assertFileExists (
96
+ $ this ->cacheDir . '/ ' . PublicSuffixListManager::PDP_PSL_TEXT_FILE
97
+ );
98
+ $ this ->assertFileExists (
99
+ $ this ->cacheDir . '/ ' . PublicSuffixListManager::PDP_PSL_PHP_FILE
100
+ );
91
101
}
92
102
93
103
public function testFetchListFromSource ()
94
104
{
95
- $ content = file_get_contents ($ this ->dataDir . '/ ' . PublicSuffixListManager::PDP_PSL_TEXT_FILE );
105
+ $ content = file_get_contents (
106
+ $ this ->dataDir . '/ ' . PublicSuffixListManager::PDP_PSL_TEXT_FILE
107
+ );
96
108
97
109
$ this ->httpAdapter ->expects ($ this ->once ())
98
110
->method ('getContent ' )
@@ -106,17 +118,24 @@ public function testFetchListFromSource()
106
118
public function testGetHttpAdapterReturnsDefaultCurlAdapterIfAdapterNotSet ()
107
119
{
108
120
$ listManager = new PublicSuffixListManager ($ this ->cacheDir );
109
- $ this ->assertInstanceOf ('\Pdp\HttpAdapter\CurlHttpAdapter ' , $ listManager ->getHttpAdapter ());
121
+ $ this ->assertInstanceOf (
122
+ '\Pdp\HttpAdapter\CurlHttpAdapter ' ,
123
+ $ listManager ->getHttpAdapter ()
124
+ );
110
125
}
111
126
112
127
public function testWritePhpCache ()
113
128
{
114
- $ this ->assertFalse (file_exists ($ this ->cacheDir . '/ ' . PublicSuffixListManager::PDP_PSL_PHP_FILE ));
129
+ $ this ->assertFileNotExists (
130
+ $ this ->cacheDir . '/ ' . PublicSuffixListManager::PDP_PSL_PHP_FILE
131
+ );
115
132
$ array = $ this ->listManager ->parseListToArray (
116
133
$ this ->dataDir . '/ ' . PublicSuffixListManager::PDP_PSL_TEXT_FILE
117
134
);
118
135
$ this ->assertGreaterThanOrEqual (230000 , $ this ->listManager ->writePhpCache ($ array ));
119
- $ this ->assertFileExists ($ this ->cacheDir . '/ ' . PublicSuffixListManager::PDP_PSL_PHP_FILE );
136
+ $ this ->assertFileExists (
137
+ $ this ->cacheDir . '/ ' . PublicSuffixListManager::PDP_PSL_PHP_FILE
138
+ );
120
139
$ publicSuffixList = include $ this ->cacheDir . '/ ' . PublicSuffixListManager::PDP_PSL_PHP_FILE ;
121
140
$ this ->assertInternalType ('array ' , $ publicSuffixList );
122
141
$ this ->assertGreaterThanOrEqual (300 , count ($ publicSuffixList ));
@@ -145,7 +164,9 @@ public function testGetList()
145
164
$ this ->dataDir . '/ ' . PublicSuffixListManager::PDP_PSL_PHP_FILE ,
146
165
$ this ->cacheDir . '/ ' . PublicSuffixListManager::PDP_PSL_PHP_FILE
147
166
);
148
- $ this ->assertFileExists ($ this ->cacheDir . '/ ' . PublicSuffixListManager::PDP_PSL_PHP_FILE );
167
+ $ this ->assertFileExists (
168
+ $ this ->cacheDir . '/ ' . PublicSuffixListManager::PDP_PSL_PHP_FILE
169
+ );
149
170
$ publicSuffixList = $ this ->listManager ->getList ();
150
171
$ this ->assertInstanceOf ('\Pdp\PublicSuffixList ' , $ publicSuffixList );
151
172
$ this ->assertGreaterThanOrEqual (300 , count ($ publicSuffixList ));
@@ -155,10 +176,15 @@ public function testGetList()
155
176
156
177
public function testGetListWithoutCache ()
157
178
{
158
- unlink ($ this ->cacheDir . '/ ' . PublicSuffixListManager::PDP_PSL_PHP_FILE );
159
- $ this ->assertFileNotExists ($ this ->cacheDir . '/ ' . PublicSuffixListManager::PDP_PSL_PHP_FILE );
179
+ $ this ->assertFileNotExists (
180
+ $ this ->cacheDir . '/ ' . PublicSuffixListManager::PDP_PSL_PHP_FILE
181
+ );
160
182
161
- $ listManager = $ this ->getMock ('\Pdp\PublicSuffixListManager ' , array ('refreshPublicSuffixList ' ), array ($ this ->cacheDir ));
183
+ $ listManager = $ this ->getMock (
184
+ '\Pdp\PublicSuffixListManager ' ,
185
+ array ('refreshPublicSuffixList ' ),
186
+ array ($ this ->cacheDir )
187
+ );
162
188
163
189
$ dataDir = $ this ->dataDir ;
164
190
$ cacheDir = $ this ->cacheDir ;
@@ -172,7 +198,8 @@ public function testGetListWithoutCache()
172
198
);
173
199
}));
174
200
175
- $ listManager ->getList ();
201
+ $ publicSuffixList = $ listManager ->getList ();
202
+ $ this ->assertInstanceOf ('\Pdp\PublicSuffixList ' , $ publicSuffixList );
176
203
}
177
204
178
205
public function testGetProvidedListFromDefaultCacheDir ()
0 commit comments