404

[ Avaa Bypassed ]




Upload:

Command:

botdev@3.135.198.174: ~ $
<?php


use PHPUnit\Framework\TestCase;
// exclude "./../src/"

final class DateConverterIntentTest extends TestCase
{
    private $translate_bot;
    private $messagesResults = [];
    function setUp(): void{
        $BOT_USER= '@TranslateGerman_bot';
        $BOT_TOKEN=  '816983194:AAH1pPCba__pNRFK7h6fFMoy-9twUuxJ-n8';
        $uriParts = explode("?",$_SERVER['REQUEST_URI']);
        $actual_link = "https://$_SERVER[HTTP_HOST]".$uriParts[0];
        $WEBHOOK_URL= "$actual_link";
        $SIGN ="پوشش خبری شهر های آلمان ".PHP_EOL."@TranslateGerman_bot";
        $this->translate_bot = new TranslateGerman($BOT_USER,$BOT_TOKEN,$WEBHOOK_URL, $SIGN);
        $bot = $this->getMockBuilder('Bot')
        ->setConstructorArgs(array($BOT_USER,$BOT_TOKEN,$WEBHOOK_URL, $SIGN))
        ->getMock();
        $member["status"]="member";
        $bot = $this->getMockBuilder('Bot')
        ->setConstructorArgs(array($BOT_USER,$BOT_TOKEN,$WEBHOOK_URL, $SIGN))
        ->getMock();
        
        $bot->method("apiRequest")->will(
            $this->returnCallback(array($this, 'returnTestDataCallback'))
        );
        $this->translate_bot->bot = $bot;
        $this->getTG()->getDB()->removeAllUserActivites();
    }
    public function returnTestDataCallback()
    {
        $args = func_get_args();
        // print_r($args);
        if($args[0]=="getChatMember"){
            $member["status"]="member";
            return $member;
        }
        else {
            $this->messagesResults[] = 
            array_push($this->messagesResults, $args[1]);
        }
    }
    function getTG(): TranslateGerman{
        return $this->translate_bot;
    }
    function reset() {
        $this->getTG()->params = null;
        $this->getTG()->method = null;
        $this->messagesResults = [];

    }
    /**
     * @group failing
    */
    public function testDateToday(): void
    {
        $IS = new IntentService($this->getTG());
        $txt="heute";
        $intents = $IS->findIntents($txt);
        // $intent->act();
        $expectedIntent = new DateConverter($IS);
        $filteredIntent =  array_values(array_filter($intents, function(Intent $intent)  use ($expectedIntent) {
            if($intent->name === $expectedIntent->name) return true;
         }));
 
         $this->assertEquals($filteredIntent[0]->name, $expectedIntent->name);        
        $this->reset();

        
        $txt="امروز";
        $intents = $IS->findIntents($txt);
        $expectedIntent = new DateConverter($IS);
        $filteredIntent =  array_values(array_filter($intents, function(Intent $intent)  use ($expectedIntent) {
           if($intent->name === $expectedIntent->name) return true;
        }));

        $this->assertEquals($filteredIntent[0]->name, $expectedIntent->name);        
        $this->reset();         
    }
    public function testDateTodayWithText(): void
    {
        $IS = new IntentService($this->getTG());
        $txt="was ist heute 1";
        $intents = $IS->findIntents($txt);
        $expectedIntent = new DateConverter($IS);
        $filteredIntent =  array_values(array_filter($intents, function(Intent $intent)  use ($expectedIntent) {
           if($intent->name === $expectedIntent->name) return true;
        }));

        $this->assertEquals($filteredIntent[0]->name, $expectedIntent->name);        
        $this->reset();    
    }
    /**
     * @group failing
    */
    public function testDateTommorrow(): void {
        $IS = new IntentService($this->getTG());
        $txt="morgen";
        $intents = $IS->findIntents($txt);
        $expectedIntent = new DateConverter($IS);
        $filteredIntent =  array_values(array_filter($intents, function(Intent $intent)  use ($expectedIntent) {
           if($intent->name === $expectedIntent->name) return true;
        })); 
        $this->assertEquals($filteredIntent[0]->name, $expectedIntent->name);        

        $this->reset();
        
        $txt="فردا";
        $intents = $IS->findIntents($txt);

        // print_r($tomorrowDate);
        $filteredIntent =  array_values(array_filter($intents, function(Intent $intent)  use ($expectedIntent) {
            if($intent->name === $expectedIntent->name) return true;
         })); 
        $this->assertEquals($filteredIntent[0]->name, $expectedIntent->name);        
 
         $this->reset();

        $txt="پس فردا";
        $intents = $IS->findIntents($txt);
        // $intent->act();
     
        $filteredIntent =  array_values(array_filter($intents, function(Intent $intent)  use ($expectedIntent) {
            if($intent->name === $expectedIntent->name) return true;
         })); 
        $this->assertEquals($filteredIntent[0]->name, $expectedIntent->name);        
 
         $this->reset();

        $txt="پریروز";
        $intents = $IS->findIntents($txt);
        
        $filteredIntent =  array_values(array_filter($intents, function(Intent $intent)  use ($expectedIntent) {
            if($intent->name === $expectedIntent->name) return true;
         })); 
        $this->assertEquals($filteredIntent[0]->name, $expectedIntent->name);     
        $this->reset();

        $txt="nächste woche";
        $intents = $IS->findIntents($txt);
        // $intent->act();
     
        $filteredIntent =  array_values(array_filter($intents, function(Intent $intent)  use ($expectedIntent) {
            if($intent->name === $expectedIntent->name) return true;
         })); 
        $this->assertEquals($filteredIntent[0]->name, $expectedIntent->name);         
        $this->reset();

        $txt="هفته بعد";
        $intents = $IS->findIntents($txt);
        // $intent->act();
     
        $filteredIntent =  array_values(array_filter($intents, function(Intent $intent)  use ($expectedIntent) {
            if($intent->name === $expectedIntent->name) return true;
         })); 
        $this->assertEquals($filteredIntent[0]->name, $expectedIntent->name);  
        $this->reset();
    }
    /**
     * @group failing
    */
    public function testCustomNextdays(): void{

        $IS = new IntentService($this->getTG());
        $expectedIntent = new DateConverter($IS);

        $txt="20 tage später";
        $intents = $IS->findIntents($txt);
     
        $filteredIntent =  array_values(array_filter($intents, function(Intent $intent)  use ($expectedIntent) {
            if($intent->name === $expectedIntent->name) return true;
         })); 
        $this->assertEquals($filteredIntent[0]->name, $expectedIntent->name);       
        $this->reset();

        $txt="4 روز بعد";
        $intents = $IS->findIntents($txt);
     
        $filteredIntent =  array_values(array_filter($intents, function(Intent $intent)  use ($expectedIntent) {
            if($intent->name === $expectedIntent->name) return true;
         })); 
        $this->assertEquals($filteredIntent[0]->name, $expectedIntent->name);    
        $this->reset();

        $txt="5 روز قبل";
        $intents = $IS->findIntents($txt);
        $filteredIntent =  array_values(array_filter($intents, function(Intent $intent)  use ($expectedIntent) {
            if($intent->name === $expectedIntent->name) return true;
         })); 
        $this->assertEquals($filteredIntent[0]->name, $expectedIntent->name);         
        $this->reset();

        $txt="۵ روز پیش";
        $intents = $IS->findIntents($txt);
     
        $filteredIntent =  array_values(array_filter($intents, function(Intent $intent)  use ($expectedIntent) {
            if($intent->name === $expectedIntent->name) return true;
         })); 
        $this->assertEquals($filteredIntent[0]->name, $expectedIntent->name);         
        $this->reset();

        $txt="۲۵ روز پیش";
        $intents = $IS->findIntents($txt);
     
        $filteredIntent =  array_values(array_filter($intents, function(Intent $intent)  use ($expectedIntent) {
            if($intent->name === $expectedIntent->name) return true;
         })); 
        $this->assertEquals($filteredIntent[0]->name, $expectedIntent->name);       
        $this->reset();

        $txt="۳۰ روز دیگه";
        $intents = $IS->findIntents($txt);
     
        $filteredIntent =  array_values(array_filter($intents, function(Intent $intent)  use ($expectedIntent) {
            if($intent->name === $expectedIntent->name) return true;
         })); 
        $this->assertEquals($filteredIntent[0]->name, $expectedIntent->name);           
        $this->reset();

        $txt="20 روز بعد";
        $intents = $IS->findIntents($txt);
        $intents = $IS->findIntents($txt);
     
        $filteredIntent =  array_values(array_filter($intents, function(Intent $intent)  use ($expectedIntent) {
            if($intent->name === $expectedIntent->name) return true;
         })); 
        $this->assertEquals($filteredIntent[0]->name, $expectedIntent->name);      
        $this->reset();
    }

