Skip to content

Commit

Permalink
Adding More Coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
weroh committed Aug 25, 2020
1 parent 9d11e47 commit b0c2368
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/Telnyx.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ public static function setPublicKey($publicKey)
self::$publicKey = $publicKey;
}

/**
* @return string The Public key used for webhooks.
*/
public static function getPublicKey()
{
return self::$publicKey;
}

/**
* Sets the client_id to be used for Connect requests.
*
Expand Down
27 changes: 27 additions & 0 deletions tests/api_resources/ApiResponseTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Telnyx;

/**
* @internal
* @covers \Telnyx\ApiResponse
*/
final class ApiResponseTest extends \Telnyx\TestCase
{
public function testConstruct()
{
$obj = [
'body' => 'body',
'code' => 'code',
'headers' => 'header',
'json' => 'json'
];

$class = new \Telnyx\ApiResponse($obj['body'], $obj['code'], $obj['headers'], $obj['json']);

static::assertSame($obj['body'], $class->body);
static::assertSame($obj['code'], $class->code);
static::assertSame($obj['headers'], $class->headers);
static::assertSame($obj['json'], $class->json);
}
}
24 changes: 24 additions & 0 deletions tests/api_resources/Operations/AllTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Telnyx;

/**
* @internal
* @covers \Telnyx\ApiOperations\All
*/

class DummyAll extends ApiResource
{
const OBJECT_NAME = 'phone_number';

use \Telnyx\ApiOperations\All;
}

final class AllTest extends \Telnyx\TestCase
{
public function testTrait()
{
$result = DummyAll::all();
$this->assertInstanceOf(\Telnyx\Collection::class, $result);
}
}
26 changes: 26 additions & 0 deletions tests/api_resources/Operations/RetrieveTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Telnyx;

/**
* @internal
* @covers \Telnyx\ApiOperations\Retrieve
*/

class DummyRetrieve extends ApiResource
{
const OBJECT_NAME = 'phone_number';

use \Telnyx\ApiOperations\Retrieve;
}

final class RetrieveTest extends \Telnyx\TestCase
{
const TEST_RESOURCE_ID = '1293384261075731499';

public function testTrait()
{
$result = DummyRetrieve::retrieve(self::TEST_RESOURCE_ID);
$this->assertInstanceOf(\Telnyx\TelnyxObject::class, $result);
}
}
2 changes: 1 addition & 1 deletion tests/api_resources/TelnyxObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/**
* @internal
* @covers \Telnyx\Telnyx
* @covers \Telnyx\TelnyxObject
*/
final class TelnyxObjectTest extends \Telnyx\TestCase
{
Expand Down
41 changes: 41 additions & 0 deletions tests/api_resources/TelnyxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,45 @@ public function testCABundlePathAccessors()
Telnyx::setCABundlePath('path/to/ca/bundle');
static::assertSame('path/to/ca/bundle', Telnyx::getCABundlePath());
}

public function testAppInfo() {
$app_info = [];
$app_info['name'] = 'test_app';
$app_info['partner_id'] = 'partner_id';
$app_info['url'] = 'url/to/app';
$app_info['version'] = '123';

Telnyx::setAppInfo($app_info['name'], $app_info['version'], $app_info['url'], $app_info['partner_id']);
static::assertSame($app_info, Telnyx::getAppInfo());
}

public function testSetsGets()
{
Telnyx::setApiKey('TEST89328');
static::assertSame('TEST89328', Telnyx::getApiKey());

Telnyx::setLogger(new \Telnyx\Util\DefaultLogger());
$this->assertInstanceOf(\Telnyx\Util\LoggerInterface::class, Telnyx::getLogger());

Telnyx::setClientId('CLIENTID455654');
static::assertSame('CLIENTID455654', Telnyx::getClientId());

Telnyx::setPublicKey('PUBLICKEY293847');
static::assertSame('PUBLICKEY293847', Telnyx::getPublicKey());

Telnyx::setApiVersion(2);
static::assertSame(2, Telnyx::getApiVersion());

Telnyx::setVerifySslCerts(true);
static::assertSame(true, Telnyx::getVerifySslCerts());

Telnyx::setAccountId('ACCOUNT38749');
static::assertSame('ACCOUNT38749', Telnyx::getAccountId());

Telnyx::setEnableTelemetry(false);
static::assertSame(false, Telnyx::getEnableTelemetry());

Telnyx::setMaxNetworkRetries(4);
static::assertSame(4, Telnyx::getMaxNetworkRetries());
}
}

0 comments on commit b0c2368

Please sign in to comment.