Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SethSharp committed Oct 5, 2024
1 parent 47ab868 commit 7454a98
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/OddsClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@ public function setBookmakers(mixed $bookmakers): self
}

/**
* @param string|array $eventId
* @param mixed $eventId
* @return $this
*/
public function setEvents(string|array $eventId): self
public function setEvents(mixed $eventId): self
{
if (is_array($eventId)) {
$this->params['eventIds'] = $this->buildEvents($eventId);
Expand Down
94 changes: 94 additions & 0 deletions tests/Unit/OddsClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,98 @@ public function testSetsBookmakers()

$this->assertEquals('0=sportsbet,1=tab,2=topsport', $oddsClient->getParams()['bookmakers']);
}

public function testSetsEventsString()
{

$oddsClient = new OddsClient('test-api-key');

$oddsClient->setEvents('some-event');

$this->assertEquals('some-event', $oddsClient->getParams()['eventIds']);
}

public function testSetsEventsArray()
{

$oddsClient = new OddsClient('test-api-key');

$oddsClient->setEvents([
'event-1',
'event-2',
'event-3',
]);

$this->assertEquals('event-1,event-2,event-3', $oddsClient->getParams()['eventIds']);
}

public function testSetsOddsFormat()
{
$oddsClient = new OddsClient('test-api-key');

$oddsClient->oddsFormat('american');

$this->assertEquals('american', $oddsClient->getParams()['oddsFormat']);
}

public function testSetsDateFormat()
{
$oddsClient = new OddsClient('test-api-key');

$oddsClient->dateFormat('unix');

$this->assertEquals('unix', $oddsClient->getParams()['dateForm']);
}

public function testCommenceTimeFromAndConvertsToIso()
{
$oddsClient = new OddsClient('test-api-key');

$oddsClient->commenceTimeFrom('2024-05-10');

$this->assertEquals('2024-05-10T00:00:00Z', $oddsClient->getParams()['commenceTimeFrom']);
}

public function testCommenceTimeFrom()
{
$oddsClient = new OddsClient('test-api-key');

$oddsClient->commenceTimeFrom('2024-05-10T00:00:00Z', isIsoFormat: true);

$this->assertEquals('2024-05-10T00:00:00Z', $oddsClient->getParams()['commenceTimeFrom']);
}

public function testCommenceTimeToAndConvertsToIso()
{
$oddsClient = new OddsClient('test-api-key');

$oddsClient->commenceTimeTo('2024-05-10');

$this->assertEquals('2024-05-10T00:00:00Z', $oddsClient->getParams()['commenceTimeTo']);
}

public function testCommenceTimeTo()
{
$oddsClient = new OddsClient('test-api-key');

$oddsClient->commenceTimeTo('2024-05-10T00:00:00Z', isIsoFormat: true);

$this->assertEquals('2024-05-10T00:00:00Z', $oddsClient->getParams()['commenceTimeTo']);
}

public function testCanAddCustomParams()
{
$oddsClient = new OddsClient('test-api-key');

$oddsClient->addParams([
'a-new-param' => 'some-value'
]);

$this->assertEquals([
'api_key' => 'test-api-key',
'regions' => 'au',
'oddsFormat' => 'decimal',
'a-new-param' => 'some-value',
], $oddsClient->getParams());
}
}

0 comments on commit 7454a98

Please sign in to comment.