This repository has been archived by the owner on Sep 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from duffelhq/api-airlines
API: Airlines
- Loading branch information
Showing
4 changed files
with
73 additions
and
1 deletion.
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 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,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Duffel\Api; | ||
|
||
class Airlines extends AbstractApi { | ||
public function all(array $parameters = []) { | ||
return $this->get('/air/airlines'); | ||
} | ||
|
||
public function show(string $id) { | ||
return $this->get('/air/airlines/'.self::encodePath($id)); | ||
} | ||
} |
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,40 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Duffel\Tests\Api; | ||
|
||
use Duffel\Api\Airlines; | ||
use Duffel\Client; | ||
use Http\Client\Common\HttpMethodsClientInterface; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class TestAirlines extends TestCase { | ||
private $mock; | ||
private $stub; | ||
|
||
public function setUp(): void { | ||
$this->mock = $this->createMock(HttpMethodsClientInterface::class); | ||
$this->stub = $this->createStub(Client::class); | ||
$this->stub->method('getHttpClient') | ||
->willReturn($this->mock); | ||
} | ||
|
||
public function testAllCallsGetWithExpectedUri(): void { | ||
$this->mock->expects($this->once()) | ||
->method('get') | ||
->with($this->equalTo('/air/airlines')); | ||
|
||
$actual = new Airlines($this->stub); | ||
$actual->all(); | ||
} | ||
|
||
public function testShowCallsGetWithExpectedUri(): void { | ||
$this->mock->expects($this->once()) | ||
->method('get') | ||
->with($this->equalTo('/air/airlines/some-id')); | ||
|
||
$actual = new Airlines($this->stub); | ||
$actual->show('some-id'); | ||
} | ||
} |