diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..99bafec --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,38 @@ +name: PHP Tests + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + test: + runs-on: ubuntu-latest + + strategy: + matrix: + php-version: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up PHP ${{ matrix.php-version }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: bcmath, curl, json + coverage: none + + - name: Install Composer dependencies + run: | + if [ "${{ matrix.php-version }}" = "7.2" ]; then + composer require --dev phpunit/phpunit:^8.0 --no-update + fi + composer install --no-progress --prefer-dist + + - name: Run tests + run: vendor/bin/phpunit diff --git a/LICENSE.TXT b/LICENSE.TXT index c96a21a..5391874 100644 --- a/LICENSE.TXT +++ b/LICENSE.TXT @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2023 - 2024 IP2Location.com +Copyright (c) 2023 - 2025 IP2Location.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 04f0694..9888b2e 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,6 @@ Below are the list of other framework library that you can install and use right ## COPYRIGHT AND LICENSE -Copyright (C) 2005-2024 by IP2Location.com +Copyright (C) 2005-2025 by IP2Location.com License under MIT diff --git a/docs/source/quickstart.md b/docs/source/quickstart.md index e5d18bf..3732421 100644 --- a/docs/source/quickstart.md +++ b/docs/source/quickstart.md @@ -13,10 +13,6 @@ download the BIN database at An outdated BIN database was provided in the databases folder for your testing. You are recommended to visit the above links to download the latest BIN database. ::: -## Requirements - -1. Python 3.5 and above. - ## Installation Install this package using **composer** as below: diff --git a/tests/DatabaseTest.php b/tests/DatabaseTest.php index d3e3330..d3c52e4 100644 --- a/tests/DatabaseTest.php +++ b/tests/DatabaseTest.php @@ -24,7 +24,7 @@ public function testIpv4CountryCode() { $this->assertEquals( 'US', - $records['countryCode'], + $records['countryCode'] ); } @@ -35,7 +35,7 @@ public function testIpv4CountryName() { $this->assertEquals( 'United States of America', - $records['countryName'], + $records['countryName'] ); } @@ -54,7 +54,7 @@ public function testIpv6CountryCode() { $this->assertEquals( 'US', - $records['countryCode'], + $records['countryCode'] ); } @@ -65,7 +65,7 @@ public function testIpv6CountryName() { $this->assertEquals( 'United States of America', - $records['countryName'], + $records['countryName'] ); } diff --git a/tests/IpToolsTest.php b/tests/IpToolsTest.php index fcb150a..53d36b8 100644 --- a/tests/IpToolsTest.php +++ b/tests/IpToolsTest.php @@ -139,7 +139,7 @@ public function testCidrToIpv6() $this->assertEqualsCanonicalizing( [ - 'ip_start' => '2002:0000:0000:1234:abcd:ffff:c0a8:0101', + 'ip_start' => '2002:0000:0000:1234:0000:0000:0000:0000', 'ip_end' => '2002:0000:0000:1234:ffff:ffff:ffff:ffff', ], $ipTools->cidrToIpv6('2002::1234:abcd:ffff:c0a8:101/64') diff --git a/tests/RegionTest.php b/tests/RegionTest.php index b6fac9d..76394a8 100644 --- a/tests/RegionTest.php +++ b/tests/RegionTest.php @@ -14,7 +14,7 @@ public function testRegionCodeField() $this->assertEquals( 'US-CA', - $region->getRegionCode('US', 'California'), + $region->getRegionCode('US', 'California') ); } } diff --git a/tests/WebServiceTest.php b/tests/WebServiceTest.php index f973e28..bfc90e4 100644 --- a/tests/WebServiceTest.php +++ b/tests/WebServiceTest.php @@ -11,7 +11,12 @@ class WebServiceTest extends TestCase { public function testCredit() { $ws = new \IP2Location\WebService('demo', 'WS24', true); - $this->assertMatchesRegularExpression('/^[0-9]+$/', (string) $ws->getCredit()); + if (method_exists($this, 'assertMatchesRegularExpression')) { + $this->assertMatchesRegularExpression('/^[0-9]+$/', (string) $ws->getCredit()); + }else{ + // Compatible with php 7.2 && phpunit 8.x + $this->assertRegExp('/^[0-9]+$/', (string) $ws->getCredit()); + } } public function testCountryCode() { @@ -23,7 +28,7 @@ public function testCountryCode() { $this->assertEquals( 'US', - $records['country_code'], + $records['country_code'] ); } }