From 7ea1bd219f2407aeda64b88a60d1f316348fa05d Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Tue, 9 Jan 2018 00:15:18 -0600 Subject: [PATCH 1/6] Bumped copyright, expanded PHP versions --- .travis.yml | 8 +++----- LICENSE | 2 +- composer.json | 31 ++++++++++++++++++++----------- src/ProjectHoneyPot.php | 2 +- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8bfb40e..92dc405 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,12 +5,10 @@ php: - 5.4 - 5.5 - 5.6 + - 7.0 + - 7.1 + - 7.2 - hhvm - - hhvm-nightly - -matrix: - allow_failures: - - php: hhvm-nightly install: - composer install diff --git a/LICENSE b/LICENSE index be2bff2..714cd64 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 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 8bef239..82637be 100644 --- a/composer.json +++ b/composer.json @@ -1,16 +1,25 @@ { - "name": "joshtronic/php-projecthoneypot", + "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" - }], + "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-dev": { "php": ">=5.3.0" }, diff --git a/src/ProjectHoneyPot.php b/src/ProjectHoneyPot.php index 613b5f1..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 From 053fe5e75e450f4a12f17e6fdac455bd1dafc9e8 Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Tue, 9 Jan 2018 00:19:26 -0600 Subject: [PATCH 2/6] Changes to get older and newer tests running --- .travis.yml | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 92dc405..b9edc08 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,24 +1,32 @@ language: php +dist: trusty +sudo: required -php: - - 5.3 - - 5.4 - - 5.5 - - 5.6 - - 7.0 - - 7.1 - - 7.2 - - hhvm +matrix: + include: + - php: 5.3 + dist: precise + - php: 5.4 + - php: 5.5 + - php: 5.6 + - php: 7.0 + - php: 7.1 + - php: 7.2 + - php: hhvm + env: HHVM=true install: - composer install + - if [[ $HHVM == true ]]; then composer require "phpunit/phpunit:5.7"; fi before_script: - mkdir -p build/logs - cd tests script: - - phpunit --colors --coverage-clover /home/travis/build/joshtronic/php-projecthoneypot/build/logs/clover.xml . + - if [[ $HHVM == true ]]; then ../vendor/bin/phpunit --colors --coverage-clover ../build/logs/clover.xml .; fi + - if [[ $HHVM != true ]]; then phpunit --colors --coverage-clover ../build/logs/clover.xml .; fi after_success: - - php ../vendor/bin/coveralls --config ../.coveralls.yml -v + - cd .. + - php vendor/bin/coveralls --config .coveralls.yml -v From c83f8a49140b14ee1c07ea27c7e0a7edd2beb61b Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Tue, 9 Jan 2018 00:26:46 -0600 Subject: [PATCH 3/6] Pin coveralls version --- composer.json | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 82637be..7a4e85b 100644 --- a/composer.json +++ b/composer.json @@ -15,8 +15,8 @@ "license": "MIT", "authors": [ { - "name": "Josh Sherman", - "email": "hello@joshtronic.com", + "name": "Josh Sherman", + "email": "hello@joshtronic.com", "homepage": "https://joshtronic.com" } ], @@ -24,9 +24,11 @@ "php": ">=5.3.0" }, "require-dev": { - "satooshi/php-coveralls": "dev-master" + "satooshi/php-coveralls": "~1.0" }, "autoload": { - "psr-4": {"joshtronic\\": "src/"} + "psr-4": { + "joshtronic\\": "src/" + } } } From 83250394b09c59aed0bb99e725cc0b7139f34a92 Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Sun, 14 Jan 2018 22:56:33 -0600 Subject: [PATCH 4/6] Alias TestCase and some cleanup --- tests/ProjectHoneyPotTest.php | 84 +++++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 33 deletions(-) diff --git a/tests/ProjectHoneyPotTest.php b/tests/ProjectHoneyPotTest.php index 38128db..508ba58 100644 --- a/tests/ProjectHoneyPotTest.php +++ b/tests/ProjectHoneyPotTest.php @@ -2,6 +2,13 @@ require_once '../src/ProjectHoneyPot.php'; +if ( + !class_exists('\PHPUnit_Framework_TestCase') + && class_exists('\PHPUnit\Framework\TestCase') +) { + class_alias('\PHPUnit\Framework\TestCase', '\PHPUnit_Framework_TestCase'); +} + class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase { /** @@ -31,9 +38,10 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase 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')); } @@ -46,9 +54,10 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase 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'); @@ -63,9 +72,10 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase 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'); @@ -80,9 +90,10 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase 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'); @@ -97,9 +108,10 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase 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'); @@ -117,9 +129,10 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase 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'); @@ -137,9 +150,10 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase 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'); @@ -157,9 +171,10 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase 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'); @@ -177,9 +192,10 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase 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'); @@ -197,9 +213,10 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase 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'); @@ -217,9 +234,10 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase 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')); } From 805b303a0429533cee4c351a1395e7c9054b5aec Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Sun, 14 Jan 2018 23:11:11 -0600 Subject: [PATCH 5/6] Conditional mock method --- tests/ProjectHoneyPotTest.php | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/tests/ProjectHoneyPotTest.php b/tests/ProjectHoneyPotTest.php index 508ba58..bc8011a 100644 --- a/tests/ProjectHoneyPotTest.php +++ b/tests/ProjectHoneyPotTest.php @@ -9,6 +9,12 @@ if ( class_alias('\PHPUnit\Framework\TestCase', '\PHPUnit_Framework_TestCase'); } +$createMock = 'createMock'; + +if (version_compare(PHPUnit_Runner_Version::id(), '5.4', '<=')) { + $createMock = 'getMock'; +} + class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase { /** @@ -32,7 +38,7 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase public function testMissingResults() { - $mock = $this->getMock( + $mock = $this->$createMock( 'joshtronic\ProjectHoneyPot', array('dns_get_record'), array('foobarfoobar') @@ -48,7 +54,7 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase public function testCategory0() { - $mock = $this->getMock( + $mock = $this->$createMock( 'joshtronic\ProjectHoneyPot', array('dns_get_record'), array('foobarfoobar') @@ -66,7 +72,7 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase public function testCategory1() { - $mock = $this->getMock( + $mock = $this->$createMock( 'joshtronic\ProjectHoneyPot', array('dns_get_record'), array('foobarfoobar') @@ -84,7 +90,7 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase public function testCategory2() { - $mock = $this->getMock( + $mock = $this->$createMock( 'joshtronic\ProjectHoneyPot', array('dns_get_record'), array('foobarfoobar') @@ -102,7 +108,7 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase public function testCategory3() { - $mock = $this->getMock( + $mock = $this->$createMock( 'joshtronic\ProjectHoneyPot', array('dns_get_record'), array('foobarfoobar') @@ -123,7 +129,7 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase public function testCategory4() { - $mock = $this->getMock( + $mock = $this->$createMock( 'joshtronic\ProjectHoneyPot', array('dns_get_record'), array('foobarfoobar') @@ -144,7 +150,7 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase public function testCategory5() { - $mock = $this->getMock( + $mock = $this->$createMock( 'joshtronic\ProjectHoneyPot', array('dns_get_record'), array('foobarfoobar') @@ -165,7 +171,7 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase public function testCategory6() { - $mock = $this->getMock( + $mock = $this->$createMock( 'joshtronic\ProjectHoneyPot', array('dns_get_record'), array('foobarfoobar') @@ -186,7 +192,7 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase public function testCategory7() { - $mock = $this->getMock( + $mock = $this->$createMock( 'joshtronic\ProjectHoneyPot', array('dns_get_record'), array('foobarfoobar') @@ -207,7 +213,7 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase public function testCategoryDefault() { - $mock = $this->getMock( + $mock = $this->$createMock( 'joshtronic\ProjectHoneyPot', array('dns_get_record'), array('foobarfoobar') @@ -228,7 +234,7 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase public function testWithout127() { - $mock = $this->getMock( + $mock = $this->$createMock( 'joshtronic\ProjectHoneyPot', array('dns_get_record'), array('foobarfoobar') From 90ba4df30848922ec2e21a241ae1b610160959a2 Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Sun, 26 Jan 2020 17:23:06 -0600 Subject: [PATCH 6/6] ci: add newer PHP versions Seems I had started this a while back and never actually finished. Bumped the copyright years and added a funding and git ignore file. Redid the Travis configuration based on my more recent experiences with testing multiple PHP versions. Updated the development dependencies and added a configuration file for PHPUnit. --- .gitignore | 4 ++++ .travis.yml | 26 ++++++++++++++-------- FUNDING.yml | 1 + LICENSE | 2 +- composer.json | 61 +++++++++++++++++++++++++-------------------------- phpunit.xml | 23 +++++++++++++++++++ 6 files changed, 76 insertions(+), 41 deletions(-) create mode 100644 .gitignore create mode 100644 FUNDING.yml create mode 100644 phpunit.xml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a2144a3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +composer.lock +composer.phar +.phpunit.result.cache +/vendor/ diff --git a/.travis.yml b/.travis.yml index b9edc08..36d3649 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: php -dist: trusty +dist: bionic sudo: required matrix: @@ -7,26 +7,34 @@ matrix: - 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: hhvm - env: HHVM=true + - php: 7.3 + - php: 7.4 + env: COVERAGE=true + - php: nightly + allow_failures: + - php: nightly install: + - php --version - composer install - - if [[ $HHVM == true ]]; then composer require "phpunit/phpunit:5.7"; fi before_script: - mkdir -p build/logs - - cd tests script: - - if [[ $HHVM == true ]]; then ../vendor/bin/phpunit --colors --coverage-clover ../build/logs/clover.xml .; fi - - if [[ $HHVM != true ]]; then phpunit --colors --coverage-clover ../build/logs/clover.xml .; fi + - vendor/bin/phpunit --coverage-clover build/logs/clover.xml after_success: - - cd .. - - php vendor/bin/coveralls --config .coveralls.yml -v + - | + if [[ $COVERAGE ]]; then + travis_retry php vendor/bin/php-coveralls --config .coveralls.yml -v + fi diff --git a/FUNDING.yml b/FUNDING.yml new file mode 100644 index 0000000..8b5faa1 --- /dev/null +++ b/FUNDING.yml @@ -0,0 +1 @@ +patreon: joshtronic diff --git a/LICENSE b/LICENSE index 714cd64..22de71d 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2012, 2013, 2014, 2015, 2016, 2017, 2018 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 7a4e85b..87ebba0 100644 --- a/composer.json +++ b/composer.json @@ -1,34 +1,33 @@ { - "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-dev": { - "php": ">=5.3.0" - }, - "require-dev": { - "satooshi/php-coveralls": "~1.0" - }, - "autoload": { - "psr-4": { - "joshtronic\\": "src/" - } + "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 new file mode 100644 index 0000000..6eaac53 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,23 @@ + + + + + tests + + + + + ./src + + +