-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from portier/feat-normalize-local
Local implementation of normalization
- Loading branch information
Showing
6 changed files
with
125 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
parameters: | ||
ignoreErrors: | ||
# Invalid type hint | ||
- '|^Parameter #1 \$value of class FG\\ASN1\\Universal\\Integer constructor expects int, string given\.$|' |
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 |
---|---|---|
|
@@ -2,16 +2,49 @@ | |
|
||
namespace Tests; | ||
|
||
use \Portier\Client; | ||
|
||
class ClientTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
public function testLocalNormalize() | ||
{ | ||
if (!Client\Client::hasNormalizeLocal()) { | ||
return; | ||
} | ||
|
||
$valid = [ | ||
['[email protected]', '[email protected]'], | ||
['[email protected]', '[email protected]'], | ||
// Simple case transformation | ||
['BJÖRN@göteborg.test', 'bjö[email protected]'], | ||
// Special case transformation | ||
['İⅢ@İⅢ.example', 'i̇ⅲ@xn--iiii-qwc.example'], | ||
]; | ||
foreach ($valid as $pair) { | ||
list($i, $o) = $pair; | ||
$this->assertEquals(Client\Client::normalizeLocal($i), $o); | ||
} | ||
|
||
$invalid = [ | ||
'foo', | ||
'foo@', | ||
'@foo.example', | ||
'[email protected]', | ||
'foo@[::1]', | ||
]; | ||
foreach ($invalid as $i) { | ||
$this->assertEquals(Client\Client::normalizeLocal($i), ''); | ||
} | ||
} | ||
|
||
public function testAuthenticate() | ||
{ | ||
$store = $this->prophesize(\Portier\Client\StoreInterface::class); | ||
$store = $this->prophesize(Client\StoreInterface::class); | ||
$store->createNonce('[email protected]') | ||
->willReturn('foobar') | ||
->shouldBeCalled(); | ||
|
||
$client = new \Portier\Client\Client( | ||
$client = new Client\Client( | ||
$store->reveal(), | ||
'https://example.com/callback' | ||
); | ||
|