*/ /** Test the spfcheck tools */ class spfcheckTest extends PHPUnit_Framework_TestCase { public function test_getRecords_NoSPF () { $this->expectException ("Exception", "Can not find a valid SPF TXT entry in DNS for domain ". "'notfound.tester.fournier38.fr'", 403); $spfcheck = new spfcheck (); $res = $spfcheck->getRecords ("notfound.tester.fournier38.fr"); } public function test_getRecords_SPFReject () { $spfcheck = new spfcheck (); $res = $spfcheck->getRecords ("reject.spf.tester.fournier38.fr"); $this->assertSame ($res, array ("reject.spf.tester.fournier38.fr" => array ("-all" => array ()))); } public function test_getRecords_Loop () { $this->expectException ("Exception", "SPFCheck : Too much DNS requests (30 >= 30)", 500); $spfcheck = new spfcheck (); $res = $spfcheck->getRecords ("loop.spf.tester.fournier38.fr"); $this->assertSame ($res, array ()); } public function test_getRecords_Include_emptyInclude () { $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 ()))); } public function test_getRecords_Redirect_emptyRedirect () { $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 ()))); } public function test_getRecords_MX_emptyMX () { $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 ()))); } public function test_getRecords_MX_validMX () { $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 ( "2a01:e0a:234:3931::103", "2a01:e0a:289:3090::206", "82.64.55.197", "82.64.75.195"), "-all" => array ()))); } public function test_getRecords_A_emptyA () { $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 ()))); } public function test_getRecords_A_validA () { $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 ( "2a01:e0a:234:3931::100", "82.64.55.197",), "-all" => array ()))); } public function test_getRecords_IP4_emptyIP4 () { $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 ()))); } public function test_getRecords_IP4_invalidIP4 () { $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 ()))); } public function test_getRecords_IP4_validIP4 () { $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 ()))); } public function test_getRecords_IP6_emptyIP6 () { $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 ()))); } public function test_getRecords_IP6_invalidIP6 () { $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 ()))); } public function test_getRecords_IP6_validIP6 () { $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 ()))); } public function test_getRecords_PTR () { $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 ()))); } public function test_getRecords_All_Multiple () { $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 ()))); } public function test_getRecords_All_NotEnd () { $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 ()))); } public function test_getRecords_All_NotSet () { $spfcheck = new spfcheck (); $res = $spfcheck->getRecords ("allnotset.spf.tester.fournier38.fr"); $this->assertSame ($res, array ("allnotset.spf.tester.fournier38.fr" => array ( "mx" => array ()))); } public function test_getRecords_Unknown () { $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 ()))); } }