    public function testTime(){
        $IS = new IntentService($this->getTG());
        $expectedIntent = new DateConverter($IS);
        $txt="jetzt";
        $intents = $IS->findIntents($txt);
     
        $filteredIntent =  array_values(array_filter($intents, function(Intent $intent)  use ($expectedIntent) {
            if($intent->name === $expectedIntent->name) return true;
         })); 
        $this->assertEquals($filteredIntent[0]->name, $expectedIntent->name);   
        $this->reset();
 
    }
    public function testCustomNextTime(){
        $IS = new IntentService($this->getTG());
        $expectedIntent = new DateConverter($IS);

        $txt="۳ ساعت بعد";
        $intents = $IS->findIntents($txt);
        $filteredIntent =  array_values(array_filter($intents, function(Intent $intent)  use ($expectedIntent) {
            if($intent->name === $expectedIntent->name) return true;
         })); 
        $this->assertEquals($filteredIntent[0]->name, $expectedIntent->name);   
        $this->reset();
 
    }

    /**
     * @group failing
    */
    public function testIntegrityToday(): void {
        $dbgMgr = new DebugsManager();
        $update = $dbgMgr->getUpdateForTestPerson("123456");
        $update["message"]["text"] = "heute";
        $this->getTG()->process($update);
        $date = date("Y/m/d H:i:s");
        $dt = new DateTime($date);
        $dt->setTimezone(new DateTimeZone("Europe/Berlin"));
        $this->assertStringContainsString($this->getTG()->params['text'], $this->getTG()->params['text']);         
        $this->reset();

    }
    public function testIntegrityCustomNextTime(): void {
        $dbgMgr = new DebugsManager();
        $update = $dbgMgr->getUpdateForTestPerson("123456");
        $update["message"]["text"] = "۳ ساعت بعد";
        $this->getTG()->process($update);
        $date = date("Y/m/d H:i:s",strtotime("+3hours"));
        $dt = new DateTime($date);
        $dt->setTimezone(new DateTimeZone("Europe/Berlin"));
        $this->assertStringContainsString($dt->format("y/m/d  H:i:s"), $this->messagesResults[2]['text']);         
    }
    public function testIntegrityCustomNextDays(): void {
        $dbgMgr = new DebugsManager();
        $update = $dbgMgr->getUpdateForTestPerson("123456");
        $update["message"]["text"] = "20 روز بعد";
        $this->getTG()->process($update);
        $date = date("Y/m/d  H:i:s", strtotime('+20day'));
        $dt = new DateTime($date);
        $dt->setTimezone(new DateTimeZone("Europe/Berlin"));
        $this->assertStringContainsString($dt->format("y/m/d"), $this->messagesResults[2]['text']);         
        $this->reset();

    }
    public function testIntegrityCustomPrevDays(): void {
        $dbgMgr = new DebugsManager();
        $update = $dbgMgr->getUpdateForTestPerson("123456");
        $update["message"]["text"] = "20 روز قبل";
        $this->getTG()->process($update);
        $date = date("Y/m/d H:i:s", strtotime('-20day'));
        $dt = new DateTime($date);
        $dt->setTimezone(new DateTimeZone("Europe/Berlin"));
        $this->assertStringContainsString($dt->format("y/m/d  H:i:s"), $this->messagesResults[2]['text']);         
        $this->reset();

    }

}






Filemanager

Name Type Size Permission Actions
adresses Folder 2755
advertise Folder 2755
database Folder 2755
drive-german Folder 2755
german Folder 2755
invited Folder 2755
ocr Folder 2755
patreon Folder 2755
speech Folder 2755
swedish Folder 2755
tamasbabot Folder 2755
videos Folder 2755
DateConverterIntentTest.php File 11.98 KB 0755
EuroTomanIntentTest.php File 2.4 KB 0755
EuroTomanTest.php File 1.44 KB 0755
GeneralTest.php File 1.79 KB 0755
verbose.php File 20 B 0755