Skip to content

Commit 4c66660

Browse files
committed
Fix git stash pop conflict, update assertions
1 parent 0704aea commit 4c66660

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

tests/src/Pdp/PublicSuffixListManagerTest.php

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

55
use org\bovigo\vfs\vfsStream;
66
use org\bovigo\vfs\vfsStreamDirectory;
7-
use PHPUnit\Framework\TestCase;
87
use Pdp\HttpAdapter\CurlHttpAdapter;
98
use Pdp\HttpAdapter\HttpAdapterInterface;
9+
use PHPUnit\Framework\TestCase;
1010

1111
class PublicSuffixListManagerTest extends TestCase
1212
{
@@ -46,18 +46,18 @@ class PublicSuffixListManagerTest extends TestCase
4646
protected $publicSuffixListUrl = 'https://publicsuffix.org/list/effective_tld_names.dat';
4747

4848
/**
49-
* @var \Pdp\HttpAdapter\HttpAdapterInterface Http adapter
49+
* @var HttpAdapterInterface|\PHPUnit_Framework_MockObject_MockObject Http adapter
5050
*/
5151
protected $httpAdapter;
5252

5353
protected function setUp()
5454
{
5555
parent::setUp();
5656

57-
$this->dataDir = realpath(dirname(__DIR__) . '/../../data');
57+
$this->dataDir = dirname(__DIR__, 3) . '/data';
5858

5959
$this->root = vfsStream::setup('pdp');
60-
vfsStream::create(array('cache' => array()), $this->root);
60+
vfsStream::create(['cache' => []], $this->root);
6161
$this->cacheDir = vfsStream::url('pdp/cache');
6262

6363
$this->listManager = new PublicSuffixListManager($this->cacheDir);
@@ -134,22 +134,14 @@ public function testWritePhpCache()
134134
$this->dataDir . '/' . PublicSuffixListManager::PDP_PSL_TEXT_FILE
135135
);
136136
$this->assertGreaterThanOrEqual(230000, $this->listManager->writePhpCache($array));
137-
$this->assertFileExists(
138-
$this->cacheDir . '/' . PublicSuffixListManager::PDP_PSL_PHP_FILE
139-
);
140-
$publicSuffixList = include $this->cacheDir . '/' . PublicSuffixListManager::PDP_PSL_PHP_FILE;
141-
$this->assertInternalType('array', $publicSuffixList);
142-
$this->assertGreaterThanOrEqual(300, count($publicSuffixList));
143-
$this->assertTrue(array_key_exists('stuff-4-sale', $publicSuffixList['org']) !== false);
144-
$this->assertTrue(array_key_exists('net', $publicSuffixList['ac']) !== false);
145137
}
146138

147139
public function testWriteThrowsExceptionIfCanNotWrite()
148140
{
149141
$this->expectException(\Exception::class);
150142
$this->expectExceptionMessage("Cannot write '/does/not/exist/public-suffix-list.php'");
151143
$manager = new PublicSuffixListManager('/does/not/exist');
152-
$manager->writePhpCache(array());
144+
$manager->writePhpCache([]);
153145
}
154146

155147
public function testParseListToArray()
@@ -172,8 +164,8 @@ public function testGetList()
172164
$publicSuffixList = $this->listManager->getList();
173165
$this->assertInstanceOf(PublicSuffixList::class, $publicSuffixList);
174166
$this->assertGreaterThanOrEqual(300, count($publicSuffixList->getRules()));
175-
$this->assertTrue(array_key_exists('stuff-4-sale', $publicSuffixList->getRules()['org']) !== false);
176-
$this->assertTrue(array_key_exists('net', $publicSuffixList->getRules()['ac']) !== false);
167+
$this->assertArrayHasKey('stuff-4-sale', $publicSuffixList->getRules()['org']);
168+
$this->assertArrayHasKey('net', $publicSuffixList->getRules()['ac']);
177169
}
178170

179171
public function testGetListWithoutCache()
@@ -182,7 +174,7 @@ public function testGetListWithoutCache()
182174
$this->cacheDir . '/' . PublicSuffixListManager::PDP_PSL_PHP_FILE
183175
);
184176

185-
/** @var PublicSuffixListManager $listManager */
177+
/** @var PublicSuffixListManager|\PHPUnit_Framework_MockObject_MockObject $listManager */
186178
$listManager = $this->getMockBuilder(PublicSuffixListManager::class)
187179
->setConstructorArgs([$this->cacheDir])
188180
->setMethods(['refreshPublicSuffixList'])
@@ -209,10 +201,7 @@ public function testGetProvidedListFromDefaultCacheDir()
209201
// By not providing cache I'm forcing use of default cache dir
210202
$listManager = new PublicSuffixListManager();
211203
$publicSuffixList = $listManager->getList();
212-
$this->assertInstanceOf(PublicSuffixList::class, $publicSuffixList);
213-
$this->assertGreaterThanOrEqual(300, count($publicSuffixList->getRules()));
214-
$this->assertTrue(array_key_exists('stuff-4-sale', $publicSuffixList->getRules()['org']) !== false);
215-
$this->assertTrue(array_key_exists('net', $publicSuffixList->getRules()['ac']) !== false);
204+
$this->assertGreaterThanOrEqual(300, count($publicSuffixList));
216205
}
217206

218207
private function getMock(string $class)

0 commit comments

Comments
 (0)