diff --git a/.coveralls.yml b/.coveralls.yml new file mode 100644 index 0000000..9160059 --- /dev/null +++ b/.coveralls.yml @@ -0,0 +1 @@ +service_name: travis-ci diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index ddf8b8d..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Test -on: [push, pull_request] -jobs: - test: - name: Test PHP ${{ matrix.php-version }} - runs-on: ubuntu-latest - strategy: - matrix: - php-version: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0'] - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-version }} - - name: PHP Version - run: php --version - - name: Composer Version - run: composer --version - - name: Install Dependencies - run: COMPOSER_MEMORY_LIMIT=-1 composer install - - name: Run Tests - run: vendor/bin/phpunit --coverage-clover ./coverage.xml - - name: Upload Coverage - if: ${{ matrix.php-version == '7.4' }} - uses: codecov/codecov-action@v1 - with: - file: ./coverage.xml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..36d3649 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,40 @@ +language: php +dist: bionic +sudo: required + +matrix: + include: + - php: 5.3 + dist: precise + - php: 5.4 + dist: trusty + - php: 5.5 + dist: trusty + - php: 5.6 + dist: trusty + - php: 7.0 + dist: xenial + - php: 7.1 + - php: 7.2 + - php: 7.3 + - php: 7.4 + env: COVERAGE=true + - php: nightly + allow_failures: + - php: nightly + +install: + - php --version + - composer install + +before_script: + - mkdir -p build/logs + +script: + - vendor/bin/phpunit --coverage-clover build/logs/clover.xml + +after_success: + - | + if [[ $COVERAGE ]]; then + travis_retry php vendor/bin/php-coveralls --config .coveralls.yml -v + fi diff --git a/FUNDING.yml b/FUNDING.yml index 9396c28..8b5faa1 100644 --- a/FUNDING.yml +++ b/FUNDING.yml @@ -1 +1 @@ -github: joshtronic +patreon: joshtronic diff --git a/LICENSE b/LICENSE index be2bff2..22de71d 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2012-2014 Josh Sherman +Copyright (c) 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Josh Sherman Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/composer.json b/composer.json index ed5854c..87ebba0 100644 --- a/composer.json +++ b/composer.json @@ -1,26 +1,33 @@ { - "name": "joshtronic/php-projecthoneypot", - "description": "PHP Wrapper for Project Honey Pot", - "version": "1.0.0", - "type": "library", - "keywords": ["project", "honey", "pot", "api", "spam", "spammer"], - "homepage": "https://github.com/joshtronic/php-projecthoneypot", - "license": "MIT", - "authors": [{ - "name": "Josh Sherman", - "email": "hello@joshtronic.com", - "homepage": "http://joshtronic.com" - }], - "require": { - "php": ">=5.3.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.36 || ^9.0" - }, - "autoload": { - "psr-4": {"joshtronic\\": "src/"} - }, - "autoload-dev": { - "psr-4": {"joshtronic\\Tests\\": "tests/"} + "name": "joshtronic/php-projecthoneypot", + "description": "PHP Wrapper for Project Honey Pot", + "version": "1.0.1", + "type": "library", + "keywords": [ + "project", + "honey", + "pot", + "api", + "spam", + "spammer" + ], + "homepage": "https://github.com/joshtronic/php-projecthoneypot", + "license": "MIT", + "authors": [{ + "name": "Josh Sherman", + "email": "hello@joshtronic.com", + "homepage": "https://joshtronic.com" + }], + "require": { + "php": ">=5.3" + }, + "require-dev": { + "php-coveralls/php-coveralls": ">=1", + "phpunit/phpunit": ">=4" + }, + "autoload": { + "psr-4": { + "joshtronic\\": "src/" } + } } diff --git a/phpunit.xml b/phpunit.xml index 82cbb00..6eaac53 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,7 +1,6 @@ - + tests diff --git a/src/ProjectHoneyPot.php b/src/ProjectHoneyPot.php index a82b243..a546b1b 100644 --- a/src/ProjectHoneyPot.php +++ b/src/ProjectHoneyPot.php @@ -9,7 +9,7 @@ * Redistribution of these files must retain the above copyright notice. * * @author Josh Sherman - * @copyright Copyright 2012-2015, Josh Sherman + * @copyright Copyright 2012, 2013, 2014, 2015, 2016, 2017, 2018 Josh Sherman * @license http://www.opensource.org/licenses/mit-license.html * @link https://github.com/joshtronic/php-projecthoneypot * @link http://www.projecthoneypot.org/httpbl_configure.php @@ -122,7 +122,7 @@ class ProjectHoneyPot /** * DNS Get Record * - * Wrapper method for dns_get_record() to allow for easy mocking of the + * Wrapper method for dns_get_record() to allow fo easy mocking of the * results in our tests. Takes an already reversed IP address and does a * DNS lookup for A records against the http:BL API. * diff --git a/tests/ProjectHoneyPotTest.php b/tests/ProjectHoneyPotTest.php index 9c5e103..bc8011a 100644 --- a/tests/ProjectHoneyPotTest.php +++ b/tests/ProjectHoneyPotTest.php @@ -1,22 +1,34 @@ assertSame('You must specify a valid API key.', $e->getMessage()); - } + new joshtronic\ProjectHoneyPot('foo'); } public function testInvalidIP() { - $object = new ProjectHoneyPot('foobarfoobar'); + $object = new joshtronic\ProjectHoneyPot('foobarfoobar'); $this->assertEquals( array('error' => 'Invalid IP address.'), @@ -26,28 +38,32 @@ class ProjectHoneyPotTest extends TestCase public function testMissingResults() { - $mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot') - ->setConstructorArgs(array('foobarfoobar')) - ->setMethods(array('dns_get_record')) - ->getMock(); + $mock = $this->$createMock( + 'joshtronic\ProjectHoneyPot', + array('dns_get_record'), + array('foobarfoobar') + ); - $mock->expects($this->once()) - ->method('dns_get_record') - ->will($this->returnValue('foo')); + $mock + ->expects($this->once()) + ->method('dns_get_record') + ->will($this->returnValue('foo')); $this->assertFalse($mock->query('1.2.3.4')); } public function testCategory0() { - $mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot') - ->setConstructorArgs(array('foobarfoobar')) - ->setMethods(array('dns_get_record')) - ->getMock(); + $mock = $this->$createMock( + 'joshtronic\ProjectHoneyPot', + array('dns_get_record'), + array('foobarfoobar') + ); - $mock->expects($this->once()) - ->method('dns_get_record') - ->will($this->returnValue(array(array('ip' => '127.0.0.0')))); + $mock + ->expects($this->once()) + ->method('dns_get_record') + ->will($this->returnValue(array(array('ip' => '127.0.0.0')))); $results = $mock->query('1.2.3.4'); @@ -56,14 +72,16 @@ class ProjectHoneyPotTest extends TestCase public function testCategory1() { - $mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot') - ->setConstructorArgs(array('foobarfoobar')) - ->setMethods(array('dns_get_record')) - ->getMock(); + $mock = $this->$createMock( + 'joshtronic\ProjectHoneyPot', + array('dns_get_record'), + array('foobarfoobar') + ); - $mock->expects($this->once()) - ->method('dns_get_record') - ->will($this->returnValue(array(array('ip' => '127.0.0.1')))); + $mock + ->expects($this->once()) + ->method('dns_get_record') + ->will($this->returnValue(array(array('ip' => '127.0.0.1')))); $results = $mock->query('1.2.3.4'); @@ -72,14 +90,16 @@ class ProjectHoneyPotTest extends TestCase public function testCategory2() { - $mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot') - ->setConstructorArgs(array('foobarfoobar')) - ->setMethods(array('dns_get_record')) - ->getMock(); + $mock = $this->$createMock( + 'joshtronic\ProjectHoneyPot', + array('dns_get_record'), + array('foobarfoobar') + ); - $mock->expects($this->once()) - ->method('dns_get_record') - ->will($this->returnValue(array(array('ip' => '127.0.0.2')))); + $mock + ->expects($this->once()) + ->method('dns_get_record') + ->will($this->returnValue(array(array('ip' => '127.0.0.2')))); $results = $mock->query('1.2.3.4'); @@ -88,14 +108,16 @@ class ProjectHoneyPotTest extends TestCase public function testCategory3() { - $mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot') - ->setConstructorArgs(array('foobarfoobar')) - ->setMethods(array('dns_get_record')) - ->getMock(); + $mock = $this->$createMock( + 'joshtronic\ProjectHoneyPot', + array('dns_get_record'), + array('foobarfoobar') + ); - $mock->expects($this->once()) - ->method('dns_get_record') - ->will($this->returnValue(array(array('ip' => '127.0.0.3')))); + $mock + ->expects($this->once()) + ->method('dns_get_record') + ->will($this->returnValue(array(array('ip' => '127.0.0.3')))); $results = $mock->query('1.2.3.4'); @@ -107,14 +129,16 @@ class ProjectHoneyPotTest extends TestCase public function testCategory4() { - $mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot') - ->setConstructorArgs(array('foobarfoobar')) - ->setMethods(array('dns_get_record')) - ->getMock(); + $mock = $this->$createMock( + 'joshtronic\ProjectHoneyPot', + array('dns_get_record'), + array('foobarfoobar') + ); - $mock->expects($this->once()) - ->method('dns_get_record') - ->will($this->returnValue(array(array('ip' => '127.0.0.4')))); + $mock + ->expects($this->once()) + ->method('dns_get_record') + ->will($this->returnValue(array(array('ip' => '127.0.0.4')))); $results = $mock->query('1.2.3.4'); @@ -126,14 +150,16 @@ class ProjectHoneyPotTest extends TestCase public function testCategory5() { - $mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot') - ->setConstructorArgs(array('foobarfoobar')) - ->setMethods(array('dns_get_record')) - ->getMock(); + $mock = $this->$createMock( + 'joshtronic\ProjectHoneyPot', + array('dns_get_record'), + array('foobarfoobar') + ); - $mock->expects($this->once()) - ->method('dns_get_record') - ->will($this->returnValue(array(array('ip' => '127.0.0.5')))); + $mock + ->expects($this->once()) + ->method('dns_get_record') + ->will($this->returnValue(array(array('ip' => '127.0.0.5')))); $results = $mock->query('1.2.3.4'); @@ -145,14 +171,16 @@ class ProjectHoneyPotTest extends TestCase public function testCategory6() { - $mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot') - ->setConstructorArgs(array('foobarfoobar')) - ->setMethods(array('dns_get_record')) - ->getMock(); + $mock = $this->$createMock( + 'joshtronic\ProjectHoneyPot', + array('dns_get_record'), + array('foobarfoobar') + ); - $mock->expects($this->once()) - ->method('dns_get_record') - ->will($this->returnValue(array(array('ip' => '127.0.0.6')))); + $mock + ->expects($this->once()) + ->method('dns_get_record') + ->will($this->returnValue(array(array('ip' => '127.0.0.6')))); $results = $mock->query('1.2.3.4'); @@ -164,14 +192,16 @@ class ProjectHoneyPotTest extends TestCase public function testCategory7() { - $mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot') - ->setConstructorArgs(array('foobarfoobar')) - ->setMethods(array('dns_get_record')) - ->getMock(); + $mock = $this->$createMock( + 'joshtronic\ProjectHoneyPot', + array('dns_get_record'), + array('foobarfoobar') + ); - $mock->expects($this->once()) - ->method('dns_get_record') - ->will($this->returnValue(array(array('ip' => '127.0.0.7')))); + $mock + ->expects($this->once()) + ->method('dns_get_record') + ->will($this->returnValue(array(array('ip' => '127.0.0.7')))); $results = $mock->query('1.2.3.4'); @@ -183,14 +213,16 @@ class ProjectHoneyPotTest extends TestCase public function testCategoryDefault() { - $mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot') - ->setConstructorArgs(array('foobarfoobar')) - ->setMethods(array('dns_get_record')) - ->getMock(); + $mock = $this->$createMock( + 'joshtronic\ProjectHoneyPot', + array('dns_get_record'), + array('foobarfoobar') + ); - $mock->expects($this->once()) - ->method('dns_get_record') - ->will($this->returnValue(array(array('ip' => '127.0.0.255')))); + $mock + ->expects($this->once()) + ->method('dns_get_record') + ->will($this->returnValue(array(array('ip' => '127.0.0.255')))); $results = $mock->query('1.2.3.4'); @@ -202,14 +234,16 @@ class ProjectHoneyPotTest extends TestCase public function testWithout127() { - $mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot') - ->setConstructorArgs(array('foobarfoobar')) - ->setMethods(array('dns_get_record')) - ->getMock(); + $mock = $this->$createMock( + 'joshtronic\ProjectHoneyPot', + array('dns_get_record'), + array('foobarfoobar') + ); - $mock->expects($this->once()) - ->method('dns_get_record') - ->will($this->returnValue(array(array('ip' => '1.0.0.0')))); + $mock + ->expects($this->once()) + ->method('dns_get_record') + ->will($this->returnValue(array(array('ip' => '1.0.0.0')))); $this->assertFalse($mock->query('1.2.3.4')); } @@ -217,11 +251,9 @@ class ProjectHoneyPotTest extends TestCase // Doesn't serve much purpose aside from helping achieve 100% coverage public function testDnsGetRecord() { - $object = new ProjectHoneyPot('foobarfoobar'); + $object = new joshtronic\ProjectHoneyPot('foobarfoobar'); - $result = $object->dns_get_record('1.2.3.4'); - - $this->assertEquals(array(), $result); + $object->dns_get_record('1.2.3.4'); } }