Debian Codegraph @

extensions/SecureLinkFixer/tests/phpunit/DomainsTest.php

raw symbols SCIP
1 <?php
2 /**
3 * Copyright (C) 2019 Kunal Mehta <[email protected]>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
19 namespace MediaWiki\SecureLinkFixer\Test;
20
21 use MediaWiki\SecureLinkFixer\ListFetcher;
22 use MediaWikiIntegrationTestCase;
23
24 /**
25 * Integration test and sanity check for domains.php
26 * @coversNothing
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 // Some arbitrary number as a sanity check
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 }