From 7ea1bd219f2407aeda64b88a60d1f316348fa05d Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Tue, 9 Jan 2018 00:15:18 -0600 Subject: [PATCH 1/9] 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/9] 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/9] 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/9] 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/9] 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/9] 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 + + + From 340711b331c7eb33675c4540f4f125ccc2e443d8 Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Mon, 2 Mar 2020 20:55:28 -0600 Subject: [PATCH 7/9] docs: add funding --- FUNDING.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 FUNDING.yml diff --git a/FUNDING.yml b/FUNDING.yml new file mode 100644 index 0000000..9396c28 --- /dev/null +++ b/FUNDING.yml @@ -0,0 +1 @@ +github: joshtronic From da6dd242a01d66591990ceae6e72024977abb4ae Mon Sep 17 00:00:00 2001 From: peter279k Date: Sat, 2 Jan 2021 02:05:43 +0800 Subject: [PATCH 8/9] Replace Travis CI with GitHub Actions --- .coveralls.yml | 1 - .github/workflows/test.yml | 29 ++++++++ .gitignore | 4 ++ .travis.yml | 26 ------- composer.json | 7 +- phpunit.xml | 24 +++++++ tests/ProjectHoneyPotTest.php | 124 ++++++++++++++++------------------ 7 files changed, 120 insertions(+), 95 deletions(-) delete mode 100644 .coveralls.yml create mode 100644 .github/workflows/test.yml create mode 100644 .gitignore delete mode 100644 .travis.yml create mode 100644 phpunit.xml diff --git a/.coveralls.yml b/.coveralls.yml deleted file mode 100644 index 9160059..0000000 --- a/.coveralls.yml +++ /dev/null @@ -1 +0,0 @@ -service_name: travis-ci diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..ddf8b8d --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,29 @@ +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/.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 deleted file mode 100644 index 8bfb40e..0000000 --- a/.travis.yml +++ /dev/null @@ -1,26 +0,0 @@ -language: php - -php: - - 5.3 - - 5.4 - - 5.5 - - 5.6 - - hhvm - - hhvm-nightly - -matrix: - allow_failures: - - php: hhvm-nightly - -install: - - composer install - -before_script: - - mkdir -p build/logs - - cd tests - -script: - - phpunit --colors --coverage-clover /home/travis/build/joshtronic/php-projecthoneypot/build/logs/clover.xml . - -after_success: - - php ../vendor/bin/coveralls --config ../.coveralls.yml -v diff --git a/composer.json b/composer.json index 8bef239..ed5854c 100644 --- a/composer.json +++ b/composer.json @@ -11,13 +11,16 @@ "email": "hello@joshtronic.com", "homepage": "http://joshtronic.com" }], - "require-dev": { + "require": { "php": ">=5.3.0" }, "require-dev": { - "satooshi/php-coveralls": "dev-master" + "phpunit/phpunit": "^4.8.36 || ^9.0" }, "autoload": { "psr-4": {"joshtronic\\": "src/"} + }, + "autoload-dev": { + "psr-4": {"joshtronic\\Tests\\": "tests/"} } } diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..82cbb00 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,24 @@ + + + + + tests + + + + + ./src + + + diff --git a/tests/ProjectHoneyPotTest.php b/tests/ProjectHoneyPotTest.php index 38128db..9c5e103 100644 --- a/tests/ProjectHoneyPotTest.php +++ b/tests/ProjectHoneyPotTest.php @@ -1,21 +1,22 @@ assertSame('You must specify a valid API key.', $e->getMessage()); + } } public function testInvalidIP() { - $object = new joshtronic\ProjectHoneyPot('foobarfoobar'); + $object = new ProjectHoneyPot('foobarfoobar'); $this->assertEquals( array('error' => 'Invalid IP address.'), @@ -25,11 +26,10 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase public function testMissingResults() { - $mock = $this->getMock( - 'joshtronic\ProjectHoneyPot', - array('dns_get_record'), - array('foobarfoobar') - ); + $mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot') + ->setConstructorArgs(array('foobarfoobar')) + ->setMethods(array('dns_get_record')) + ->getMock(); $mock->expects($this->once()) ->method('dns_get_record') @@ -40,11 +40,10 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase public function testCategory0() { - $mock = $this->getMock( - 'joshtronic\ProjectHoneyPot', - array('dns_get_record'), - array('foobarfoobar') - ); + $mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot') + ->setConstructorArgs(array('foobarfoobar')) + ->setMethods(array('dns_get_record')) + ->getMock(); $mock->expects($this->once()) ->method('dns_get_record') @@ -57,11 +56,10 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase public function testCategory1() { - $mock = $this->getMock( - 'joshtronic\ProjectHoneyPot', - array('dns_get_record'), - array('foobarfoobar') - ); + $mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot') + ->setConstructorArgs(array('foobarfoobar')) + ->setMethods(array('dns_get_record')) + ->getMock(); $mock->expects($this->once()) ->method('dns_get_record') @@ -74,11 +72,10 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase public function testCategory2() { - $mock = $this->getMock( - 'joshtronic\ProjectHoneyPot', - array('dns_get_record'), - array('foobarfoobar') - ); + $mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot') + ->setConstructorArgs(array('foobarfoobar')) + ->setMethods(array('dns_get_record')) + ->getMock(); $mock->expects($this->once()) ->method('dns_get_record') @@ -91,11 +88,10 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase public function testCategory3() { - $mock = $this->getMock( - 'joshtronic\ProjectHoneyPot', - array('dns_get_record'), - array('foobarfoobar') - ); + $mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot') + ->setConstructorArgs(array('foobarfoobar')) + ->setMethods(array('dns_get_record')) + ->getMock(); $mock->expects($this->once()) ->method('dns_get_record') @@ -111,11 +107,10 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase public function testCategory4() { - $mock = $this->getMock( - 'joshtronic\ProjectHoneyPot', - array('dns_get_record'), - array('foobarfoobar') - ); + $mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot') + ->setConstructorArgs(array('foobarfoobar')) + ->setMethods(array('dns_get_record')) + ->getMock(); $mock->expects($this->once()) ->method('dns_get_record') @@ -131,11 +126,10 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase public function testCategory5() { - $mock = $this->getMock( - 'joshtronic\ProjectHoneyPot', - array('dns_get_record'), - array('foobarfoobar') - ); + $mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot') + ->setConstructorArgs(array('foobarfoobar')) + ->setMethods(array('dns_get_record')) + ->getMock(); $mock->expects($this->once()) ->method('dns_get_record') @@ -151,11 +145,10 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase public function testCategory6() { - $mock = $this->getMock( - 'joshtronic\ProjectHoneyPot', - array('dns_get_record'), - array('foobarfoobar') - ); + $mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot') + ->setConstructorArgs(array('foobarfoobar')) + ->setMethods(array('dns_get_record')) + ->getMock(); $mock->expects($this->once()) ->method('dns_get_record') @@ -171,11 +164,10 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase public function testCategory7() { - $mock = $this->getMock( - 'joshtronic\ProjectHoneyPot', - array('dns_get_record'), - array('foobarfoobar') - ); + $mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot') + ->setConstructorArgs(array('foobarfoobar')) + ->setMethods(array('dns_get_record')) + ->getMock(); $mock->expects($this->once()) ->method('dns_get_record') @@ -191,11 +183,10 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase public function testCategoryDefault() { - $mock = $this->getMock( - 'joshtronic\ProjectHoneyPot', - array('dns_get_record'), - array('foobarfoobar') - ); + $mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot') + ->setConstructorArgs(array('foobarfoobar')) + ->setMethods(array('dns_get_record')) + ->getMock(); $mock->expects($this->once()) ->method('dns_get_record') @@ -211,11 +202,10 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase public function testWithout127() { - $mock = $this->getMock( - 'joshtronic\ProjectHoneyPot', - array('dns_get_record'), - array('foobarfoobar') - ); + $mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot') + ->setConstructorArgs(array('foobarfoobar')) + ->setMethods(array('dns_get_record')) + ->getMock(); $mock->expects($this->once()) ->method('dns_get_record') @@ -227,9 +217,11 @@ class ProjectHoneyPotTest extends PHPUnit_Framework_TestCase // Doesn't serve much purpose aside from helping achieve 100% coverage public function testDnsGetRecord() { - $object = new joshtronic\ProjectHoneyPot('foobarfoobar'); + $object = new ProjectHoneyPot('foobarfoobar'); - $object->dns_get_record('1.2.3.4'); + $result = $object->dns_get_record('1.2.3.4'); + + $this->assertEquals(array(), $result); } } From d96fdc3120bd0f5dab5d55dda1276c5f01e21e1d Mon Sep 17 00:00:00 2001 From: peter279k Date: Mon, 4 Jan 2021 01:42:44 +0800 Subject: [PATCH 9/9] Resolves issue #2 --- src/ProjectHoneyPot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ProjectHoneyPot.php b/src/ProjectHoneyPot.php index 613b5f1..a82b243 100644 --- a/src/ProjectHoneyPot.php +++ b/src/ProjectHoneyPot.php @@ -122,7 +122,7 @@ class ProjectHoneyPot /** * DNS Get Record * - * Wrapper method for dns_get_record() to allow fo easy mocking of the + * Wrapper method for dns_get_record() to allow for 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. *