public function testSendTelegram()
 {
     $tests = ["test_null", "test_mail", "test_telegram", "test_all"];
     foreach ($tests as $test) {
         $_GET['siteID'] = $test;
         $_GET['landingForm']['email'] = 'glmeist@gmail.com';
         $_GET['landingForm']['phone'] = '+77012240824';
         $_GET['landingForm']['fieldNames']['phone'] = "Телефон";
         $valid_form = new LandingForm();
         $valid_form->load();
         if (isset($valid_form->getSiteConfig()["telegram"]["channel_name"])) {
             $telegram = $valid_form->sendTelegram();
             $this->assertTrue($telegram->ok);
         } else {
             $this->assertNull($valid_form->sendTelegram());
         }
         unset($valid_form);
     }
 }
示例#2
0
<?php

header('Content-Type: application/javascript');
define('DEBUG', true);
require __DIR__ . "/LandingForm.php";
$data = ["success" => false, "errors" => []];
try {
    $form = new LandingForm();
    $form->load();
    if ($form->validate()) {
        $email = $form->send();
        $database = $form->save();
        $telegram = $form->sendTelegram();
        $data['success'] = true;
        if (DEBUG) {
            $data['telegram'] = $telegram;
            $data['email'] = $email;
            $data['database'] = $database;
        }
    }
    $data["errors"] = array_merge($data["errors"], $form->getErrors());
} catch (Exception $e) {
    $data['errors'][] = $e->getMessage();
}
echo $_GET['callback'] . '(' . json_encode($data) . ')';