Skip to content

Commit

Permalink
Merge pull request #8 from renesoaresse/feature/markets
Browse files Browse the repository at this point in the history
Implementation of the markets route
  • Loading branch information
kirill-latish authored Oct 25, 2018
2 parents 48a247c + 3b7dde5 commit ac3b6b0
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Sportmonks/SoccerAPI/Requests/Markets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Sportmonks\SoccerAPI\Requests;

use Sportmonks\SoccerAPI\SoccerAPIClient;

class Markets extends SoccerAPIClient {

public function all()
{
return $this->callData('markets');
}

public function byId($marketsId)
{
return $this->call('markets/' . $marketsId);
}

}
6 changes: 6 additions & 0 deletions src/Sportmonks/SoccerAPI/SoccerAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Sportmonks\SoccerAPI;

use Sportmonks\SoccerAPI\Requests\Bookmaker;
use Sportmonks\SoccerAPI\Requests\Markets;
use Sportmonks\SoccerAPI\Requests\Commentary;
use Sportmonks\SoccerAPI\Requests\Fixture;
use Sportmonks\SoccerAPI\Requests\Head2Head;
Expand Down Expand Up @@ -119,4 +120,9 @@ public function squads()
return new Squad();
}

public function markets()
{
return new Markets();
}

}
42 changes: 42 additions & 0 deletions tests/Requests/MarketsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
use Sportmonks\SoccerAPI\Facades\SoccerAPI;


/**
* @group bookmaker
*/
class MarketsTest extends TestCase {

/**
* @test
*/
public function it_retrieves_all_markets()
{
$response = SoccerAPI::markets()->all();

$this->assertNotEmpty($response->data);
}

/**
* @test
*/
public function it_retrieves_markets_without_data()
{
Config::set('soccerapi.without_data', true);
$response = SoccerAPI::markets()->all();

$this->assertArrayHasKey(0, $response);
}

/**
* @test
*/
public function it_retrieves_a_markets_by_id()
{
$response = SoccerAPI::markets()->byId($this->marketsId);

$this->assertEquals($this->marketsId, $response->data->id);
$this->assertNotNull($response->data->name);
}

}

0 comments on commit ac3b6b0

Please sign in to comment.