Compare commits
7 commits
master
...
developmen
Author | SHA1 | Date | |
---|---|---|---|
932e2ca800 | |||
6a70fd2f26 | |||
5a9b6ec5c8 | |||
ddfe2b126a | |||
ba8f480f5e | |||
5d7000bf8a | |||
ac0903530a |
8 changed files with 262 additions and 158 deletions
1
.coveralls.yml
Normal file
1
.coveralls.yml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
service_name: travis-ci
|
29
.github/workflows/test.yml
vendored
29
.github/workflows/test.yml
vendored
|
@ -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
|
|
40
.travis.yml
Normal file
40
.travis.yml
Normal file
|
@ -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
|
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
||||||
The MIT License (MIT)
|
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
|
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
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
|
@ -1,26 +1,33 @@
|
||||||
{
|
{
|
||||||
"name": "joshtronic/php-projecthoneypot",
|
"name": "joshtronic/php-projecthoneypot",
|
||||||
"description": "PHP Wrapper for Project Honey Pot",
|
"description": "PHP Wrapper for Project Honey Pot",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"keywords": ["project", "honey", "pot", "api", "spam", "spammer"],
|
"keywords": [
|
||||||
|
"project",
|
||||||
|
"honey",
|
||||||
|
"pot",
|
||||||
|
"api",
|
||||||
|
"spam",
|
||||||
|
"spammer"
|
||||||
|
],
|
||||||
"homepage": "https://github.com/joshtronic/php-projecthoneypot",
|
"homepage": "https://github.com/joshtronic/php-projecthoneypot",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"authors": [{
|
"authors": [{
|
||||||
"name": "Josh Sherman",
|
"name": "Josh Sherman",
|
||||||
"email": "hello@joshtronic.com",
|
"email": "hello@joshtronic.com",
|
||||||
"homepage": "http://joshtronic.com"
|
"homepage": "https://joshtronic.com"
|
||||||
}],
|
}],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.3.0"
|
"php": ">=5.3"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^4.8.36 || ^9.0"
|
"php-coveralls/php-coveralls": ">=1",
|
||||||
|
"phpunit/phpunit": ">=4"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {"joshtronic\\": "src/"}
|
"psr-4": {
|
||||||
},
|
"joshtronic\\": "src/"
|
||||||
"autoload-dev": {
|
}
|
||||||
"psr-4": {"joshtronic\\Tests\\": "tests/"}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<phpunit
|
<phpunit
|
||||||
colors="true"
|
colors="true"
|
||||||
bootstrap="./vendor/autoload.php"
|
|
||||||
convertErrorsToExceptions="true"
|
convertErrorsToExceptions="true"
|
||||||
convertNoticesToExceptions="true"
|
convertNoticesToExceptions="true"
|
||||||
convertWarningsToExceptions="true"
|
convertWarningsToExceptions="true"
|
||||||
|
@ -12,7 +11,7 @@
|
||||||
verbose="true"
|
verbose="true"
|
||||||
>
|
>
|
||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite name="Project Honeypot">
|
<testsuite name="Project Honey Pot">
|
||||||
<directory>tests</directory>
|
<directory>tests</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
* Redistribution of these files must retain the above copyright notice.
|
* Redistribution of these files must retain the above copyright notice.
|
||||||
*
|
*
|
||||||
* @author Josh Sherman <hello@joshtronic.com>
|
* @author Josh Sherman <hello@joshtronic.com>
|
||||||
* @copyright Copyright 2012-2015, Josh Sherman
|
* @copyright Copyright 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Josh Sherman
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html
|
* @license http://www.opensource.org/licenses/mit-license.html
|
||||||
* @link https://github.com/joshtronic/php-projecthoneypot
|
* @link https://github.com/joshtronic/php-projecthoneypot
|
||||||
* @link http://www.projecthoneypot.org/httpbl_configure.php
|
* @link http://www.projecthoneypot.org/httpbl_configure.php
|
||||||
|
@ -55,6 +55,8 @@ class ProjectHoneyPot
|
||||||
*/
|
*/
|
||||||
public function query($ip_address)
|
public function query($ip_address)
|
||||||
{
|
{
|
||||||
|
var_Dump('ip addy', $ip_address, filter_var($ip_address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE));
|
||||||
|
|
||||||
// Validates the IP format
|
// Validates the IP format
|
||||||
if (filter_var($ip_address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE)) {
|
if (filter_var($ip_address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE)) {
|
||||||
// Flips the script, err, IP address
|
// Flips the script, err, IP address
|
||||||
|
@ -122,7 +124,7 @@ class ProjectHoneyPot
|
||||||
/**
|
/**
|
||||||
* DNS Get Record
|
* 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
|
* results in our tests. Takes an already reversed IP address and does a
|
||||||
* DNS lookup for A records against the http:BL API.
|
* DNS lookup for A records against the http:BL API.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,22 +1,53 @@
|
||||||
<?php
|
<?php
|
||||||
namespace joshtronic\Tests;
|
require_once './src/ProjectHoneyPot.php';
|
||||||
use joshtronic\ProjectHoneyPot;
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
|
|
||||||
class ProjectHoneyPotTest extends TestCase
|
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
|
||||||
{
|
{
|
||||||
|
public function testCreateMock()
|
||||||
|
{
|
||||||
|
$this->assertTrue(true);
|
||||||
|
|
||||||
|
if (
|
||||||
|
method_exists('PHPUnit_Runner_Version','id')
|
||||||
|
&& version_compare(PHPUnit_Runner_Version::id(), '5.4', '<=')
|
||||||
|
) {
|
||||||
|
return 'getMock';
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'createMock';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Due to version juggling, did this a bit more manually as the
|
||||||
|
// declarations were being removed entirely and I wasn't sure which
|
||||||
|
// versions supported the suggested methods.
|
||||||
public function testInvalidKey()
|
public function testInvalidKey()
|
||||||
{
|
{
|
||||||
|
$threw = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
new ProjectHoneyPot('foo');
|
new joshtronic\ProjectHoneyPot('foo');
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->assertSame('You must specify a valid API key.', $e->getMessage());
|
$threw = true;
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
'You must specify a valid API key.',
|
||||||
|
$e->getMessage(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->assertTrue($threw);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testInvalidIP()
|
public function testInvalidIP()
|
||||||
{
|
{
|
||||||
$object = new ProjectHoneyPot('foobarfoobar');
|
$object = new joshtronic\ProjectHoneyPot('foobarfoobar');
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
array('error' => 'Invalid IP address.'),
|
array('error' => 'Invalid IP address.'),
|
||||||
|
@ -24,28 +55,38 @@ class ProjectHoneyPotTest extends TestCase
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMissingResults()
|
/**
|
||||||
|
* @depends testCreateMock
|
||||||
|
*/
|
||||||
|
public function testMissingResults($createMock)
|
||||||
{
|
{
|
||||||
$mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot')
|
$mock = $this->$createMock('joshtronic\ProjectHoneyPot');
|
||||||
->setConstructorArgs(array('foobarfoobar'))
|
|
||||||
->setMethods(array('dns_get_record'))
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$mock->expects($this->once())
|
$mock
|
||||||
|
->expects($this->once())
|
||||||
->method('dns_get_record')
|
->method('dns_get_record')
|
||||||
|
->with($this->equalTo('4.3.2.1'))
|
||||||
->will($this->returnValue('foo'));
|
->will($this->returnValue('foo'));
|
||||||
|
|
||||||
$this->assertFalse($mock->query('1.2.3.4'));
|
var_dump($mock->query('1.2.3.4'));
|
||||||
|
|
||||||
|
$this->assertNull($mock->query('1.2.3.4'));
|
||||||
|
// $this->assertFalse($mock->query('1.2.3.4'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCategory0()
|
/**
|
||||||
|
* @depends testCreateMock
|
||||||
|
*/
|
||||||
|
public function testCategory0($createMock)
|
||||||
{
|
{
|
||||||
$mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot')
|
$mock = $this->$createMock(
|
||||||
->setConstructorArgs(array('foobarfoobar'))
|
'joshtronic\ProjectHoneyPot',
|
||||||
->setMethods(array('dns_get_record'))
|
array('dns_get_record'),
|
||||||
->getMock();
|
array('foobarfoobar')
|
||||||
|
);
|
||||||
|
|
||||||
$mock->expects($this->once())
|
$mock
|
||||||
|
->expects($this->once())
|
||||||
->method('dns_get_record')
|
->method('dns_get_record')
|
||||||
->will($this->returnValue(array(array('ip' => '127.0.0.0'))));
|
->will($this->returnValue(array(array('ip' => '127.0.0.0'))));
|
||||||
|
|
||||||
|
@ -54,14 +95,19 @@ class ProjectHoneyPotTest extends TestCase
|
||||||
$this->assertEquals(array('Search Engine'), $results['categories']);
|
$this->assertEquals(array('Search Engine'), $results['categories']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCategory1()
|
/**
|
||||||
|
* @depends testCreateMock
|
||||||
|
*/
|
||||||
|
public function testCategory1($createMock)
|
||||||
{
|
{
|
||||||
$mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot')
|
$mock = $this->$createMock(
|
||||||
->setConstructorArgs(array('foobarfoobar'))
|
'joshtronic\ProjectHoneyPot',
|
||||||
->setMethods(array('dns_get_record'))
|
array('dns_get_record'),
|
||||||
->getMock();
|
array('foobarfoobar')
|
||||||
|
);
|
||||||
|
|
||||||
$mock->expects($this->once())
|
$mock
|
||||||
|
->expects($this->once())
|
||||||
->method('dns_get_record')
|
->method('dns_get_record')
|
||||||
->will($this->returnValue(array(array('ip' => '127.0.0.1'))));
|
->will($this->returnValue(array(array('ip' => '127.0.0.1'))));
|
||||||
|
|
||||||
|
@ -70,14 +116,19 @@ class ProjectHoneyPotTest extends TestCase
|
||||||
$this->assertEquals(array('Suspicious'), $results['categories']);
|
$this->assertEquals(array('Suspicious'), $results['categories']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCategory2()
|
/**
|
||||||
|
* @depends testCreateMock
|
||||||
|
*/
|
||||||
|
public function testCategory2($createMock)
|
||||||
{
|
{
|
||||||
$mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot')
|
$mock = $this->$createMock(
|
||||||
->setConstructorArgs(array('foobarfoobar'))
|
'joshtronic\ProjectHoneyPot',
|
||||||
->setMethods(array('dns_get_record'))
|
array('dns_get_record'),
|
||||||
->getMock();
|
array('foobarfoobar')
|
||||||
|
);
|
||||||
|
|
||||||
$mock->expects($this->once())
|
$mock
|
||||||
|
->expects($this->once())
|
||||||
->method('dns_get_record')
|
->method('dns_get_record')
|
||||||
->will($this->returnValue(array(array('ip' => '127.0.0.2'))));
|
->will($this->returnValue(array(array('ip' => '127.0.0.2'))));
|
||||||
|
|
||||||
|
@ -86,14 +137,19 @@ class ProjectHoneyPotTest extends TestCase
|
||||||
$this->assertEquals(array('Harvester'), $results['categories']);
|
$this->assertEquals(array('Harvester'), $results['categories']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCategory3()
|
/**
|
||||||
|
* @depends testCreateMock
|
||||||
|
*/
|
||||||
|
public function testCategory3($createMock)
|
||||||
{
|
{
|
||||||
$mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot')
|
$mock = $this->$createMock(
|
||||||
->setConstructorArgs(array('foobarfoobar'))
|
'joshtronic\ProjectHoneyPot',
|
||||||
->setMethods(array('dns_get_record'))
|
array('dns_get_record'),
|
||||||
->getMock();
|
array('foobarfoobar')
|
||||||
|
);
|
||||||
|
|
||||||
$mock->expects($this->once())
|
$mock
|
||||||
|
->expects($this->once())
|
||||||
->method('dns_get_record')
|
->method('dns_get_record')
|
||||||
->will($this->returnValue(array(array('ip' => '127.0.0.3'))));
|
->will($this->returnValue(array(array('ip' => '127.0.0.3'))));
|
||||||
|
|
||||||
|
@ -105,14 +161,19 @@ class ProjectHoneyPotTest extends TestCase
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCategory4()
|
/**
|
||||||
|
* @depends testCreateMock
|
||||||
|
*/
|
||||||
|
public function testCategory4($createMock)
|
||||||
{
|
{
|
||||||
$mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot')
|
$mock = $this->$createMock(
|
||||||
->setConstructorArgs(array('foobarfoobar'))
|
'joshtronic\ProjectHoneyPot',
|
||||||
->setMethods(array('dns_get_record'))
|
array('dns_get_record'),
|
||||||
->getMock();
|
array('foobarfoobar')
|
||||||
|
);
|
||||||
|
|
||||||
$mock->expects($this->once())
|
$mock
|
||||||
|
->expects($this->once())
|
||||||
->method('dns_get_record')
|
->method('dns_get_record')
|
||||||
->will($this->returnValue(array(array('ip' => '127.0.0.4'))));
|
->will($this->returnValue(array(array('ip' => '127.0.0.4'))));
|
||||||
|
|
||||||
|
@ -124,14 +185,19 @@ class ProjectHoneyPotTest extends TestCase
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCategory5()
|
/**
|
||||||
|
* @depends testCreateMock
|
||||||
|
*/
|
||||||
|
public function testCategory5($createMock)
|
||||||
{
|
{
|
||||||
$mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot')
|
$mock = $this->$createMock(
|
||||||
->setConstructorArgs(array('foobarfoobar'))
|
'joshtronic\ProjectHoneyPot',
|
||||||
->setMethods(array('dns_get_record'))
|
array('dns_get_record'),
|
||||||
->getMock();
|
array('foobarfoobar')
|
||||||
|
);
|
||||||
|
|
||||||
$mock->expects($this->once())
|
$mock
|
||||||
|
->expects($this->once())
|
||||||
->method('dns_get_record')
|
->method('dns_get_record')
|
||||||
->will($this->returnValue(array(array('ip' => '127.0.0.5'))));
|
->will($this->returnValue(array(array('ip' => '127.0.0.5'))));
|
||||||
|
|
||||||
|
@ -143,14 +209,19 @@ class ProjectHoneyPotTest extends TestCase
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCategory6()
|
/**
|
||||||
|
* @depends testCreateMock
|
||||||
|
*/
|
||||||
|
public function testCategory6($createMock)
|
||||||
{
|
{
|
||||||
$mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot')
|
$mock = $this->$createMock(
|
||||||
->setConstructorArgs(array('foobarfoobar'))
|
'joshtronic\ProjectHoneyPot',
|
||||||
->setMethods(array('dns_get_record'))
|
array('dns_get_record'),
|
||||||
->getMock();
|
array('foobarfoobar')
|
||||||
|
);
|
||||||
|
|
||||||
$mock->expects($this->once())
|
$mock
|
||||||
|
->expects($this->once())
|
||||||
->method('dns_get_record')
|
->method('dns_get_record')
|
||||||
->will($this->returnValue(array(array('ip' => '127.0.0.6'))));
|
->will($this->returnValue(array(array('ip' => '127.0.0.6'))));
|
||||||
|
|
||||||
|
@ -162,14 +233,19 @@ class ProjectHoneyPotTest extends TestCase
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCategory7()
|
/**
|
||||||
|
* @depends testCreateMock
|
||||||
|
*/
|
||||||
|
public function testCategory7($createMock)
|
||||||
{
|
{
|
||||||
$mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot')
|
$mock = $this->$createMock(
|
||||||
->setConstructorArgs(array('foobarfoobar'))
|
'joshtronic\ProjectHoneyPot',
|
||||||
->setMethods(array('dns_get_record'))
|
array('dns_get_record'),
|
||||||
->getMock();
|
array('foobarfoobar')
|
||||||
|
);
|
||||||
|
|
||||||
$mock->expects($this->once())
|
$mock
|
||||||
|
->expects($this->once())
|
||||||
->method('dns_get_record')
|
->method('dns_get_record')
|
||||||
->will($this->returnValue(array(array('ip' => '127.0.0.7'))));
|
->will($this->returnValue(array(array('ip' => '127.0.0.7'))));
|
||||||
|
|
||||||
|
@ -181,14 +257,19 @@ class ProjectHoneyPotTest extends TestCase
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCategoryDefault()
|
/**
|
||||||
|
* @depends testCreateMock
|
||||||
|
*/
|
||||||
|
public function testCategoryDefault($createMock)
|
||||||
{
|
{
|
||||||
$mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot')
|
$mock = $this->$createMock(
|
||||||
->setConstructorArgs(array('foobarfoobar'))
|
'joshtronic\ProjectHoneyPot',
|
||||||
->setMethods(array('dns_get_record'))
|
array('dns_get_record'),
|
||||||
->getMock();
|
array('foobarfoobar')
|
||||||
|
);
|
||||||
|
|
||||||
$mock->expects($this->once())
|
$mock
|
||||||
|
->expects($this->once())
|
||||||
->method('dns_get_record')
|
->method('dns_get_record')
|
||||||
->will($this->returnValue(array(array('ip' => '127.0.0.255'))));
|
->will($this->returnValue(array(array('ip' => '127.0.0.255'))));
|
||||||
|
|
||||||
|
@ -200,14 +281,19 @@ class ProjectHoneyPotTest extends TestCase
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWithout127()
|
/**
|
||||||
|
* @depends testCreateMock
|
||||||
|
*/
|
||||||
|
public function testWithout127($createMock)
|
||||||
{
|
{
|
||||||
$mock = $this->getMockBuilder('joshtronic\\ProjectHoneyPot')
|
$mock = $this->$createMock(
|
||||||
->setConstructorArgs(array('foobarfoobar'))
|
'joshtronic\ProjectHoneyPot',
|
||||||
->setMethods(array('dns_get_record'))
|
array('dns_get_record'),
|
||||||
->getMock();
|
array('foobarfoobar')
|
||||||
|
);
|
||||||
|
|
||||||
$mock->expects($this->once())
|
$mock
|
||||||
|
->expects($this->once())
|
||||||
->method('dns_get_record')
|
->method('dns_get_record')
|
||||||
->will($this->returnValue(array(array('ip' => '1.0.0.0'))));
|
->will($this->returnValue(array(array('ip' => '1.0.0.0'))));
|
||||||
|
|
||||||
|
@ -217,11 +303,9 @@ class ProjectHoneyPotTest extends TestCase
|
||||||
// Doesn't serve much purpose aside from helping achieve 100% coverage
|
// Doesn't serve much purpose aside from helping achieve 100% coverage
|
||||||
public function testDnsGetRecord()
|
public function testDnsGetRecord()
|
||||||
{
|
{
|
||||||
$object = new ProjectHoneyPot('foobarfoobar');
|
$object = new joshtronic\ProjectHoneyPot('foobarfoobar');
|
||||||
|
|
||||||
$result = $object->dns_get_record('1.2.3.4');
|
$object->dns_get_record('1.2.3.4');
|
||||||
|
|
||||||
$this->assertEquals(array(), $result);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue