Skip to content

Commit

Permalink
Adding query and test
Browse files Browse the repository at this point in the history
  • Loading branch information
karllhughes committed Sep 8, 2016
1 parent f2b9c0c commit c2faa23
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 79 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
},
"autoload": {
"psr-4": {
"JobBrander\\Jobs\\Client\\": "src/"
"JobApis\\Jobs\\Client\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"JobBrander\\Jobs\\Client\\Tests\\": "tests/src/"
"JobApis\\Jobs\\Client\\Tests\\": "tests/src/"
}
}
}
105 changes: 32 additions & 73 deletions src/Queries/GithubQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,126 +3,85 @@
class GithubQuery extends AbstractQuery
{
/**
* Direct hire jobs only
*
* @var boolean
*/
protected $direct;

/**
* Jobs' area code
*
* @var string
*/
protected $areacode;

/**
* Country
*
* @var string
*/
protected $country;

/**
* State
* A search term, such as "ruby" or "java". Aliases to "search"
*
* @var string
*/
protected $state;
protected $description;

/**
* Skill to search for
* A search term, such as "ruby" or "java".
*
* @var string
*/
protected $skill;
protected $search;

/**
* City
* A city name, zip code, or other location search term.
*
* @var string
*/
protected $city;
protected $location;

/**
* Search query string
* A specific latitude. If used, you must also send long and must not send location.
*
* @var string
*/
protected $text;
protected $lat;

/**
* IP address that will be used to look up a geocode
* A specific longitude. If used, you must also send lat and must not send location.
*
* @var string
*/
protected $ip;
protected $long;

/**
* Posting age in days
* If you want to limit results to full time positions set this parameter to 'true'.
*
* @var string
*/
protected $age;

/**
* Specific Dice user ID who posted the job
*
* @var string
*/
protected $diceid;

/**
* Page number of results to display
*
* @var integer
*/
protected $page;

/**
* Results per page
*
* @var integer
*/
protected $pgcnt;
protected $full_time;

/**
* Sort parameter:
* sort=1 sorts by posted age
* sort=2 sorts by job title
* sort=3 sorts by company
* sort=4 sorts by location
* Get baseUrl
*
* @var integer
* @return string Value of the base url to this api
*/
protected $sort;
public function getBaseUrl()
{
return 'https://jobs.github.com/positions.json';
}

/**
* Sort direction:
* sd=a sort order is ASCENDING
* sd=d sort order is DESCENDING
* Get keyword
*
* @var string
* @return string Attribute being used as the search keyword
*/
protected $sd;
public function getKeyword()
{
return $this->search;
}

/**
* Get baseUrl
* Get description (alias for search)
*
* @return string Value of the base url to this api
* @return string Attribute being used as the search keyword
*/
public function getBaseUrl()
public function getDescription()
{
return 'http://service.dice.com/api/rest/jobsearch/v1/simple.json';
return $this->search;
}

/**
* Get keyword
* Set description (alias for search)
*
* @return string Attribute being used as the search keyword
*/
public function getKeyword()
public function setDescription($value = null)
{
return $this->text;
$this->search = $value;
return $this;
}
}
8 changes: 4 additions & 4 deletions tests/src/GithubTest.php → tests/src/GithubProviderTest.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php namespace JobBrander\Jobs\Client\Providers\Test;
<?php namespace JobApis\Jobs\Client\Tests;

use DateTime;
use JobBrander\Jobs\Client\Job;
use JobBrander\Jobs\Client\Providers\Github;
use JobApis\Jobs\Client\Job;
use JobApis\Jobs\Client\Providers\Github;
use Mockery as m;

class GithubTest extends \PHPUnit_Framework_TestCase
class GithubProviderTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
{
Expand Down
78 changes: 78 additions & 0 deletions tests/src/GithubQueryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php namespace JobApis\Jobs\Client\Tests;

use JobApis\Jobs\Client\Queries\GithubQuery;
use Mockery as m;

class GithubQueryTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
{
$this->query = new GithubQuery();
}

public function testItCanGetBaseUrl()
{
$this->assertEquals(
'https://jobs.github.com/positions.json',
$this->query->getBaseUrl()
);
}

public function testItCanGetKeyword()
{
$keyword = uniqid();
$this->query->set('search', $keyword);
$this->assertEquals($keyword, $this->query->getKeyword());
}

public function testItCanSetAndGetDescription()
{
$keyword = uniqid();
$this->query->set('description', $keyword);
$this->assertEquals($keyword, $this->query->get('description'));
$this->assertEquals($keyword, $this->query->get('search'));
}

/**
* @expectedException OutOfRangeException
*/
public function testItThrowsExceptionWhenSettingInvalidAttribute()
{
$this->query->set(uniqid(), uniqid());
}

/**
* @expectedException OutOfRangeException
*/
public function testItThrowsExceptionWhenGettingInvalidAttribute()
{
$this->query->get(uniqid());
}

/*
public function testItSetsAndGetsValidAttributes()
{
$attributes = [
'text' => uniqid(),
'country' => uniqid(),
'diceid' => uniqid(),
'sort' => uniqid(),
];
foreach ($attributes as $key => $value) {
$this->query->set($key, $value);
}
foreach ($attributes as $key => $value) {
$this->assertEquals($value, $this->query->get($key));
}
$url = $this->query->getUrl();
$this->assertContains('text=', $url);
$this->assertContains('country=', $url);
$this->assertContains('diceid=', $url);
$this->assertContains('sort=', $url);
}
*/
}

0 comments on commit c2faa23

Please sign in to comment.