File tree Expand file tree Collapse file tree 5 files changed +21
-14
lines changed Expand file tree Collapse file tree 5 files changed +21
-14
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ class PublicSuffixListManager
36
36
private $ sourceUrl ;
37
37
38
38
/**
39
- * @var string Directory where text and php versions of list will be cached
39
+ * @var CacheInterface PSR-16 cache adapter
40
40
*/
41
41
private $ cacheAdapter ;
42
42
Original file line number Diff line number Diff line change 23
23
*/
24
24
class FileCacheAdapterTest extends TestCase
25
25
{
26
- private $ cache ;
26
+ protected $ cache ;
27
27
28
- private $ root ;
28
+ protected $ root ;
29
29
30
- private $ cacheDir ;
30
+ protected $ cacheDir ;
31
31
32
32
public function setUp ()
33
33
{
Original file line number Diff line number Diff line change 3
3
namespace Pdp \Tests ;
4
4
5
5
use Pdp \Cache \FileCacheAdapter ;
6
+ use Pdp \Http \CurlHttpAdapter ;
6
7
use Pdp \PublicSuffixList ;
7
8
use Pdp \PublicSuffixListManager ;
8
9
use PHPUnit \Framework \TestCase ;
@@ -21,11 +22,10 @@ class CheckPublicSuffixTest extends TestCase
21
22
*/
22
23
private $ list ;
23
24
24
- protected function setUp ()
25
+ public function setUp ()
25
26
{
26
- $ cache = new FileCacheAdapter ();
27
- $ rules = $ cache ->get (PublicSuffixListManager::ALL_DOMAINS );
28
- $ this ->list = new PublicSuffixList ($ rules );
27
+ $ manager = new PublicSuffixListManager (new FileCacheAdapter (), new CurlHttpAdapter ());
28
+ $ this ->list = $ manager ->getList ();
29
29
}
30
30
31
31
/**
Original file line number Diff line number Diff line change 4
4
5
5
namespace Pdp \Tests ;
6
6
7
+ use org \bovigo \vfs \vfsStream ;
7
8
use Pdp \Cache \FileCacheAdapter ;
8
9
use Pdp \Http \CurlHttpAdapter ;
9
10
use Pdp \PublicSuffixListManager ;
@@ -15,24 +16,30 @@ class PublicSuffixListManagerTest extends TestCase
15
16
* @var PublicSuffixListManager List manager
16
17
*/
17
18
protected $ manager ;
18
-
19
+ protected $ cache ;
20
+ protected $ root ;
21
+ protected $ cacheDir ;
19
22
protected $ cachePool ;
20
23
21
- protected function setUp ()
24
+ public function setUp ()
22
25
{
23
- $ this ->cachePool = new FileCacheAdapter ('/tmp/test-my-cache ' );
24
-
26
+ $ this ->root = vfsStream::setup ('pdp ' );
27
+ vfsStream::create (['cache ' => []], $ this ->root );
28
+ $ this ->cacheDir = vfsStream::url ('pdp/cache ' );
29
+ $ this ->cachePool = new FileCacheAdapter ($ this ->cacheDir );
25
30
$ this ->manager = new PublicSuffixListManager (
26
31
$ this ->cachePool ,
27
32
new CurlHttpAdapter (),
28
33
'https://publicsuffix.org/list/public_suffix_list.dat '
29
34
);
30
35
}
31
36
32
- protected function tearDown ()
37
+ public function tearDown ()
33
38
{
34
39
$ this ->manager = null ;
35
40
$ this ->cachePool = null ;
41
+ $ this ->cacheDir = null ;
42
+ $ this ->root = null ;
36
43
}
37
44
38
45
public function testGetProvidedListFromDefaultCacheDir ()
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ class PublicSuffixListTest extends TestCase
27
27
*/
28
28
private $ list ;
29
29
30
- protected function setUp ()
30
+ public function setUp ()
31
31
{
32
32
$ cache = new FileCacheAdapter ();
33
33
$ rules = $ cache ->get (PublicSuffixListManager::ALL_DOMAINS );
You can’t perform that action at this time.
0 commit comments