-
Notifications
You must be signed in to change notification settings - Fork 180
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
29df1c0
commit dccb3ff
Showing
1 changed file
with
59 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace VonageTest\Subaccount; | ||
|
||
use PHPUnit\Framework\Exception; | ||
use PHPUnit\Framework\ExpectationFailedException; | ||
use Prophecy\Prophecy\ObjectProphecy; | ||
use SebastianBergmann\RecursionContext\InvalidArgumentException; | ||
use Vonage\Client; | ||
use Vonage\Client\APIResource; | ||
use Vonage\Client\Factory\MapFactory; | ||
use Vonage\Subaccount\Client as SubaccountClient; | ||
use Vonage\Subaccount\ClientFactory; | ||
use VonageTest\Psr7AssertionTrait; | ||
use VonageTest\VonageTestCase; | ||
|
||
class ClientFactoryTest extends VonageTestCase | ||
{ | ||
use Psr7AssertionTrait; | ||
|
||
protected APIResource $api; | ||
|
||
protected Client|ObjectProphecy $vonageClient; | ||
|
||
public function setUp(): void | ||
{ | ||
$this->vonageClient = $this->prophesize(Client::class); | ||
$this->vonageClient->getCredentials()->willReturn( | ||
new Client\Credentials\Basic('abc', 'def'), | ||
); | ||
$this->vonageClient = $this->vonageClient->reveal(); | ||
} | ||
|
||
/** | ||
* Makes sure that the client factory returns the correct object instance | ||
* | ||
* @see https://github.com/Vonage/vonage-php-sdk-core/pull/472 | ||
* | ||
* @return void | ||
* @throws InvalidArgumentException | ||
* @throws Exception | ||
* @throws ExpectationFailedException | ||
*/ | ||
public function testFactoryMakeCorrectClient(): void | ||
{ | ||
$container = new MapFactory( | ||
[ | ||
APIResource::class => APIResource::class, | ||
], | ||
$this->vonageClient | ||
); | ||
|
||
$factory = new ClientFactory(); | ||
$client = $factory($container); | ||
$this->assertInstanceOf(SubaccountClient::class, $client); | ||
} | ||
} |