OSDN Git Service

Test for array_count_leaves(), array_merge_leaves()
authorhenoheno <henoheno>
Fri, 4 May 2007 14:55:36 +0000 (23:55 +0900)
committerhenoheno <henoheno>
Fri, 4 May 2007 14:55:36 +0000 (23:55 +0900)
spam/SpamTest.php
spam/spam.php

index 60c213b..df98e95 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-// $Id: SpamTest.php,v 1.7 2007/05/04 14:42:28 henoheno Exp $
+// $Id: SpamTest.php,v 1.8 2007/05/04 14:54:21 henoheno Exp $
 // Copyright (C) 2007 heno
 //
 // Design test case for spam.php (called from runner.php)
@@ -137,6 +137,20 @@ class SpamTest extends PHPUnit_TestCase
                        'f4',
                );
                $this->assertEquals($result, array_merge_leaves($array1, $array2));
+
+               // ----
+
+               // Values will not be unique now
+               $array1 = array(5, 4);
+               $array2 = array(4, 5);
+               $result = array(5, 4, 4, 5);
+               $this->assertEquals($result, array_merge_leaves($array1, $array2));
+
+               // One more thing ...
+               $array1 = array('b' => array('k3'));
+               $array2 = array('b' => 'k3');
+               $result = array('b' => array('k3', 'k3'));
+               $this->assertEquals($result, array_merge_leaves($array1, $array2));
        }
 
        function testFunc_uri_pickup()
index c31ea62..5f9cf61 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-// $Id: spam.php,v 1.146 2007/05/04 14:44:06 henoheno Exp $
+// $Id: spam.php,v 1.147 2007/05/04 14:55:36 henoheno Exp $
 // Copyright (C) 2006-2007 PukiWiki Developers Team
 // License: GPL v2 or (at your option) any later version
 //
@@ -1143,9 +1143,11 @@ function check_uri_spam($target = '', $method = array())
                        if ($asap && $is_spam) break;
 
                        // Merge $blocked
+                       // TODO: unique the hosts
                        $blocked = array_merge_leaves($blocked, $_progress['blocked']);
 
                        // Merge $hosts
+                       // TODO: unique the hosts
                        $hosts   = array_merge_leaves($hosts,   $_progress['hosts']);
                }