We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| 1 | <?php |
||
| 35 | class RE_Test extends PHP_Typography_Testcase { |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Sets up the fixture, for example, opens a network connection. |
||
| 39 | * This method is called before a test is executed. |
||
| 40 | */ |
||
| 41 | protected function setUp() { // @codingStandardsIgnoreLine |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Tears down the fixture, for example, closes a network connection. |
||
| 46 | * This method is called after a test is executed. |
||
| 47 | */ |
||
| 48 | protected function tearDown() { // @codingStandardsIgnoreLine |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Tests top_level_domains. |
||
| 53 | * |
||
| 54 | * @covers ::top_level_domains |
||
| 55 | * |
||
| 56 | * @uses ::get_top_level_domains_from_file |
||
| 57 | */ |
||
| 58 | public function test_top_level_domains() { |
||
| 59 | $result = $this->invokeStaticMethod( RE::class, 'top_level_domains', [] ); |
||
| 60 | |||
| 61 | $this->assertInternalType( 'string', $result, 'RE::top_level_domains() should return a string.' ); |
||
| 62 | $this->assertGreaterThan( 0, strlen( $result ) ); |
||
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Tests top_level_domains. |
||
| 67 | * |
||
| 68 | * @covers ::top_level_domains |
||
| 69 | * |
||
| 70 | * @uses ::get_top_level_domains_from_file |
||
| 71 | */ |
||
| 72 | public function test_top_level_domains_clean() { |
||
| 73 | // Unset RE::$top_level_domains_pattern. |
||
| 74 | $this->setStaticValue( RE::class, 'top_level_domains_pattern', null ); |
||
| 75 | |||
| 76 | $result = $this->invokeStaticMethod( RE::class, 'top_level_domains', [] ); |
||
| 77 | |||
| 78 | $this->assertInternalType( 'string', $result, 'RE::top_level_domains() should return a string.' ); |
||
| 79 | $this->assertGreaterThan( 0, strlen( $result ) ); |
||
| 80 | } |
||
| 81 | |||
| 82 | /** |
||
| 83 | * Tests get_top_level_domains_from_file. |
||
| 84 | * |
||
| 85 | * @covers ::get_top_level_domains_from_file |
||
| 86 | */ |
||
| 87 | public function test_get_top_level_domains_from_file() { |
||
| 88 | $default = 'ac|ad|aero|ae|af|ag|ai|al|am|an|ao|aq|arpa|ar|asia|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|biz|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|cat|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|com|coop|co|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|info|int|in|io|iq|ir|is|it|je|jm|jobs|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mil|mk|ml|mm|mn|mobi|mo|mp|mq|mr|ms|mt|museum|mu|mv|mw|mx|my|mz|name|na|nc|net|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pro|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tel|tf|tg|th|tj|tk|tl|tm|tn|to|tp|travel|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw'; |
||
| 89 | |||
| 90 | $invalid_result = $this->invokeStaticMethod( RE::class, 'get_top_level_domains_from_file', [ '/some/invalid/path/to_a_non_existent_file.txt' ] ); |
||
| 91 | $valid_result = $this->invokeStaticMethod( RE::class, 'get_top_level_domains_from_file', [ dirname( __DIR__ ) . '/src/IANA/tlds-alpha-by-domain.txt' ] ); |
||
| 92 | |||
| 93 | $this->assertSame( $default, $invalid_result ); |
||
| 94 | $this->assertNotSame( $valid_result, $invalid_result ); |
||
| 95 | $this->assertNotEmpty( $valid_result ); |
||
| 96 | } |
||
| 97 | } |
||
| 98 |