/**
  * Tests if the remove tournament method
  * works as expected.
  */
 public function testRepoRemoveTournamentRemovalSuccess()
 {
     $tournament = Factory::create('App\\Models\\Tournament');
     $result = $this->repository->removeTournament(Administrator::find($tournament->created_by), $tournament->name);
     $this->assertTrue($result);
     $this->assertNull(Tournament::find($tournament->id));
 }
 /**
  * Tests if the remove rankings works
  * correclty.
  */
 public function testRepoRemoveRankingRemovalSuccess()
 {
     $ranking = Factory::create('App\\Models\\Ranking');
     $admin = Administrator::find(Tournament::find($ranking->tournament_id)->created_by);
     $result = $this->repository->removeRanking($admin, $ranking->id);
     $this->assertTrue($result);
     $this->assertNull(Ranking::find($ranking->id));
 }
 /**
  * Проверка замен перед дедлайном
  */
 public function actionCheck()
 {
     $bot = new BotApi(Yii::$app->params['token']);
     $time = time() + 2 * 60 * 60;
     $tournaments = Tournament::find()->where(['checked' => false])->andWhere(['<', 'deadline', date('Y-m-d H:i:s', $time)])->all();
     foreach ($tournaments as $tournament) {
         foreach ($tournament->teams as $team) {
             if ($team->user->notification) {
                 $transfers = $team->getTransfers();
                 if ($transfers == $tournament->transfers) {
                     $message = 'Ты ещё не сделал замены, скоро дедлайн:';
                     $date = new DateTime($tournament->deadline, new DateTimeZone(Yii::$app->timeZone));
                     $message .= "\n" . $date->format('H:i') . '  ' . $tournament->name;
                     try {
                         $bot->sendMessage($team->user->chat_id, $message);
                     } catch (Exception $e) {
                         Yii::info($e->getMessage(), 'send');
                     }
                 }
             }
         }
         $tournament->checked = true;
         $tournament->save();
     }
 }
Example #4
0
<?php

require __DIR__ . '/../../bootstrap/autoload.php';
$app = (require_once __DIR__ . '/../../bootstrap/app.php');
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
use App;
$response = $kernel->handle($request = Illuminate\Http\Request::capture());
$tournament = App\Models\Tournament::find(1);
App\Models\Match::where(['tournamentId' => $tournament->id])->delete();
$event = new App\Events\TournamentWasStarted($tournament);
$handler = new App\Listeners\Tournament\DrawLeague();
$handler->handle($event);