| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
namespace MediaWiki\SecureLinkFixer\Test; |
| 20 |
|
| 21 |
use MediaWiki\SecureLinkFixer\ListFetcher; |
| 22 |
use MediaWikiIntegrationTestCase; |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
class DomainsTest extends MediaWikiIntegrationTestCase { |
| 29 |
|
| 30 |
public function testReproducibility() { |
| 31 |
$domains = file_get_contents( __DIR__ . '/../../domains.php' ); |
| 32 |
preg_match( '/mozilla-firefox\/firefox@([0-9a-f]*?) \((.*?)\)/', $domains, $matches ); |
| 33 |
$this->assertCount( 3, $matches ); |
| 34 |
[ , $rev, $date ] = $matches; |
| 35 |
$lf = new ListFetcher(); |
| 36 |
$expected = $lf->fetchList( $rev, $date ); |
| 37 |
$this->assertSame( $expected, $domains ); |
| 38 |
} |
| 39 |
|
| 40 |
public function testDomains() { |
| 41 |
$domains = require __DIR__ . '/../../domains.php'; |
| 42 |
$this->assertIsArray( $domains ); |
| 43 |
|
| 44 |
$this->assertGreaterThan( 50000, count( $domains ) ); |
| 45 |
foreach ( $domains as $domain => $subdomain ) { |
| 46 |
$this->assertMatchesRegularExpression( '/^[A-z0-9\-\.]*$/', $domain ); |
| 47 |
$this->assertTrue( $subdomain === 0 || $subdomain === 1 ); |
| 48 |
} |
| 49 |
} |
| 50 |
} |