first commit

This commit is contained in:
zickkeen committed 2024-03-17 11:39:27 +07:00
commit d0e185820a
2710 files changed
+465112

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
<?php
/**
* SocialConnect project
* @author: Patsura Dmitry @ovr <[email protected]>
*/
namespace Test;
class ClientTest extends \PHPUnit_Framework_TestCase
{
public function testConstructSuccess()
{
$appId = 12345;
$secret = 'mytestkey';
$client = new SimpleClient($appId, $secret);
static::assertInstanceOf('SocialConnect\Common\ClientAbstract', $client);
static::assertSame($appId, $client->getAppId());
static::assertSame($secret, $client->getAppSecret());
}
}
@@ -0,0 +1,43 @@
<?php
/**
* SocialConnect project
* @author: Patsura Dmitry @ovr <[email protected]>
*/
namespace Test\Http\Client;
use SocialConnect\Common\Http\Client\Curl;
class CurlTest extends \PHPUnit_Framework_TestCase
{
public function testConstructSuccess()
{
$client = new Curl();
static::assertInstanceOf('SocialConnect\Common\Http\Client\Client', $client);
}
public function testRequest()
{
$client = new Curl();
$response = $client->request('https://api.dmtry.me/api/users/get/1/');
static::assertInstanceOf('SocialConnect\Common\Http\Response', $response);
static::assertTrue($response->isOk());
static::assertInternalType('string', $response->getBody());
static::assertInternalType('integer', $response->getStatusCode());
static::assertInternalType('object', $response->json());
static::assertInternalType('array', $response->json(true));
static::assertInternalType('array', $response->getHeaders());
/**
* Test after request
*/
static::assertInternalType('resource', $client->getCurlHandler());
}
public function testGetCurlHandler()
{
$client = new Curl();
static::assertInternalType('resource', $client->getCurlHandler());
}
}
@@ -0,0 +1,36 @@
<?php
/**
* SocialConnect project
* @author: Patsura Dmitry @ovr <[email protected]>
*/
namespace Test\Http\Client;
use SocialConnect\Common\Http\Client\Guzzle;
use GuzzleHttp\Client;
class GuzzleTest extends \PHPUnit_Framework_TestCase
{
public function testConstructSuccess()
{
$client = new Guzzle();
static::assertInstanceOf('SocialConnect\Common\Http\Client\Client', $client);
$client = new Guzzle(new Client());
static::assertInstanceOf('SocialConnect\Common\Http\Client\Client', $client);
}
public function testGetRequest()
{
$client = new Guzzle(new Client());
$response = $client->request('https://api.dmtry.me/api/users/get/1/');
static::assertInstanceOf('SocialConnect\Common\Http\Response', $response);
static::assertTrue($response->isOk());
static::assertInternalType('string', $response->getBody());
static::assertInternalType('integer', $response->getStatusCode());
static::assertInternalType('object', $response->json());
static::assertInternalType('array', $response->json(true));
static::assertInternalType('array', $response->getHeaders());
}
}
@@ -0,0 +1,32 @@
<?php
/**
* SocialConnect project
* @author: Patsura Dmitry @ovr <[email protected]>
*/
namespace Test\Http\Client;
use SocialConnect\Common\Http\Response;
class ResponseTest extends \PHPUnit_Framework_TestCase
{
public function testConstructSuccess()
{
static::assertSame(Response::STATUS_OK, 200);
$response = new Response(Response::STATUS_OK, 'test string', array());
static::assertSame(Response::STATUS_OK, $response->getStatusCode());
static::assertSame('test string', $response->getBody());
static::assertTrue($response->isOk());
}
public function testHeadersMethods()
{
$value = '123fdsf23423';
$response = new Response(Response::STATUS_OK, 'test string', array('X-AUTH-TOKEN' => $value));
static::assertFalse($response->hasHeader('X-AUTH'));
static::assertTrue($response->hasHeader('X-AUTH-TOKEN'));
static::assertSame($value, $response->getHeader('X-AUTH-TOKEN'));
}
}