Tests are now compliant with php-cs-fixer (CamelCase for method, phpdoc valid)
This commit is contained in:
@@ -1,20 +1,22 @@
|
||||
<?php
|
||||
|
||||
/** DomFramework - Tests
|
||||
* @package domframework
|
||||
* @author Dominique Fournier <dominique@fournier38.fr>
|
||||
* @license BSD
|
||||
*/
|
||||
/**
|
||||
* DomFramework - Tests
|
||||
* @package domframework
|
||||
* @author Dominique Fournier <dominique@fournier38.fr>
|
||||
* @license BSD
|
||||
*/
|
||||
|
||||
namespace Domframework\Tests;
|
||||
|
||||
use Domframework\Spfcheck;
|
||||
|
||||
/** Test the Spfcheck tools
|
||||
*/
|
||||
/**
|
||||
* Test the Spfcheck tools
|
||||
*/
|
||||
class SpfcheckTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function test_getRecords_NoSPF()
|
||||
public function testGetRecordsNoSPF()
|
||||
{
|
||||
$this->expectException(
|
||||
"Exception",
|
||||
@@ -26,18 +28,18 @@ class SpfcheckTest extends \PHPUnit_Framework_TestCase
|
||||
$res = $spfcheck->getRecords("notfound.tester.fournier38.fr");
|
||||
}
|
||||
|
||||
public function test_getRecords_SPFReject()
|
||||
public function testGetRecordsSPFReject()
|
||||
{
|
||||
$spfcheck = new Spfcheck();
|
||||
$res = $spfcheck->getRecords("reject.spf.tester.fournier38.fr");
|
||||
$this->assertSame(
|
||||
$res,
|
||||
array ("reject.spf.tester.fournier38.fr" =>
|
||||
array ("-all" => array ()))
|
||||
["reject.spf.tester.fournier38.fr" =>
|
||||
["-all" => []]]
|
||||
);
|
||||
}
|
||||
|
||||
public function test_getRecords_Loop()
|
||||
public function testGetRecordsLoop()
|
||||
{
|
||||
$this->expectException(
|
||||
"Exception",
|
||||
@@ -46,267 +48,267 @@ class SpfcheckTest extends \PHPUnit_Framework_TestCase
|
||||
);
|
||||
$spfcheck = new Spfcheck();
|
||||
$res = $spfcheck->getRecords("loop.spf.tester.fournier38.fr");
|
||||
$this->assertSame($res, array ());
|
||||
$this->assertSame($res, []);
|
||||
}
|
||||
|
||||
public function test_getRecords_Include_emptyInclude()
|
||||
public function testGetRecordsIncludeEmptyInclude()
|
||||
{
|
||||
$spfcheck = new Spfcheck();
|
||||
$res = $spfcheck->getRecords("includeempty.spf.tester.fournier38.fr");
|
||||
$this->assertSame(
|
||||
$res,
|
||||
array ("includeempty.spf.tester.fournier38.fr" =>
|
||||
array ("include:" => array (), "-all" => array ()))
|
||||
["includeempty.spf.tester.fournier38.fr" =>
|
||||
["include:" => [], "-all" => []]]
|
||||
);
|
||||
}
|
||||
|
||||
public function test_getRecords_Redirect_emptyRedirect()
|
||||
public function testGetRecordsRedirectEmptyRedirect()
|
||||
{
|
||||
$spfcheck = new Spfcheck();
|
||||
$res = $spfcheck->getRecords("redirectempty.spf.tester.fournier38.fr");
|
||||
$this->assertSame(
|
||||
$res,
|
||||
array ("redirectempty.spf.tester.fournier38.fr" =>
|
||||
array ("redirect=" => array (), "-all" => array ()))
|
||||
["redirectempty.spf.tester.fournier38.fr" =>
|
||||
["redirect=" => [], "-all" => []]]
|
||||
);
|
||||
}
|
||||
|
||||
public function test_getRecords_MX_emptyMX()
|
||||
public function testGetRecordsMXEmptyMX()
|
||||
{
|
||||
$spfcheck = new Spfcheck();
|
||||
$res = $spfcheck->getRecords("mx.spf.tester.fournier38.fr");
|
||||
$this->assertSame(
|
||||
$res,
|
||||
array ("mx.spf.tester.fournier38.fr" =>
|
||||
array ("mx" => array (), "-all" => array ()))
|
||||
["mx.spf.tester.fournier38.fr" =>
|
||||
["mx" => [], "-all" => []]]
|
||||
);
|
||||
}
|
||||
|
||||
public function test_getRecords_MX_validMX()
|
||||
public function testGetRecordsMXValidMX()
|
||||
{
|
||||
$spfcheck = new Spfcheck();
|
||||
$res = $spfcheck->getRecords("mxvalid.spf.tester.fournier38.fr");
|
||||
$this->assertSame(
|
||||
$res,
|
||||
array ("mxvalid.spf.tester.fournier38.fr" => array (
|
||||
"mx:tester.fournier38.fr" => array (
|
||||
["mxvalid.spf.tester.fournier38.fr" => [
|
||||
"mx:tester.fournier38.fr" => [
|
||||
"2a01:e0a:2a7:9cd1::103",
|
||||
"2a01:e0a:392:ab60::206",
|
||||
"82.64.75.195",
|
||||
"82.66.67.64"),
|
||||
"-all" => array ()))
|
||||
"82.66.67.64"],
|
||||
"-all" => []]]
|
||||
);
|
||||
}
|
||||
|
||||
public function test_getRecords_A_emptyA()
|
||||
public function testGetRecordsAEmptyA()
|
||||
{
|
||||
$spfcheck = new Spfcheck();
|
||||
$res = $spfcheck->getRecords("a.spf.tester.fournier38.fr");
|
||||
$this->assertSame(
|
||||
$res,
|
||||
array ("a.spf.tester.fournier38.fr" =>
|
||||
array ("a" => array (), "-all" => array ()))
|
||||
["a.spf.tester.fournier38.fr" =>
|
||||
["a" => [], "-all" => []]]
|
||||
);
|
||||
}
|
||||
|
||||
public function test_getRecords_A_validA()
|
||||
public function testGetRecordsAValidA()
|
||||
{
|
||||
$spfcheck = new Spfcheck();
|
||||
$res = $spfcheck->getRecords("avalid.spf.tester.fournier38.fr");
|
||||
$this->assertSame(
|
||||
$res,
|
||||
array ("avalid.spf.tester.fournier38.fr" => array (
|
||||
"a:tester.fournier38.fr" => array (
|
||||
["avalid.spf.tester.fournier38.fr" => [
|
||||
"a:tester.fournier38.fr" => [
|
||||
"2a01:e0a:2a7:9cd1::100",
|
||||
"82.64.75.195",),
|
||||
"-all" => array ()))
|
||||
"82.64.75.195",],
|
||||
"-all" => []]]
|
||||
);
|
||||
}
|
||||
|
||||
public function test_getRecords_IP4_emptyIP4()
|
||||
public function testGetRecordsIP4EmptyIP4()
|
||||
{
|
||||
$spfcheck = new Spfcheck();
|
||||
$res = $spfcheck->getRecords("ip4empty.spf.tester.fournier38.fr");
|
||||
$this->assertSame(
|
||||
$res,
|
||||
array ("ip4empty.spf.tester.fournier38.fr" => array (
|
||||
"ip4:" => array (),
|
||||
"-all" => array ()))
|
||||
["ip4empty.spf.tester.fournier38.fr" => [
|
||||
"ip4:" => [],
|
||||
"-all" => []]]
|
||||
);
|
||||
}
|
||||
|
||||
public function test_getRecords_IP4_invalidIP4()
|
||||
public function testGetRecordsIP4InvalidIP4()
|
||||
{
|
||||
$spfcheck = new Spfcheck();
|
||||
$res = $spfcheck->getRecords("ip4invalid.spf.tester.fournier38.fr");
|
||||
$this->assertSame(
|
||||
$res,
|
||||
array ("ip4invalid.spf.tester.fournier38.fr" => array (
|
||||
"ip4:0::1" => array (),
|
||||
"-all" => array ()))
|
||||
["ip4invalid.spf.tester.fournier38.fr" => [
|
||||
"ip4:0::1" => [],
|
||||
"-all" => []]]
|
||||
);
|
||||
}
|
||||
|
||||
public function test_getRecords_IP4_validIP4()
|
||||
public function testGetRecordsIP4ValidIP4()
|
||||
{
|
||||
$spfcheck = new Spfcheck();
|
||||
$res = $spfcheck->getRecords("ip4valid.spf.tester.fournier38.fr");
|
||||
$this->assertSame(
|
||||
$res,
|
||||
array ("ip4valid.spf.tester.fournier38.fr" => array (
|
||||
"ip4:192.168.1.1" => array ("192.168.1.1"),
|
||||
"-all" => array ()))
|
||||
["ip4valid.spf.tester.fournier38.fr" => [
|
||||
"ip4:192.168.1.1" => ["192.168.1.1"],
|
||||
"-all" => []]]
|
||||
);
|
||||
}
|
||||
|
||||
public function test_getRecords_IP6_emptyIP6()
|
||||
public function testGetRecordsIP6EmptyIP6()
|
||||
{
|
||||
$spfcheck = new Spfcheck();
|
||||
$res = $spfcheck->getRecords("ip6empty.spf.tester.fournier38.fr");
|
||||
$this->assertSame(
|
||||
$res,
|
||||
array ("ip6empty.spf.tester.fournier38.fr" => array (
|
||||
"ip6:" => array (),
|
||||
"-all" => array ()))
|
||||
["ip6empty.spf.tester.fournier38.fr" => [
|
||||
"ip6:" => [],
|
||||
"-all" => []]]
|
||||
);
|
||||
}
|
||||
|
||||
public function test_getRecords_IP6_invalidIP6()
|
||||
public function testGetRecordsIP6InvalidIP6()
|
||||
{
|
||||
$spfcheck = new Spfcheck();
|
||||
$res = $spfcheck->getRecords("ip6invalid.spf.tester.fournier38.fr");
|
||||
$this->assertSame(
|
||||
$res,
|
||||
array ("ip6invalid.spf.tester.fournier38.fr" => array (
|
||||
"ip6:192.168.1.1" => array (),
|
||||
"-all" => array ()))
|
||||
["ip6invalid.spf.tester.fournier38.fr" => [
|
||||
"ip6:192.168.1.1" => [],
|
||||
"-all" => []]]
|
||||
);
|
||||
}
|
||||
|
||||
public function test_getRecords_IP6_validIP6()
|
||||
public function testGetRecordsIP6ValidIP6()
|
||||
{
|
||||
$spfcheck = new Spfcheck();
|
||||
$res = $spfcheck->getRecords("ip6valid.spf.tester.fournier38.fr");
|
||||
$this->assertSame(
|
||||
$res,
|
||||
array ("ip6valid.spf.tester.fournier38.fr" => array (
|
||||
"ip6:0::1" => array ("0::1"),
|
||||
"-all" => array ()))
|
||||
["ip6valid.spf.tester.fournier38.fr" => [
|
||||
"ip6:0::1" => ["0::1"],
|
||||
"-all" => []]]
|
||||
);
|
||||
}
|
||||
|
||||
public function test_getRecords_PTR()
|
||||
public function testGetRecordsPTR()
|
||||
{
|
||||
$spfcheck = new Spfcheck();
|
||||
$res = $spfcheck->getRecords("ptrvalid.spf.tester.fournier38.fr");
|
||||
$this->assertSame(
|
||||
$res,
|
||||
array ("ptrvalid.spf.tester.fournier38.fr" => array (
|
||||
"ptr" => array (),
|
||||
"-all" => array ()))
|
||||
["ptrvalid.spf.tester.fournier38.fr" => [
|
||||
"ptr" => [],
|
||||
"-all" => []]]
|
||||
);
|
||||
}
|
||||
|
||||
public function test_getRecords_All_Multiple()
|
||||
public function testGetRecordsAllMultiple()
|
||||
{
|
||||
$spfcheck = new Spfcheck();
|
||||
$res = $spfcheck->getRecords("allmultiple.spf.tester.fournier38.fr");
|
||||
$this->assertSame(
|
||||
$res,
|
||||
array ("allmultiple.spf.tester.fournier38.fr" => array (
|
||||
"+all" => array (),
|
||||
"-all" => array ()))
|
||||
["allmultiple.spf.tester.fournier38.fr" => [
|
||||
"+all" => [],
|
||||
"-all" => []]]
|
||||
);
|
||||
}
|
||||
|
||||
public function test_getRecords_All_NotEnd()
|
||||
public function testGetRecordsAllNotEnd()
|
||||
{
|
||||
$spfcheck = new Spfcheck();
|
||||
$res = $spfcheck->getRecords("allnotend.spf.tester.fournier38.fr");
|
||||
$this->assertSame(
|
||||
$res,
|
||||
array ("allnotend.spf.tester.fournier38.fr" => array (
|
||||
"+all" => array (),
|
||||
"mx" => array ()))
|
||||
["allnotend.spf.tester.fournier38.fr" => [
|
||||
"+all" => [],
|
||||
"mx" => []]]
|
||||
);
|
||||
}
|
||||
|
||||
public function test_getRecords_All_NotSet()
|
||||
public function testGetRecordsAllNotSet()
|
||||
{
|
||||
$spfcheck = new Spfcheck();
|
||||
$res = $spfcheck->getRecords("allnotset.spf.tester.fournier38.fr");
|
||||
$this->assertSame(
|
||||
$res,
|
||||
array ("allnotset.spf.tester.fournier38.fr" => array (
|
||||
"mx" => array ()))
|
||||
["allnotset.spf.tester.fournier38.fr" => [
|
||||
"mx" => []]]
|
||||
);
|
||||
}
|
||||
|
||||
public function test_wideIPRange()
|
||||
public function testWideIPRange()
|
||||
{
|
||||
$spfcheck = new Spfcheck();
|
||||
$spfcheck->getRecords("wide.spf.tester.fournier38.fr");
|
||||
$res = $spfcheck->getErrors();
|
||||
$this->assertSame(
|
||||
$res,
|
||||
array ("wide.spf.tester.fournier38.fr" => array (
|
||||
["wide.spf.tester.fournier38.fr" => [
|
||||
"ip4:213.131.32.0/2" => "Invalid ip4 set for domain 'wide.spf.tester.fournier38.fr' : Mask '/2' too wide",
|
||||
"ip6:2001::/20" => "Invalid ip6 set for domain 'wide.spf.tester.fournier38.fr' : Mask '/20' too wide"
|
||||
))
|
||||
]]
|
||||
);
|
||||
}
|
||||
|
||||
public function test_recordsWithPlus()
|
||||
public function testRecordsWithPlus()
|
||||
{
|
||||
$spfcheck = new Spfcheck();
|
||||
$res = $spfcheck->getRecords("plus.spf.tester.fournier38.fr");
|
||||
$this->assertSame(
|
||||
$res,
|
||||
array ("plus.spf.tester.fournier38.fr" => array (
|
||||
"+a" => array (),
|
||||
"+mx" => array (),
|
||||
"+ip4:178.33.236.5" => array ("178.33.236.5"),
|
||||
"-ip4:137.74.69.64" => array ("137.74.69.64"),
|
||||
"+ip4:51.254.45.81" => array ("51.254.45.81"),
|
||||
"-all" => array (),
|
||||
))
|
||||
["plus.spf.tester.fournier38.fr" => [
|
||||
"+a" => [],
|
||||
"+mx" => [],
|
||||
"+ip4:178.33.236.5" => ["178.33.236.5"],
|
||||
"-ip4:137.74.69.64" => ["137.74.69.64"],
|
||||
"+ip4:51.254.45.81" => ["51.254.45.81"],
|
||||
"-all" => [],
|
||||
]]
|
||||
);
|
||||
}
|
||||
|
||||
public function test_getRecords_Unknown()
|
||||
public function testGetRecordsUnknown()
|
||||
{
|
||||
$spfcheck = new Spfcheck();
|
||||
$res = $spfcheck->getRecords("unknown.spf.tester.fournier38.fr");
|
||||
$this->assertSame(
|
||||
$res,
|
||||
array ("unknown.spf.tester.fournier38.fr" => array (
|
||||
"unknown" => array (),
|
||||
"-all" => array ()))
|
||||
["unknown.spf.tester.fournier38.fr" => [
|
||||
"unknown" => [],
|
||||
"-all" => []]]
|
||||
);
|
||||
}
|
||||
|
||||
public function test_ipCheckToSPF_OK_inA()
|
||||
public function testIpCheckToSPFOKInA()
|
||||
{
|
||||
$spfcheck = new Spfcheck();
|
||||
$res = $spfcheck->ipCheckToSPF("plus.spf.tester.fournier38.fr", "178.33.236.5");
|
||||
$this->assertSame($res, "PASS");
|
||||
}
|
||||
|
||||
public function test_ipCheckToSPF_FAIL_inALL()
|
||||
public function testIpCheckToSPFFAILInALL()
|
||||
{
|
||||
$spfcheck = new Spfcheck();
|
||||
$res = $spfcheck->ipCheckToSPF("plus.spf.tester.fournier38.fr", "1.3.6.5");
|
||||
$this->assertSame($res, "FAIL");
|
||||
}
|
||||
|
||||
public function test_ipCheckToSPF_OK_inALL()
|
||||
public function testIpCheckToSPFOKInALL()
|
||||
{
|
||||
$spfcheck = new Spfcheck();
|
||||
$res = $spfcheck->ipCheckToSPF("plus.spf.tester.fournier38.fr", "1.3.6.5");
|
||||
$this->assertSame($res, "FAIL");
|
||||
}
|
||||
|
||||
public function test_ipCheckToSPF_FAIL_inIP4()
|
||||
public function testIpCheckToSPFFAILInIP4()
|
||||
{
|
||||
$spfcheck = new Spfcheck();
|
||||
$res = $spfcheck->ipCheckToSPF("plus.spf.tester.fournier38.fr", "137.74.69.64");
|
||||
|
||||
Reference in New Issue
Block a user