Skip to content

Commit

Permalink
Finishing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
karllhughes committed Jan 17, 2016
1 parent bed9d61 commit d75a42a
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ All Notable changes to `infoconnect-php-client` will be documented in this file
- Nothing

### Removed
- Nothing
- Automatic test coverage HTML generation

### Security
- Nothing
Expand Down
69 changes: 67 additions & 2 deletions tests/src/InfoconnectClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,71 @@ public function testItCanGetSearchCompanies()
}
}

public function testItCanPostCountCompanies()
{
$parameters = [
'companyname' => 'Google',
];

$this->client->client = m::mock('GuzzleHttp\Client');
$response = m::mock('Psr\Http\Message\ResponseInterface');

$count = rand(1,500);
$content = '{
"MatchCount": "'.$count.'"
}';

$this->client->client->shouldReceive('request')
->once()
->andReturn($response);
$response->shouldReceive('getStatusCode')
->once()
->andReturn('200');
$response->shouldReceive('getBody')
->once()
->andReturn($response);
$response->shouldReceive('getContents')
->once()
->andReturn($content);

$resultCount = $this->client->postCountCompanies($parameters);

$this->assertTrue(is_int($count));
$this->assertEquals($count, $resultCount);
}

public function testItCanPostSearchCompanies()
{
$parameters = [
'companyname' => 'Google',
'resourcetype' => 'Enhanced',
];

$this->client->client = m::mock('GuzzleHttp\Client');
$response = m::mock('Psr\Http\Message\ResponseInterface');

$content = $this->generateCompanies();

$this->client->client->shouldReceive('request')
->once()
->andReturn($response);
$response->shouldReceive('getStatusCode')
->once()
->andReturn('200');
$response->shouldReceive('getBody')
->once()
->andReturn($response);
$response->shouldReceive('getContents')
->once()
->andReturn($content);

$results = $this->client->postSearchCompanies($parameters);

foreach ($results as $result) {
$this->assertEquals('JobBrander\Clients\Responses\Company', get_class($result));
}
}

/**
* @expectedException \Exception
* @expectedExceptionMessage Invalid response format.
Expand Down Expand Up @@ -164,9 +229,9 @@ public function testItCanPostCountCompaniesWithRealApiKey()
'CompanyName' => 'Google',
];

$count = $this->client->postCountCompanies($parameters);
$resultCount = $this->client->postCountCompanies($parameters);

$this->assertTrue(is_int($count));
$this->assertTrue(is_int($resultCount));
}

public function testItCanPostSearchCompaniesWithRealApiKey()
Expand Down

0 comments on commit d75a42a

Please sign in to comment.