Skip to content

Instantly share code, notes, and snippets.

@grantbrokergenius
Created May 9, 2019 16:05
Show Gist options
  • Save grantbrokergenius/dab93ce1c44dacdc7d06e82a3ae0a404 to your computer and use it in GitHub Desktop.
Save grantbrokergenius/dab93ce1c44dacdc7d06e82a3ae0a404 to your computer and use it in GitHub Desktop.
<?php
namespace tests\Integration\API\AdminPanel;
use App\AdminPanel\Events\EventsHandler;
use DB;
use tests\Integration\AutoPricer\IntegrationTestCase;
class EventsHandlerTest extends IntegrationTestCase
{
/* @var PDO */
private $db;
/* @var EventsHandler */
private $service;
private $bg_event_id_to_map;
private $event_exchange_id = 11111;
private $exchange_id = 1;
private $unresolveable_exchange_id = 2;
private $admin_user_id = 1;
public function setUp()
{
parent::setUp();
$this->db = DB::getPdo();
$this->service = new EventsHandler();
$this->bg_event_id_to_map = $this->addEvent();
}
private function addEvent() {
$sql = <<<SQL
INSERT INTO `bg_events` VALUES (1,'98989898',NULL,'Texas Rangers at Houston Astros','Minute Maid Park','2017-05-04 13:10:00','vs','2017-05-04 15:30:29','2017-09-25 08:08:12',NULL))
SQL;
$this->db->query($sql);
return $this->db->lastInsertId();
}
public function testGetUnApprovedEvents() {
$data = [
'exchange_id' => 1,
'only_flagged_events' => 'false',
'event_start_date' => '',
'event_end_date' => '',
'page' => 1,
'name_type' => '',
];
$results = $this->service->getUnApprovedEvents($data);
$this->assertAttributeGreaterThan(0, 'total', $results);
}
public function testUpdateExchangeEventId() {
$result = $this->service->updateExchangeEventId($this->bg_event_id_to_map, $this->event_exchange_id, $this->exchange_id);
$this->assertTrue($result);
}
public function testApproveEvent() {
$result = $this->service->approveEvent($this->bg_event_id_to_map, $this->exchange_id);
$this->assertEquals(1, $result);
}
public function testMarkUnresolveable() {
$result = $this->service->markUnresolveable($this->unresolveable_exchange_id, $this->bg_event_id_to_map, $this->admin_user_id);
$this->assertTrue($result);
}
/*
public function testDeleteEventMappingFlags() {
}
public function testUpdateStubhubEventId() {
}
*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment