Skip to content
This repository has been archived by the owner on Feb 14, 2020. It is now read-only.

Commit

Permalink
Refactor ConnectionControllerTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy Baukema committed Jan 22, 2015
1 parent 65c6759 commit 640f920
Showing 1 changed file with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,32 @@ public function testReturnsEmptyCollection()

public function testReturnsCollection()
{
$this->createConnection();
$createResponse = $this->createConnection();

$this->assertGreaterThanOrEqual(200, $createResponse->getStatusCode(), 'POST /connections.json is in 200 range');
$this->assertLessThanOrEqual(299, $createResponse->getStatusCode(), 'POST /connections.json is in 200 range');

$this->client->request('GET', '/api/connections.json');
$response = $this->client->getResponse();

$this->assertJsonHeader($response);
$this->assertEquals(200, $response->getStatusCode(), $response->getContent());

$expectedResponse = <<<JSON
{"connections":{"1":{"id":1,"name":"test-idp","revisionNr":0,"state":"testaccepted","type":"saml20-idp","allowAllEntities":true,"revisionNote":"initial revision","isActive":true,"updatedByUserName":"admin","createdAtDate":"1970-01-01T00:00:00+0000","updatedAtDate":"1970-01-01T00:00:00+0000","updatedFromIp":"127.0.0.1","metadata":{"SingleSignOnService":[{"Location":"foo"}]},"allowedConnections":[],"blockedConnections":[],"disableConsentConnections":[]}}}
JSON;
$this->assertEquals($expectedResponse, $response->getContent());
$expectedResponse = array (
'connections' =>
array (
1 =>
array (
'id' => 1,
'name' => 'test-idp',
'revisionNr' => 0,
'state' => 'testaccepted',
'type' => 'saml20-idp',
),
),
);
$actualResponse = json_decode($response->getContent(), true);
$this->assertEquals($expectedResponse, $actualResponse);
}

// GET
Expand All @@ -98,7 +112,7 @@ public function testReturnsErrorForNonExistingConnection()

public function testReturnsConnection()
{
$this->createConnection();
$createResponse = $this->createConnection();

$this->client->request('GET', '/api/connections/1.json');
$response = $this->client->getResponse();
Expand Down Expand Up @@ -281,5 +295,6 @@ private function createConnection()
)
)
));
return $this->client->getResponse();
}
}

0 comments on commit 640f920

Please sign in to comment.