Skip to content

Commit

Permalink
benchmark testing
Browse files Browse the repository at this point in the history
  • Loading branch information
SethSharp committed Oct 5, 2024
1 parent 8246123 commit 4cf59e4
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 11 deletions.
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@
}
},
"require-dev": {
"pestphp/pest": "^3.2"
"pestphp/pest": "^3.2",
"orchestra/testbench": "^9.5"
},
"config": {
"allow-plugins": {
"pestphp/pest-plugin": true
}
},
"scripts": {
"test": "pest"
}
}
5 changes: 0 additions & 5 deletions tests/Feature/ExampleTest.php

This file was deleted.

5 changes: 0 additions & 5 deletions tests/Unit/ExampleTest.php

This file was deleted.

80 changes: 80 additions & 0 deletions tests/Unit/OddsClientTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php

namespace Tests\Unit;

use Orchestra\Testbench\TestCase;
use SethSharp\OddsApi\OddsClient;

class OddsClientTest extends TestCase
{
protected function getPackageProviders($app)
{
return [
'SethSharp\OddsApi\OddsApiServiceProvider'
];
}

protected function setUp(): void
{
parent::setUp();

$this->app['config']->set('odds-api.default_region', 'au');
$this->app['config']->set('odds-api.default_odds_format', 'decimal');
}

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

$this->assertEquals('https://api.the-odds-api.com', $oddsClient->getApiEndpoint());

$this->assertEquals([
'api_key' => $apiKey,
'regions' => 'au',
'oddsFormat' => 'decimal',
], $oddsClient->getParams());
}

public function testSetsProvidedApiEndpoint()
{
$oddsClient = new OddsClient('test-api-key', 'a-new-endpoint');

$this->assertEquals('a-new-endpoint', $oddsClient->getApiEndpoint());
}

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

$oddsClient->setRegion('us');

$this->assertEquals('us', $oddsClient->getParams()['regions']);
}

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

$oddsClient->setMarkets([
'h2h',
'spreads',
'outrights'
]);

$this->assertEquals('0=h2h,1=spreads,2=outrights', $oddsClient->getParams()['markets']);
}

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

$oddsClient->setBookmakers([
'sportsbet',
'tab',
'topsport'
]);

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

0 comments on commit 4cf59e4

Please sign in to comment.