Skip to content

Commit

Permalink
updated unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MelonSmasher committed Aug 16, 2017
1 parent 5fadff9 commit f106c58
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
21 changes: 21 additions & 0 deletions app/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,27 @@ function jediMasterRoom()

}

/**
* Dummy Address
*
* @return array
*/
function jediMasterAddress()
{
$state = \App\Http\Models\API\State::where('code', 'NY')->firstOrFail();
return [
'account_id' => \App\Http\Models\API\Account::where('identifier', '9999999')->where('username', 'skwall')->firstOrFail()->id,
'addressee' => \App\Http\Models\API\Account::where('identifier', '9999999')->where('username', 'skwall')->firstOrFail()->format_full_name(true),
'organization' => 'Jedi Academy',
'line_1' => '309 X-Wing Drive',
'line_2' => 'Earth',
'city' => 'Troy',
'state_id' => $state->id,
'zip' => 12180,
'country_id' => $state->country->id
];
}

/**
* Returns the LDAP configuration
*
Expand Down
59 changes: 59 additions & 0 deletions tests/integration/api/AddressTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,65 @@ public function fails_to_get_address_by_id_without_auth()
->seeJsonStructure($this->errorStructure);
}

/** @test */
public function can_get_addresses_by_account_id()
{
$account = Account::create(lukeSkywalkerAccount());
Address::create(jediMasterAddress());
$this->get('/api/v1/addresses/account/' . $account->id, ['Authorization' => 'Bearer ' . $this->bearer])
->seeStatusCode(200);
#->seeJsonStructure($this->paginatedStructure); # @todo define this structure
}

/** @test */
public function fails_to_get_addresses_by_account_id_without_auth()
{
$account = Account::create(lukeSkywalkerAccount());
Address::create(jediMasterAddress());
$this->get('/api/v1/addresses/account/' . $account->id)
->seeStatusCode(401)
->seeJsonStructure($this->errorStructure);
}

/** @test */
public function can_get_addresses_by_account_identifier()
{
$account = Account::create(lukeSkywalkerAccount());
Address::create(jediMasterAddress());
$this->get('/api/v1/addresses/identifier/' . $account->identifier, ['Authorization' => 'Bearer ' . $this->bearer])
->seeStatusCode(200);
#->seeJsonStructure($this->paginatedStructure); # @todo define this structure
}

/** @test */
public function fails_to_get_addresses_by_account_identifier_without_auth()
{
$account = Account::create(lukeSkywalkerAccount());
Address::create(jediMasterAddress());
$this->get('/api/v1/addresses/identifier/' . $account->identifier)
->seeStatusCode(401)
->seeJsonStructure($this->errorStructure);
}

/** @test */
public function can_get_addresses_by_account_username()
{
$account = Account::create(lukeSkywalkerAccount());
Address::create(jediMasterAddress());
$this->get('/api/v1/addresses/username/' . $account->username, ['Authorization' => 'Bearer ' . $this->bearer])
->seeStatusCode(200);
#->seeJsonStructure($this->paginatedStructure); # @todo define this structure
}

/** @test */
public function fails_to_get_addresses_by_account_username_without_auth()
{
$account = Account::create(lukeSkywalkerAccount());
Address::create(jediMasterAddress());
$this->get('/api/v1/addresses/username/' . $account->username)
->seeStatusCode(401)
->seeJsonStructure($this->errorStructure);
}

/** @test */
public function can_create_address()
Expand Down

0 comments on commit f106c58

Please sign in to comment.