-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Normalizer and some string length limits.
- Loading branch information
1 parent
33bc18e
commit a9bef5d
Showing
6 changed files
with
184 additions
and
2 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
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,26 @@ | ||
<?php | ||
|
||
namespace Omnipay\SipsPayPage; | ||
|
||
abstract class Normalizer | ||
{ | ||
private static $invalid = array( | ||
'Š'=>'S', 'š'=>'s', 'Đ'=>'Dj', 'đ'=>'dj', 'Ž'=>'Z', 'ž'=>'z', | ||
'Č'=>'C', 'č'=>'c', 'Ć'=>'C', 'ć'=>'c', 'À'=>'A', 'Á'=>'A', 'Â'=>'A', 'Ã'=>'A', | ||
'Ä'=>'A', 'Å'=>'A', 'Æ'=>'A', 'Ç'=>'C', 'È'=>'E', 'É'=>'E', 'Ê'=>'E', 'Ë'=>'E', | ||
'Ì'=>'I', 'Í'=>'I', 'Î'=>'I', 'Ï'=>'I', 'Ñ'=>'N', 'Ò'=>'O', 'Ó'=>'O', 'Ô'=>'O', | ||
'Õ'=>'O', 'Ö'=>'O', 'Ø'=>'O', 'Ù'=>'U', 'Ú'=>'U', 'Û'=>'U', 'Ü'=>'U', 'Ý'=>'Y', | ||
'Þ'=>'B', 'ß'=>'Ss', 'à'=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'a', 'å'=>'a', | ||
'æ'=>'a', 'ç'=>'c', 'è'=>'e', 'é'=>'e', 'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i', | ||
'î'=>'i', 'ï'=>'i', 'ð'=>'o', 'ñ'=>'n', 'ò'=>'o', 'ó'=>'o', 'ô'=>'o', 'õ'=>'o', | ||
'ö'=>'o', 'ø'=>'o', 'ù'=>'u', 'ú'=>'u', 'û'=>'u', 'ý'=>'y', 'ý'=>'y', 'þ'=>'b', | ||
'ÿ'=>'y', 'Ŕ'=>'R', 'ŕ'=>'r', "`" => "'", "´" => "'", "„" => ",", "`" => "'", | ||
"´" => "'", "“" => "\"", "”" => "\"", "´" => "'", "’" => "'", "{" => "", | ||
"~" => "", "–" => "-", "’" => "'", ">" => " ", "<" => " " | ||
); | ||
|
||
public static function normalize($string) | ||
{ | ||
return str_replace(array_keys(self::$invalid), array_values(self::$invalid), $string); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -49,4 +49,40 @@ public function testSendSuccess() | |
|
||
$this->assertEquals($httpResponse->getBody(true), $response->getRedirectResponse()->getContent()); | ||
} | ||
|
||
public function testCardAddress1Limit() | ||
{ | ||
$this->setExpectedException(\Omnipay\Common\Exception\InvalidCreditCardException::class, 'Address1 is too long.'); | ||
$card = new OffsiteCreditCard(); | ||
$card->setEmail('[email protected]'); | ||
$card->setAddress1('uriset aursiet arusiet arusiet rausite nrautie rsauitersauiest i,auice'); | ||
$this->request->setCard($card); | ||
|
||
/** @var \Omnipay\SipsPayPage\Message\PurchaseResponse $response */ | ||
$response = $this->request->send(); | ||
|
||
} | ||
|
||
public function testCardEmail() | ||
{ | ||
$this->setExpectedException(\Omnipay\Common\Exception\InvalidCreditCardException::class, 'The email parameter is required with OffsiteCreditCard.'); | ||
$card = new OffsiteCreditCard(); | ||
$this->request->setCard($card); | ||
|
||
/** @var \Omnipay\SipsPayPage\Message\PurchaseResponse $response */ | ||
$response = $this->request->send(); | ||
|
||
} | ||
|
||
public function testCardNormalize() | ||
{ | ||
$card = new OffsiteCreditCard(); | ||
$card->setAddress1('11 rue Élie Rochette'); | ||
$card->setAddress2('éèàù'); | ||
$card->setFirstName('éèàù'); | ||
|
||
$this->assertEquals('11 rue Elie Rochette', $card->getAddress1()); | ||
$this->assertEquals('eeau', $card->getAddress2()); | ||
$this->assertEquals('eeau', $card->getFirstName()); | ||
} | ||
} |