From a3fb32f65a8050852206e1e79e7b9990b08ef9d5 Mon Sep 17 00:00:00 2001 From: flashwave Date: Sun, 16 Sep 2018 21:16:17 +0200 Subject: [PATCH] fuck tests --- .travis.yml | 16 ---- phpunit.xml | 17 ---- tests/ColourTest.php | 108 ------------------------- tests/IPAddressTest.php | 170 ---------------------------------------- tests/UserTest.php | 18 ----- tests/ZalgoTest.php | 27 ------- 6 files changed, 356 deletions(-) delete mode 100644 .travis.yml delete mode 100644 phpunit.xml delete mode 100644 tests/ColourTest.php delete mode 100644 tests/IPAddressTest.php delete mode 100644 tests/UserTest.php delete mode 100644 tests/ZalgoTest.php diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 49e506d7..00000000 --- a/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -cache: - directories: - - vendor - -language: php - -php: - - 7.2 - -matrix: - fast_finish: true - -before_install: - - composer install - -script: ./vendor/bin/phpunit diff --git a/phpunit.xml b/phpunit.xml deleted file mode 100644 index b56766a5..00000000 --- a/phpunit.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - ./tests/ - - - diff --git a/tests/ColourTest.php b/tests/ColourTest.php deleted file mode 100644 index fc42b039..00000000 --- a/tests/ColourTest.php +++ /dev/null @@ -1,108 +0,0 @@ -assertTrue(colour_get_inherit($colour)); - $this->assertEquals($colour, 0x40000000); - $this->assertEquals(colour_get_red($colour), 0); - $this->assertEquals(colour_get_green($colour), 0); - $this->assertEquals(colour_get_blue($colour), 0); - $this->assertEquals(colour_get_hex($colour), '#000000'); - $this->assertEquals(colour_get_css($colour), 'inherit'); - } - - public function testNull() - { - $colour = colour_create(); - - $this->assertFalse(colour_get_inherit($colour)); - $this->assertEquals($colour, 0); - $this->assertEquals(colour_get_red($colour), 0); - $this->assertEquals(colour_get_green($colour), 0); - $this->assertEquals(colour_get_blue($colour), 0); - $this->assertEquals(colour_get_hex($colour), '#000000'); - $this->assertEquals(colour_get_css($colour), '#000000'); - } - - public function testFromRaw() - { - $colour = static::RAW_HEX6; - - $this->assertFalse(colour_get_inherit($colour)); - $this->assertEquals($colour, static::RAW_HEX6); - $this->assertEquals(colour_get_red($colour), static::RED_HEX6); - $this->assertEquals(colour_get_green($colour), static::GREEN_HEX6); - $this->assertEquals(colour_get_blue($colour), static::BLUE_HEX6); - $this->assertEquals(colour_get_hex($colour), static::STR_HEX6); - $this->assertEquals(colour_get_css($colour), static::STR_HEX6); - } - - public function testFromRGB() - { - $colour = colour_create(); - colour_from_rgb($colour, static::RED_HEX6, static::GREEN_HEX6, static::BLUE_HEX6); - - $this->assertFalse(colour_get_inherit($colour)); - $this->assertEquals($colour, static::RAW_HEX6); - $this->assertEquals(colour_get_red($colour), static::RED_HEX6); - $this->assertEquals(colour_get_green($colour), static::GREEN_HEX6); - $this->assertEquals(colour_get_blue($colour), static::BLUE_HEX6); - $this->assertEquals(colour_get_hex($colour), static::STR_HEX6); - $this->assertEquals(colour_get_css($colour), static::STR_HEX6); - } - - public function testFromHex() - { - $colour = colour_create(); - colour_from_hex($colour, static::STR_HEX6); - - $this->assertFalse(colour_get_inherit($colour)); - $this->assertEquals($colour, static::RAW_HEX6); - $this->assertEquals(colour_get_red($colour), static::RED_HEX6); - $this->assertEquals(colour_get_green($colour), static::GREEN_HEX6); - $this->assertEquals(colour_get_blue($colour), static::BLUE_HEX6); - $this->assertEquals(colour_get_hex($colour), static::STR_HEX6); - $this->assertEquals(colour_get_css($colour), static::STR_HEX6); - } - - public function testFromHex3() - { - $colour = colour_create(); - colour_from_hex($colour, static::SSTR_HEX3); - - $this->assertFalse(colour_get_inherit($colour)); - $this->assertEquals($colour, static::RAW_HEX3); - $this->assertEquals(colour_get_red($colour), static::RED_HEX3); - $this->assertEquals(colour_get_green($colour), static::GREEN_HEX3); - $this->assertEquals(colour_get_blue($colour), static::BLUE_HEX3); - $this->assertEquals(colour_get_hex($colour), static::STR_HEX3); - $this->assertEquals(colour_get_css($colour), static::STR_HEX3); - } - - public function testHexException() - { - $colour = colour_create(); - $this->assertFalse(colour_from_hex($colour, 'invalid hex code')); - } -} diff --git a/tests/IPAddressTest.php b/tests/IPAddressTest.php deleted file mode 100644 index 8fde1935..00000000 --- a/tests/IPAddressTest.php +++ /dev/null @@ -1,170 +0,0 @@ -assertEquals(IPAddress::V4, IPAddress::detectVersionFromString('127.0.0.1')); - $this->assertEquals(IPAddress::V4, IPAddress::detectVersionFromRaw(hex2bin('7f000001'))); - - $this->assertEquals(IPAddress::V4, IPAddress::detectVersionFromString('104.27.135.189')); - $this->assertEquals(IPAddress::V4, IPAddress::detectVersionFromRaw(hex2bin('681b87bd'))); - - $this->assertEquals(IPAddress::V4, IPAddress::detectVersionFromString('104.27.154.200')); - $this->assertEquals(IPAddress::V4, IPAddress::detectVersionFromRaw(hex2bin('681b9ac8'))); - - $this->assertEquals(IPAddress::V4, IPAddress::detectVersionFromString('104.28.9.4')); - $this->assertEquals(IPAddress::V4, IPAddress::detectVersionFromRaw(hex2bin('681c0904'))); - - $this->assertEquals(IPAddress::V6, IPAddress::detectVersionFromString('::1')); - $this->assertEquals( - IPAddress::V6, - IPAddress::detectVersionFromRaw(hex2bin('00000000000000000000000000000001')) - ); - - $this->assertEquals(IPAddress::V6, IPAddress::detectVersionFromString('2400:cb00:2048:1:0:0:681b:9ac8')); - $this->assertEquals( - IPAddress::V6, - IPAddress::detectVersionFromRaw(hex2bin('2400cb002048000100000000681b9ac8')) - ); - - $this->assertEquals(IPAddress::V6, IPAddress::detectVersionFromString('2400:cb00:2048:1:0:0:681c:804')); - $this->assertEquals( - IPAddress::V6, - IPAddress::detectVersionFromRaw(hex2bin('2400cb002048000100000000681c0804')) - ); - - $this->assertEquals(IPAddress::V6, IPAddress::detectVersionFromString('2400:cb00:2048:1:0:0:681b:86bd')); - $this->assertEquals( - IPAddress::V6, - IPAddress::detectVersionFromRaw(hex2bin('2400cb002048000100000000681b86bd')) - ); - - $this->assertEquals(IPAddress::V6, IPAddress::detectVersionFromString('2400:cb00:2048:1:0:0:681f:5e2a')); - $this->assertEquals( - IPAddress::V6, - IPAddress::detectVersionFromRaw(hex2bin('2400cb002048000100000000681f5e2a')) - ); - - $this->assertEquals(IPAddress::UNKNOWN_VERSION, IPAddress::detectVersionFromString('not an ip address')); - $this->assertEquals(IPAddress::UNKNOWN_VERSION, IPAddress::detectVersionFromString('256.256.256.256')); - $this->assertEquals(IPAddress::UNKNOWN_VERSION, IPAddress::detectVersionFromRaw('invalid')); - } - - public function testString() - { - $this->assertEquals(hex2bin('7f000001'), IPAddress::fromString('127.0.0.1')->getRaw()); - $this->assertEquals(hex2bin('681b87bd'), IPAddress::fromString('104.27.135.189')->getRaw()); - $this->assertEquals(hex2bin('681b9ac8'), IPAddress::fromString('104.27.154.200')->getRaw()); - $this->assertEquals(hex2bin('681c0904'), IPAddress::fromString('104.28.9.4')->getRaw()); - - $this->assertEquals( - hex2bin('00000000000000000000000000000001'), - IPAddress::fromString('::1')->getRaw() - ); - $this->assertEquals( - hex2bin('2400cb002048000100000000681b9ac8'), - IPAddress::fromString('2400:cb00:2048:1:0:0:681b:9ac8')->getRaw() - ); - $this->assertEquals( - hex2bin('2400cb002048000100000000681c0804'), - IPAddress::fromString('2400:cb00:2048:1:0:0:681c:804')->getRaw() - ); - $this->assertEquals( - hex2bin('2400cb002048000100000000681b86bd'), - IPAddress::fromString('2400:cb00:2048:1:0:0:681b:86bd')->getRaw() - ); - $this->assertEquals( - hex2bin('2400cb002048000100000000681f5e2a'), - IPAddress::fromString('2400:cb00:2048:1:0:0:681f:5e2a')->getRaw() - ); - } - - public function testRaw() - { - $this->assertEquals('127.0.0.1', IPAddress::fromRaw(hex2bin('7f000001'))->getString()); - $this->assertEquals('104.27.135.189', IPAddress::fromRaw(hex2bin('681b87bd'))->getString()); - $this->assertEquals('104.27.154.200', IPAddress::fromRaw(hex2bin('681b9ac8'))->getString()); - $this->assertEquals('104.28.9.4', IPAddress::fromRaw(hex2bin('681c0904'))->getString()); - - $this->assertEquals( - '::1', - IPAddress::fromRaw(hex2bin('00000000000000000000000000000001'))->getString() - ); - $this->assertEquals( - IPAddress::fromRaw(hex2bin('2400cb002048000100000000681b9ac8'))->getString(), - '2400:cb00:2048:1::681b:9ac8' - ); - $this->assertEquals( - '2400:cb00:2048:1::681c:804', - IPAddress::fromRaw(hex2bin('2400cb002048000100000000681c0804'))->getString() - ); - $this->assertEquals( - '2400:cb00:2048:1::681b:86bd', - IPAddress::fromRaw(hex2bin('2400cb002048000100000000681b86bd'))->getString() - ); - $this->assertEquals( - '2400:cb00:2048:1::681f:5e2a', - IPAddress::fromRaw(hex2bin('2400cb002048000100000000681f5e2a'))->getString() - ); - } - - public function testCompare() - { - $v4_start = IPAddress::fromString('117.0.0.255'); - $v4_end = IPAddress::fromString('127.0.0.255'); - $v6_start = IPAddress::fromString('::1'); - $v6_end = IPAddress::fromString('::FFFF'); - - $this->assertEquals(1, $v4_start->compareTo($v4_end)); - $this->assertEquals(-1, $v4_end->compareTo($v4_start)); - $this->assertEquals(0, $v4_start->compareTo($v4_start)); - $this->assertEquals(0, $v4_end->compareTo($v4_end)); - - $this->assertEquals(1, $v6_start->compareTo($v6_end)); - $this->assertEquals(-1, $v6_end->compareTo($v6_start)); - $this->assertEquals(0, $v6_start->compareTo($v6_start)); - $this->assertEquals(0, $v6_end->compareTo($v6_end)); - } - - public function testMaskedRange() - { - $range_v4 = IPAddressRange::fromMaskedString('127.0.0.1/8'); - $this->assertEquals('127.0.0.1', $range_v4->getMaskAddress()->getString()); - $this->assertEquals(8, $range_v4->getCidrLength()); - $this->assertEquals('127.0.0.1/8', $range_v4->getMaskedString()); - - $range_v6 = IPAddressRange::fromMaskedString('::1/16'); - $this->assertEquals('::1', $range_v6->getMaskAddress()->getString()); - $this->assertEquals(16, $range_v6->getCidrLength()); - $this->assertEquals('::1/16', $range_v6->getMaskedString()); - } - - // excellent naming - public function testRangedRange() - { - $range_v4 = IPAddressRange::fromRangeString('255.255.255.248-255.255.255.255'); - $this->assertEquals('255.255.255.248', $range_v4->getMaskAddress()->getString()); - $this->assertEquals(29, $range_v4->getCidrLength()); - - $range_v6 = IPAddressRange::fromRangeString('2400:cb00:2048:1::681b:86bd-2400:cb00:2048:1::681f:5e2a'); - $this->assertEquals('2400:cb00:2048:1::6818:0', $range_v6->getMaskAddress()->getString()); - $this->assertEquals(109, $range_v6->getCidrLength()); - } - - public function testMatchRange() - { - $range_v4 = new IPAddressRange(IPAddress::fromString('108.162.192.0'), 18); - $this->assertTrue($range_v4->match(IPAddress::fromString('108.162.255.255'))); - $this->assertFalse($range_v4->match(IPAddress::fromString('127.0.0.1'))); - - $range_v6 = new IPAddressRange(IPAddress::fromString('2a06:98c0::'), 29); - $this->assertTrue($range_v6->match(IPAddress::fromString('2a06:98c7:7f:43:645:ab:cd:2525'))); - $this->assertFalse($range_v6->match(IPAddress::fromString('::1'))); - } -} diff --git a/tests/UserTest.php b/tests/UserTest.php deleted file mode 100644 index a83eee7c..00000000 --- a/tests/UserTest.php +++ /dev/null @@ -1,18 +0,0 @@ -assertEquals(user_validate_username('flashwave'), ''); - $this->assertEquals(user_validate_username(' flash '), 'trim'); - $this->assertEquals(user_validate_username('f'), 'short'); - $this->assertEquals(user_validate_username('flaaaaaaaaaaaaaaaash'), 'long'); - $this->assertEquals(user_validate_username('F|@$h'), 'invalid'); - $this->assertEquals(user_validate_username('fl ash_wave'), 'spacing'); - $this->assertEquals(user_validate_username('fl ash'), 'double-spaces'); - } -} diff --git a/tests/ZalgoTest.php b/tests/ZalgoTest.php deleted file mode 100644 index 30c9eabb..00000000 --- a/tests/ZalgoTest.php +++ /dev/null @@ -1,27 +0,0 @@ -assertEquals( - static::TEST_STRING, - zalgo_strip(zalgo_run(static::TEST_STRING, MSZ_ZALGO_MODE_MINI)) - ); - - $this->assertEquals( - static::TEST_STRING, - zalgo_strip(zalgo_run(static::TEST_STRING, MSZ_ZALGO_MODE_NORMAL)) - ); - - $this->assertEquals( - static::TEST_STRING, - zalgo_strip(zalgo_run(static::TEST_STRING, MSZ_ZALGO_MODE_MAX)) - ); - } -}