Skip to content

Commit

Permalink
Merge pull request #16 from matomo-org/githubaction
Browse files Browse the repository at this point in the history
Migrate travis tests to GitHub action
  • Loading branch information
michalkleiner authored Jan 8, 2025
2 parents d31bde2 + 2d44035 commit 2e9fdac
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 44 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -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
20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
}
},
"require": {
"php": ">=5.4"
"php": ">=7.2"
},
"require-dev": {
"phpunit/phpunit": "^4.8.36"
"phpunit/phpunit": "^8 || ^9 || ^10 || ^11"
}
}
5 changes: 0 additions & 5 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@
phpunit -c phpunit.xml
-->
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="./vendor/autoload.php">

<testsuites>
Expand Down
8 changes: 4 additions & 4 deletions tests/IPTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
class IPTest extends TestCase
{
public function ipData()
public static function ipData()
{
return array(
// IPv4
Expand All @@ -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'),
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -221,7 +221,7 @@ public function getIpsInRangeData()
);
}

public function getEmptyIpRangeData()
public static function getEmptyIpRangeData()
{
return array(
array(''),
Expand Down
12 changes: 6 additions & 6 deletions tests/IPUtilsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
class IPUtilsTest extends TestCase
{
public function getIPSanitizationData()
public static function getIPSanitizationData()
{
return array( // input, output
// single IPv4 address
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(

Expand Down
6 changes: 3 additions & 3 deletions tests/IPv4Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
class IPv4Test extends TestCase
{
public function getIPv4Data()
public static function getIPv4Data()
{
return array(
array(null, '0.0.0.0'),
Expand All @@ -34,10 +34,10 @@ 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()
public static function getAddressesToAnonymize()
{
return array(
// ip, array( expected0, expected1, expected2, expected3, expected4 ),
Expand Down
8 changes: 4 additions & 4 deletions tests/IPv6Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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),
Expand All @@ -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(
Expand Down Expand Up @@ -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 ),
Expand Down

0 comments on commit 2e9fdac

Please sign in to comment.