diff --git a/.scrutinizer.yml b/.scrutinizer.yml index cf46d83..a903494 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -19,7 +19,7 @@ checks: tools: external_code_coverage: timeout: 600 - runs: 3 + runs: 2 php_analyzer: true php_code_coverage: false php_code_sniffer: diff --git a/.travis.yml b/.travis.yml index d1ff8ae..3037852 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: php php: - - 5.4 - 5.5 - 5.6 - 7.0 diff --git a/CHANGELOG.md b/CHANGELOG.md index e8b4c3a..50ee516 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,23 @@ # Changelog All Notable changes to `jobs-indeed` will be documented in this file +## 0.3.2 - 2015-06-07 + +### Added +- Nothing + +### Deprecated +- Nothing + +### Fixed +- Test coverage for Guzzle 6 + +### Removed +- Nothing + +### Security +- Nothing + ## 0.3.1 - 2015-05-24 ### Added diff --git a/composer.json b/composer.json index 03b9e8a..889ac96 100644 --- a/composer.json +++ b/composer.json @@ -18,8 +18,8 @@ } ], "require": { - "php": ">=5.4.0", - "jobbrander/jobs-common": "~0.4" + "php": ">=5.5.0", + "jobbrander/jobs-common": "~0.7" }, "require-dev": { "phpunit/phpunit": "3.7.*", diff --git a/tests/src/IndeedTest.php b/tests/src/IndeedTest.php index baaa438..d00550f 100644 --- a/tests/src/IndeedTest.php +++ b/tests/src/IndeedTest.php @@ -5,10 +5,14 @@ class IndeedTest extends \PHPUnit_Framework_TestCase { + private $clientClass = 'JobBrander\Jobs\Client\Providers\AbstractProvider'; + private $collectionClass = 'JobBrander\Jobs\Client\Collection'; + private $jobClass = 'JobBrander\Jobs\Client\Job'; + public function setUp() { $this->params = [ - 'publisherId' => '3806336598146294', + 'publisherId' => '12345667', 'version' => 2, 'highlight' => 0, ]; @@ -215,21 +219,37 @@ public function testUrlNotIncludesVersionWhenNotProvided() $this->assertNotContains($param, $url); } + public function testItCanCreateJobFromPayload() + { + $payload = $this->createJobArray(); + $results = $this->client->createJobObject($payload); + + $this->assertEquals($payload['jobtitle'], $results->title); + $this->assertEquals($payload['snippet'], $results->description); + $this->assertEquals($payload['company'], $results->company); + $this->assertEquals($payload['url'], $results->url); + $this->assertEquals($payload['jobkey'], $results->sourceId); + $this->assertEquals($payload['formattedLocation'], $results->location); + } + public function testItCanConnect() { - $jobCount = rand(2,10); - $listings = ['results' => $this->getResultItems($jobCount)]; - $source = $this->client->getSource(); - $keyword = 'project manager'; - $city = 'Chicago'; - $state = 'IL'; + $provider = $this->getProviderAttributes(); - $this->client->setKeyword($keyword) - ->setCity($city) - ->setState($state); + for ($i = 0; $i < $provider['jobs_count']; $i++) { + $payload['results'][] = $this->createJobArray(); + } + + $responseBody = json_encode($payload); + + $job = m::mock($this->jobClass); + $job->shouldReceive('setQuery')->with($provider['keyword']) + ->times($provider['jobs_count'])->andReturnSelf(); + $job->shouldReceive('setSource')->with($provider['source']) + ->times($provider['jobs_count'])->andReturnSelf(); $response = m::mock('GuzzleHttp\Message\Response'); - $response->shouldReceive($this->client->getFormat())->once()->andReturn($listings); + $response->shouldReceive('getBody')->once()->andReturn($responseBody); $http = m::mock('GuzzleHttp\Client'); $http->shouldReceive(strtolower($this->client->getVerb())) @@ -240,17 +260,32 @@ public function testItCanConnect() $results = $this->client->getJobs(); - $this->assertCount($jobCount, $results); - - foreach ($listings['results'] as $i => $result) { - $this->assertEquals($listings['results'][$i]['jobtitle'], $results->get($i)->title); - $this->assertEquals($listings['results'][$i]['company'], $results->get($i)->company); - $this->assertEquals($listings['results'][$i]['formattedLocation'], $results->get($i)->location); - $this->assertEquals($listings['results'][$i]['snippet'], $results->get($i)->description); - $this->assertEquals($listings['results'][$i]['url'], $results->get($i)->url); - $this->assertEquals($listings['results'][$i]['jobkey'], $results->get($i)->sourceId); - $this->assertEquals($source, $results->get($i)->source); - $this->assertEquals($keyword, $results->get($i)->query); - } + $this->assertInstanceOf($this->collectionClass, $results); + $this->assertCount($provider['jobs_count'], $results); + } + + private function createJobArray() { + return [ + 'jobtitle' => uniqid(), + 'company' => uniqid(), + 'formattedLocation' => uniqid(), + 'snippet' => uniqid(), + 'url' => uniqid(), + 'jobkey' => uniqid(), + ]; + } + + private function getProviderAttributes($attributes = []) + { + $defaults = [ + 'path' => uniqid(), + 'format' => 'json', + 'keyword' => uniqid(), + 'source' => uniqid(), + 'params' => [uniqid()], + 'jobs_count' => rand(2,10), + + ]; + return array_replace($defaults, $attributes); } }