-
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
ad287ba
commit d86ba3e
Showing
9 changed files
with
105 additions
and
189 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,40 @@ | ||
<?php | ||
|
||
namespace ProgrammatorDev\SportMonksFootball\Resource; | ||
|
||
use ProgrammatorDev\SportMonksFootball\Entity\Response\RivalCollection; | ||
use ProgrammatorDev\SportMonksFootball\Resource\Util\PaginationTrait; | ||
use Psr\Http\Client\ClientExceptionInterface; | ||
|
||
class RivalResource extends Resource | ||
{ | ||
use PaginationTrait; | ||
|
||
/** | ||
* @throws ClientExceptionInterface | ||
*/ | ||
public function getAll(): RivalCollection | ||
{ | ||
$data = $this->api->request( | ||
method: 'GET', | ||
path: '/v3/football/rivals' | ||
); | ||
|
||
return new RivalCollection($data); | ||
} | ||
|
||
/** | ||
* @throws ClientExceptionInterface | ||
*/ | ||
public function getAllByTeamId(int $teamId): RivalCollection | ||
{ | ||
$data = $this->api->request( | ||
method: 'GET', | ||
path: $this->api->buildPath('/v3/football/rivals/teams/{teamId}', [ | ||
'teamId' => $teamId | ||
]) | ||
); | ||
|
||
return new RivalCollection($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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace ProgrammatorDev\SportMonksFootball\Test\Integration; | ||
|
||
use ProgrammatorDev\SportMonksFootball\Entity\Response\RivalCollection; | ||
use ProgrammatorDev\SportMonksFootball\Test\AbstractTest; | ||
use ProgrammatorDev\SportMonksFootball\Test\MockResponse; | ||
use ProgrammatorDev\SportMonksFootball\Test\Util\TestCollectionResponseTrait; | ||
|
||
class RivalResourceTest extends AbstractTest | ||
{ | ||
use TestCollectionResponseTrait; | ||
|
||
public static function provideCollectionResponseData(): \Generator | ||
{ | ||
yield 'get all' => [ | ||
RivalCollection::class, | ||
MockResponse::RIVAL_COLLECTION_DATA, | ||
'rivals', | ||
'getAll' | ||
]; | ||
yield 'get all by team id' => [ | ||
RivalCollection::class, | ||
MockResponse::RIVAL_COLLECTION_DATA, | ||
'rivals', | ||
'getAllByTeamId', | ||
[1] | ||
]; | ||
} | ||
} |
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 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,24 @@ | ||
<?php | ||
|
||
namespace ProgrammatorDev\SportMonksFootball\Test\Unit; | ||
|
||
use ProgrammatorDev\SportMonksFootball\Entity\Rival; | ||
use ProgrammatorDev\SportMonksFootball\Test\AbstractTest; | ||
|
||
class RivalTest extends AbstractTest | ||
{ | ||
public function testMethods(): void | ||
{ | ||
$entity = new Rival([ | ||
'id' => 1, | ||
'sport_id' => 1, | ||
'team_id' => 1, | ||
'rival_id' => 1 | ||
], 'UTC'); | ||
|
||
$this->assertSame(1, $entity->getId()); | ||
$this->assertSame(1, $entity->getSportId()); | ||
$this->assertSame(1, $entity->getTeamId()); | ||
$this->assertSame(1, $entity->getRivalId()); | ||
} | ||
} |