Skip to content

Commit 0a75cff

Browse files
committed
improve test suite
1 parent dbc6136 commit 0a75cff

File tree

5 files changed

+21
-14
lines changed

5 files changed

+21
-14
lines changed

src/PublicSuffixListManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class PublicSuffixListManager
3636
private $sourceUrl;
3737

3838
/**
39-
* @var string Directory where text and php versions of list will be cached
39+
* @var CacheInterface PSR-16 cache adapter
4040
*/
4141
private $cacheAdapter;
4242

tests/Cache/FileCacheAdapterTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
*/
2424
class FileCacheAdapterTest extends TestCase
2525
{
26-
private $cache;
26+
protected $cache;
2727

28-
private $root;
28+
protected $root;
2929

30-
private $cacheDir;
30+
protected $cacheDir;
3131

3232
public function setUp()
3333
{

tests/CheckPublicSuffixTest.php

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

55
use Pdp\Cache\FileCacheAdapter;
6+
use Pdp\Http\CurlHttpAdapter;
67
use Pdp\PublicSuffixList;
78
use Pdp\PublicSuffixListManager;
89
use PHPUnit\Framework\TestCase;
@@ -21,11 +22,10 @@ class CheckPublicSuffixTest extends TestCase
2122
*/
2223
private $list;
2324

24-
protected function setUp()
25+
public function setUp()
2526
{
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();
2929
}
3030

3131
/**

tests/PublicSuffixListManagerTest.php

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

55
namespace Pdp\Tests;
66

7+
use org\bovigo\vfs\vfsStream;
78
use Pdp\Cache\FileCacheAdapter;
89
use Pdp\Http\CurlHttpAdapter;
910
use Pdp\PublicSuffixListManager;
@@ -15,24 +16,30 @@ class PublicSuffixListManagerTest extends TestCase
1516
* @var PublicSuffixListManager List manager
1617
*/
1718
protected $manager;
18-
19+
protected $cache;
20+
protected $root;
21+
protected $cacheDir;
1922
protected $cachePool;
2023

21-
protected function setUp()
24+
public function setUp()
2225
{
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);
2530
$this->manager = new PublicSuffixListManager(
2631
$this->cachePool,
2732
new CurlHttpAdapter(),
2833
'https://publicsuffix.org/list/public_suffix_list.dat'
2934
);
3035
}
3136

32-
protected function tearDown()
37+
public function tearDown()
3338
{
3439
$this->manager = null;
3540
$this->cachePool = null;
41+
$this->cacheDir = null;
42+
$this->root = null;
3643
}
3744

3845
public function testGetProvidedListFromDefaultCacheDir()

tests/PublicSuffixListTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class PublicSuffixListTest extends TestCase
2727
*/
2828
private $list;
2929

30-
protected function setUp()
30+
public function setUp()
3131
{
3232
$cache = new FileCacheAdapter();
3333
$rules = $cache->get(PublicSuffixListManager::ALL_DOMAINS);

0 commit comments

Comments
 (0)