-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #17 Card number should be numeric. Do strip non numeric charact…
…ers from card number, allow only spaces
- Loading branch information
1 parent
ed9a3b8
commit 365ea79
Showing
6 changed files
with
112 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace LVR\CreditCard\Exceptions; | ||
|
||
class CreditCardCharactersException extends CreditCardException | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace LVR\CreditCard\Tests\Unit; | ||
|
||
use LVR\CreditCard\Factory; | ||
use LVR\CreditCard\Cards\Card; | ||
use LVR\CreditCard\Tests\TestCase; | ||
use LVR\CreditCard\Exceptions\CreditCardException; | ||
use LVR\CreditCard\Exceptions\CreditCardCharactersException; | ||
|
||
class CardTest extends TestCase | ||
{ | ||
/** @test **/ | ||
public function it_expects_card_number() | ||
{ | ||
$this->expectException(CreditCardException::class); | ||
|
||
Factory::makeFromNumber(''); | ||
} | ||
|
||
/** @test **/ | ||
public function it_allows_spaces_in_card_numbers() | ||
{ | ||
$this->assertInstanceOf(Card::class, Factory::makeFromNumber('4111 1111 1111 1111')); | ||
} | ||
|
||
/** @test **/ | ||
public function it_checks_if_all_card_number_characters_are_numeric() | ||
{ | ||
$this->expectException(CreditCardCharactersException::class); | ||
|
||
Factory::makeFromNumber('4111111x111111sss111'); | ||
} | ||
|
||
/** @test **/ | ||
public function it_returns_card_name() | ||
{ | ||
$card = Factory::makeFromNumber('4111 1111 1111 1111'); | ||
|
||
$this->assertEquals('visa', $card->name()); | ||
} | ||
|
||
/** @test **/ | ||
public function it_returns_card_brand() | ||
{ | ||
$card = Factory::makeFromNumber('4111 1111 1111 1111'); | ||
|
||
$this->assertEquals('Visa', $card->brand()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters