-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3785a0e
commit 20b7b98
Showing
9 changed files
with
115 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace ProgrammatorDev\SportMonksFootball\Resource; | ||
|
||
use ProgrammatorDev\SportMonksFootball\Entity\Response\TopscorerCollection; | ||
use ProgrammatorDev\SportMonksFootball\Resource\Util\PaginationTrait; | ||
use Psr\Http\Client\ClientExceptionInterface; | ||
|
||
class TopscorerResource extends Resource | ||
{ | ||
use PaginationTrait; | ||
|
||
/** | ||
* @throws ClientExceptionInterface | ||
*/ | ||
public function getAllBySeasonId(int $seasonId): TopscorerCollection | ||
{ | ||
$data = $this->api->request( | ||
method: 'GET', | ||
path: $this->api->buildPath('/v3/football/topscorers/seasons/{seasonId}', [ | ||
'seasonId' => $seasonId | ||
]) | ||
); | ||
|
||
return new TopscorerCollection($data); | ||
} | ||
|
||
/** | ||
* @throws ClientExceptionInterface | ||
*/ | ||
public function getAllByStageId(int $stageId): TopscorerCollection | ||
{ | ||
$data = $this->api->request( | ||
method: 'GET', | ||
path: $this->api->buildPath('/v3/football/topscorers/stages/{stageId}', [ | ||
'stageId' => $stageId | ||
]) | ||
); | ||
|
||
return new TopscorerCollection($data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace ProgrammatorDev\SportMonksFootball\Test\Integration; | ||
|
||
use ProgrammatorDev\SportMonksFootball\Entity\Response\TopscorerCollection; | ||
use ProgrammatorDev\SportMonksFootball\Test\AbstractTest; | ||
use ProgrammatorDev\SportMonksFootball\Test\MockResponse; | ||
use ProgrammatorDev\SportMonksFootball\Test\Util\TestCollectionResponseTrait; | ||
|
||
class TopscorerResourceTest extends AbstractTest | ||
{ | ||
use TestCollectionResponseTrait; | ||
|
||
public static function provideCollectionResponseData(): \Generator | ||
{ | ||
yield 'get all by season id' => [ | ||
TopscorerCollection::class, | ||
MockResponse::TOPSCORER_COLLECTION_DATA, | ||
'topscorers', | ||
'getAllBySeasonId', | ||
[1] | ||
]; | ||
yield 'get all by stage id' => [ | ||
TopscorerCollection::class, | ||
MockResponse::TOPSCORER_COLLECTION_DATA, | ||
'topscorers', | ||
'getAllByStageId', | ||
[1] | ||
]; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace ProgrammatorDev\SportMonksFootball\Test\Unit; | ||
|
||
use ProgrammatorDev\SportMonksFootball\Entity\Topscorer; | ||
use ProgrammatorDev\SportMonksFootball\Test\AbstractTest; | ||
|
||
class TopscorerTest extends AbstractTest | ||
{ | ||
public function testMethods(): void | ||
{ | ||
$entity = new Topscorer([ | ||
'id' => 1, | ||
'season_id' => 1, | ||
'player_id' => 1, | ||
'type_id' => 1, | ||
'participant_id' => 1, | ||
'position' => 1, | ||
'total' => 10 | ||
], 'UTC'); | ||
|
||
$this->assertSame(1, $entity->getId()); | ||
$this->assertSame(1, $entity->getSeasonId()); | ||
$this->assertSame(1, $entity->getPlayerId()); | ||
$this->assertSame(1, $entity->getTypeId()); | ||
$this->assertSame(1, $entity->getParticipantId()); | ||
$this->assertSame(1, $entity->getPosition()); | ||
$this->assertSame(10, $entity->getTotal()); | ||
} | ||
} |