فهرست منبع

add invitor_filter

lionared 7 سال پیش
والد
کامیت
e407e390a9
2فایلهای تغییر یافته به همراه24 افزوده شده و 0 حذف شده
  1. 14 0
      helper/async/broadcast/filter.php
  2. 10 0
      test/TestPush.php

+ 14 - 0
helper/async/broadcast/filter.php

@@ -252,7 +252,21 @@ class gift_filter extends filter
 
 class invitor_filter extends filter
 {
+    protected $has_invitor;
+
+    public function __construct($param)
+    {
+        $this->has_invitor = boolval($param['value']);
+    }
+
     public function filtrate(member_info $minfo)
     {
+        if($this->has_invitor) {
+            return $minfo->inviter_id() > 0;
+        }
+        else
+        {
+            return $minfo->inviter_id() == 0;
+        }
     }
 }

+ 10 - 0
test/TestPush.php

@@ -131,6 +131,16 @@ class TestPush extends PHPUnit_Framework_TestCase
         $this->assertTrue($result);
     }
 
+    public function testInvitorFilter()
+    {
+        $member_id = 36486;
+        $info = new member_info($member_id);
+
+        $filter = new async\invitor_filter(['value' => true]);
+        $result = $filter->filtrate($info);
+        $this->assertTrue($result);
+    }
+
     public function testBroadcastCount()
     {
         //$filter_arr = [['type' => 'regtime', 'days' => 90]];