Skip to content

Commit

Permalink
Increasing test coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
aperdomo committed Mar 24, 2016
1 parent a0a8fe3 commit 3aa2f81
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 15 deletions.
8 changes: 4 additions & 4 deletions src/Message/AbstractProfileRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ abstract class AbstractProfileRequest extends AbstractRequest

public function getProfileId()
{
return $this->getParameter('profileId');
return $this->getParameter('profile_id');
}

public function setProfileId($value)
{
return $this->setParameter('profileId', $value);
return $this->setParameter('profile_id', $value);
}

public function getCardId()
{
return $this->getParameter('cardId');
return $this->getParameter('card_id');
}

public function setCardId($value)
{
return $this->setParameter('cardId', $value);
return $this->setParameter('card_id', $value);
}

public function getComment()
Expand Down
7 changes: 7 additions & 0 deletions src/Message/DeleteProfileCardRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

class DeleteProfileCardRequest extends DeleteProfileRequest
{
public function getData()
{
$this->validate('profile_id');
$this->validate('card_id');
return;
}

public function getEndpoint()
{
return $this->endpoint . '/' . $this->getProfileId() . '/cards/' . $this->getCardId();
Expand Down
3 changes: 2 additions & 1 deletion src/Message/DeleteProfileRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ class DeleteProfileRequest extends AbstractProfileRequest
{
public function getData()
{
return array();
$this->validate('profile_id');
return;
}

public function getEndpoint()
Expand Down
3 changes: 2 additions & 1 deletion src/Message/FetchProfileRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ class FetchProfileRequest extends AbstractProfileRequest
{
public function getData()
{
return array();
$this->validate('profile_id');
return;
}

public function getEndpoint()
Expand Down
18 changes: 9 additions & 9 deletions tests/GatewayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function testFetchProfile()
{
$request = $this->gateway->fetchProfile(
array(
'profileId' => 1
'profile_id' => 1
)
);
$this->assertInstanceOf('Omnipay\Beanstream\Message\FetchProfileRequest', $request);
Expand All @@ -106,7 +106,7 @@ public function testUpdateProfile()
{
$request = $this->gateway->updateProfile(
array(
'profileId' => 1,
'profile_id' => 1,
'language' => 'test-language',
'comment' => 'test-comment'
)
Expand All @@ -122,7 +122,7 @@ public function testDeleteProfile()
{
$request = $this->gateway->deleteProfile(
array(
'profileId' => 1,
'profile_id' => 1,
)
);
$this->assertInstanceOf('Omnipay\Beanstream\Message\DeleteProfileRequest', $request);
Expand All @@ -134,7 +134,7 @@ public function testCreateProfileCard()
{
$request = $this->gateway->createProfileCard(
array(
'profileId' => 1
'profile_id' => 1
)
);
$this->assertInstanceOf('Omnipay\Beanstream\Message\CreateProfileCardRequest', $request);
Expand All @@ -146,7 +146,7 @@ public function testFetchProfileCards()
{
$request = $this->gateway->fetchProfileCards(
array(
'profileId' => 1
'profile_id' => 1
)
);
$this->assertInstanceOf('Omnipay\Beanstream\Message\FetchProfileCardsRequest', $request);
Expand All @@ -158,8 +158,8 @@ public function testUpdateProfileCard()
{
$request = $this->gateway->updateProfileCard(
array(
'profileId' => 1,
'cardId' => 2
'profile_id' => 1,
'card_id' => 2
)
);
$this->assertInstanceOf('Omnipay\Beanstream\Message\UpdateProfileCardRequest', $request);
Expand All @@ -172,8 +172,8 @@ public function testDeleteProfileCard()
{
$request = $this->gateway->deleteProfileCard(
array(
'profileId' => 1,
'cardId' => 2
'profile_id' => 1,
'card_id' => 2
)
);
$this->assertInstanceOf('Omnipay\Beanstream\Message\DeleteProfileCardRequest', $request);
Expand Down
6 changes: 6 additions & 0 deletions tests/Message/CreateProfileCardRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ public function testCard()
{
$card = $this->getValidCard();
$this->assertSame($this->request, $this->request->setCard($card));
$data = $this->request->getData();
$this->assertSame($card['number'], $data['number']);
$this->assertSame($card['cvv'], $data['cvd']);
$this->assertSame(sprintf("%02d", $card['expiryMonth']), $data['expiry_month']);
$this->assertSame(substr($card['expiryYear'], -2), $data['expiry_year']);
$this->assertSame($card['firstName'] . ' ' . $card['lastName'], $data['name']);
}

public function testHttpMethod()
Expand Down
8 changes: 8 additions & 0 deletions tests/Message/DeleteProfileRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,12 @@ public function testHttpMethod()
{
$this->assertSame('DELETE', $this->request->getHttpMethod());
}

public function testGetData()
{
$this->assertSame($this->request, $this->request->setProfileId('1'));
$this->assertSame('1', $this->request->getProfileId());
$this->assertNull($this->request->getData());
$this->assertSame('DELETE', $this->request->getHttpMethod());
}
}
8 changes: 8 additions & 0 deletions tests/Message/FetchProfileRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,12 @@ public function testHttpMethod()
{
$this->assertSame('GET', $this->request->getHttpMethod());
}

public function testGetData()
{
$this->assertSame($this->request, $this->request->setProfileId('1'));
$this->assertSame('1', $this->request->getProfileId());
$this->assertNull($this->request->getData());
$this->assertSame('GET', $this->request->getHttpMethod());
}
}

0 comments on commit 3aa2f81

Please sign in to comment.