From 4138ff122c632dbb48fbe620b94177a20d2d1de8 Mon Sep 17 00:00:00 2001 From: Stefan Giehl Date: Tue, 7 Jan 2025 17:42:26 +0100 Subject: [PATCH 01/10] Create GitHub test action --- .github/workflows/phpunit.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/phpunit.yml diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml new file mode 100644 index 0000000..6109ede --- /dev/null +++ b/.github/workflows/phpunit.yml @@ -0,0 +1,26 @@ +name: PHPUnit + +on: + pull_request: + push: + +permissions: + contents: read + +jobs: + build: + name: PHPUnit + runs-on: ubuntu-latest + strategy: + matrix: + php-version: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] + steps: + - uses: actions/checkout@v4 + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + - name: Composer install + run: composer install + - name: PHPUnit / PHP ${{ matrix.php-version }} + run: ./vendor/bin/phpunit From d6da8e39bc3f596d9e430f8c0560f616df7e10a5 Mon Sep 17 00:00:00 2001 From: Stefan Giehl Date: Tue, 7 Jan 2025 17:44:07 +0100 Subject: [PATCH 02/10] allow newer php versions --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7e3190e..a4773c9 100644 --- a/composer.json +++ b/composer.json @@ -16,6 +16,6 @@ "php": ">=5.4" }, "require-dev": { - "phpunit/phpunit": "^4.8.36" + "phpunit/phpunit": "^8 || ^9 || ^10 || ^11" } } From 481959fc1795f7c7e260a89a4c55684de70fd863 Mon Sep 17 00:00:00 2001 From: Stefan Giehl Date: Tue, 7 Jan 2025 17:46:43 +0100 Subject: [PATCH 03/10] fix test --- tests/IPv4Test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/IPv4Test.php b/tests/IPv4Test.php index 2ba40be..743ef2a 100644 --- a/tests/IPv4Test.php +++ b/tests/IPv4Test.php @@ -34,7 +34,7 @@ public function testToIPv4String($stringIp, $expected) $this->assertInstanceOf('Matomo\Network\IPv4', $ip); - $this->assertEquals($expected, $ip->toIPv4String(), $stringIp); + $this->assertEquals($expected, $ip->toIPv4String()); } public function getAddressesToAnonymize() From bc8608678bbb2a0c1cbe5131e8a86f10ef7d2c80 Mon Sep 17 00:00:00 2001 From: Stefan Giehl Date: Tue, 7 Jan 2025 17:47:30 +0100 Subject: [PATCH 04/10] remove .travis.yml --- .travis.yml | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 1a7918c..0000000 --- a/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -language: php - -dist: trusty -sudo: false - -php: - - 5.4 - - 5.5 - - 5.6 - - 7.0 - - 7.1 - - 7.2 - - 7.3 - - 7.4 - -install: - - travis_retry composer install - -script: - - vendor/bin/phpunit From 227cf395826919a45f741b2e26d73a37f1eb1396 Mon Sep 17 00:00:00 2001 From: Stefan Giehl Date: Tue, 7 Jan 2025 17:48:01 +0100 Subject: [PATCH 05/10] adjust phpunit.xml --- phpunit.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index d814d7a..8c3cca9 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -3,14 +3,9 @@ phpunit -c phpunit.xml --> From 153155275d23bb9dc8454993cc0d2b97fa8766bf Mon Sep 17 00:00:00 2001 From: Stefan Giehl Date: Tue, 7 Jan 2025 17:50:46 +0100 Subject: [PATCH 06/10] Adjust test --- tests/IPTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/IPTest.php b/tests/IPTest.php index 97692b1..e0e33b3 100644 --- a/tests/IPTest.php +++ b/tests/IPTest.php @@ -17,7 +17,7 @@ */ class IPTest extends TestCase { - public function ipData() + public static function ipData() { return array( // IPv4 @@ -35,7 +35,7 @@ public function ipData() ); } - public function emptyNullIpData() + public static function emptyNullIpData() { return array( array('', "\x00\x00\x00\x00", '0.0.0.0'), @@ -134,7 +134,7 @@ public function testGetHostnameFailure() $this->assertNull($ip->getHostname()); } - public function getIpsInRangeData() + public static function getIpsInRangeData() { return array( array('192.168.1.10', array( @@ -221,7 +221,7 @@ public function getIpsInRangeData() ); } - public function getEmptyIpRangeData() + public static function getEmptyIpRangeData() { return array( array(''), From 12643e30b245eb5d2bbb237029f08637c3d862b7 Mon Sep 17 00:00:00 2001 From: Stefan Giehl Date: Tue, 7 Jan 2025 17:51:34 +0100 Subject: [PATCH 07/10] adjust tests --- tests/IPUtilsTest.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/IPUtilsTest.php b/tests/IPUtilsTest.php index e4f158a..9d82355 100644 --- a/tests/IPUtilsTest.php +++ b/tests/IPUtilsTest.php @@ -16,7 +16,7 @@ */ class IPUtilsTest extends TestCase { - public function getIPSanitizationData() + public static function getIPSanitizationData() { return array( // input, output // single IPv4 address @@ -66,7 +66,7 @@ public function testSanitizeIp($ip, $expected) $this->assertEquals($expected, IPUtils::sanitizeIp($ip)); } - public function getIPRangeSanitizationData() + public static function getIPRangeSanitizationData() { return array( array('', null), @@ -136,7 +136,7 @@ public function testSanitizeIpRange($ip, $expected) $this->assertSame($expected, IPUtils::sanitizeIpRange($ip)); } - public function getIPData() + public static function getIPData() { return array( // IPv4 @@ -162,7 +162,7 @@ public function testStringToBinaryIP($string, $binary) $this->assertEquals($binary, IPUtils::stringToBinaryIP($string)); } - public function getInvalidIPData() + public static function getInvalidIPData() { return array( // not a series of dotted numbers @@ -194,7 +194,7 @@ public function testStringToBinaryInvalidIP($stringIp) $this->assertEquals("\x00\x00\x00\x00", IPUtils::stringToBinaryIP($stringIp)); } - public function getBinaryIPData() + public static function getBinaryIPData() { // a valid network address is either 4 or 16 bytes; those lines are intentionally left blank ;) return array( @@ -236,7 +236,7 @@ public function testBinaryToStringInvalidIP($binary) $this->assertEquals('0.0.0.0', IPUtils::binaryToStringIP($binary), bin2hex($binary)); } - public function getBoundsForIPRangeTest() + public static function getBoundsForIPRangeTest() { return array( From f9beadbbc61989143584c4eb803cbe321270b613 Mon Sep 17 00:00:00 2001 From: Stefan Giehl Date: Tue, 7 Jan 2025 17:51:57 +0100 Subject: [PATCH 08/10] adjust tests --- tests/IPv4Test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/IPv4Test.php b/tests/IPv4Test.php index 743ef2a..333492d 100644 --- a/tests/IPv4Test.php +++ b/tests/IPv4Test.php @@ -16,7 +16,7 @@ */ class IPv4Test extends TestCase { - public function getIPv4Data() + public static function getIPv4Data() { return array( array(null, '0.0.0.0'), @@ -37,7 +37,7 @@ public function testToIPv4String($stringIp, $expected) $this->assertEquals($expected, $ip->toIPv4String()); } - public function getAddressesToAnonymize() + public static function getAddressesToAnonymize() { return array( // ip, array( expected0, expected1, expected2, expected3, expected4 ), From e4a693fad5b576e2c8b1d3b3aa58d57e26e3da7d Mon Sep 17 00:00:00 2001 From: Stefan Giehl Date: Tue, 7 Jan 2025 17:52:20 +0100 Subject: [PATCH 09/10] adjust tests --- tests/IPv6Test.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/IPv6Test.php b/tests/IPv6Test.php index 9146736..38b18ae 100644 --- a/tests/IPv6Test.php +++ b/tests/IPv6Test.php @@ -17,7 +17,7 @@ */ class IPv6Test extends TestCase { - public function getIPv6Data() + public static function getIPv6Data() { return array( array('::ffff:192.168.0.1', '192.168.0.1'), @@ -37,7 +37,7 @@ public function testToIPv4String($stringIp, $expected) $this->assertEquals($expected, $ip->toIPv4String(), $stringIp); } - public function getMappedIPv4Data() + public static function getMappedIPv4Data() { return array( array(IP::fromStringIP('::ffff:192.168.0.1'), true), @@ -63,7 +63,7 @@ public function testIsMappedIPv4(IPv6 $ip, $isMapped) $this->assertEquals($isMapped, $ip->isMappedIPv4(), $ip); } - public function getAddressesToAnonymize() + public static function getAddressesToAnonymize() { return array( array('2001:db8:0:8d3:0:8a2e:70:7344', array( @@ -100,7 +100,7 @@ public function testAnonymize($ipString, $expected) } - public function getIPv4AddressesToAnonymize() + public static function getIPv4AddressesToAnonymize() { return array( // ip, array( expected0, expected1, expected2, expected3, expected4 ), From 2d4403535ca4e377917132055eece8a7997860cf Mon Sep 17 00:00:00 2001 From: Stefan Giehl Date: Tue, 7 Jan 2025 17:53:30 +0100 Subject: [PATCH 10/10] increase minimum php version to 7.2 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a4773c9..151baee 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ } }, "require": { - "php": ">=5.4" + "php": ">=7.2" }, "require-dev": { "phpunit/phpunit": "^8 || ^9 || ^10 || ^11"