Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

OPENEUROPA-1208: Write initial tests for resources. #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 46 additions & 1 deletion test/Api/RolesApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@
use \OpenEuropa\SyncopePhpClient\ApiException;
use \OpenEuropa\SyncopePhpClient\ObjectSerializer;

use \OpenEuropa\SyncopePhpClient\Api\RolesApi;
use GuzzleHttp\Client;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\MultipartStream;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\RequestOptions;
use OpenEuropa\SyncopePhpClient\HeaderSelector;

use \OpenEuropa\SyncopePhpClient\Model\RoleTO;

use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Psr7\Response;

/**
* RolesApiTest Class Doc Comment.
*
Expand All @@ -42,6 +57,20 @@
*/
class RolesApiTest extends \PHPUnit_Framework_TestCase
{
/**
* @var ClientInterface
*/
protected $client;

/**
* @var Configuration
*/
protected $config;

/**
* @var HeaderSelector
*/
protected $headerSelector;

/**
* Setup before running any test cases.
Expand All @@ -53,6 +82,9 @@ public static function setUpBeforeClass() {
* Setup before running each test case.
*/
public function setUp() {
// Initialize some needed parameters for RoleApi instance.
$this->config = new Configuration();
$this->headerSelector = new HeaderSelector();
}

/**
Expand All @@ -73,7 +105,20 @@ public static function tearDownAfterClass() {
* Creates a new role..
*
*/
public function testCreateRole() {
public function testCreateRole() { // Create a mock and queue two responses.

// Initialize mocked client.
$mock = new MockHandler([
new Response(200, []),
]);
$handler = HandlerStack::create($mock);
$this->client = new Client(['handler' => $handler]);

$RoleApi = new RolesApi($this->client, $this->config, $this->headerSelector);
$roleTO = new RoleTO([]);
$result = $RoleApi->createRole('tester', $roleTO);

$this->assertEquals($result[1], 200);
}

/**
Expand Down