-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding tests for Oauth Provider authenticaion
- Loading branch information
Showing
13 changed files
with
340 additions
and
207 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,6 +1,4 @@ | ||
<?php | ||
|
||
|
||
use Phinx\Seed\AbstractSeed; | ||
|
||
class UserSeeder extends AbstractSeed | ||
|
This file was deleted.
Oops, something went wrong.
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,16 @@ | ||
<?php declare(strict_types=1); | ||
|
||
use Illuminate\Database\Eloquent\Collection; | ||
use Laminas\Authentication\Result; | ||
use Mockery\Mock; | ||
use Noesis\Auth\Adapter\GithubAuthentication; | ||
|
||
test('GithubAuthentication::validate', function () { | ||
/** @var GithubAuthentication|Mock $githubAuthentication */ | ||
$githubAuthentication = mock(GithubAuthentication::class)->makePartial(); | ||
$githubAuthentication->shouldReceive( 'getUsersWhere')->andReturn(new Collection(['testuser'])); | ||
|
||
$githubAuthentication->setEmail('[email protected]'); | ||
expect($githubAuthentication->authenticate() instanceof Result)->toBeTrue(); | ||
expect($githubAuthentication->authenticate()->isValid())->toBeTrue(); | ||
}); |
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,16 @@ | ||
<?php declare(strict_types=1); | ||
|
||
use Illuminate\Database\Eloquent\Collection; | ||
use Laminas\Authentication\Result; | ||
use Mockery\Mock; | ||
use Noesis\Auth\Adapter\LinkedinAuthentication; | ||
|
||
test('LinkedinAuthentication::validate', function () { | ||
/** @var LinkedinAuthentication|Mock $linkedinAuthentication */ | ||
$linkedinAuthentication = mock(LinkedinAuthentication::class)->makePartial(); | ||
$linkedinAuthentication->shouldReceive( 'getUsersWhere')->andReturn(new Collection(['testuser'])); | ||
|
||
$linkedinAuthentication->setEmail('[email protected]'); | ||
expect($linkedinAuthentication->authenticate() instanceof Result)->toBeTrue(); | ||
expect($linkedinAuthentication->authenticate()->isValid())->toBeTrue(); | ||
}); |
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,16 @@ | ||
<?php declare(strict_types=1); | ||
|
||
use Illuminate\Database\Eloquent\Collection; | ||
use Laminas\Authentication\Result; | ||
use Mockery\Mock; | ||
use Noesis\Auth\Adapter\TwitterAuthentication; | ||
|
||
test('TwitterAuthentication::validate', function () { | ||
/** @var TwitterAuthentication|Mock $twitterAuth */ | ||
$twitterAuth = mock(TwitterAuthentication::class)->makePartial(); | ||
$twitterAuth->shouldReceive( 'getUsersWhere')->andReturn(new Collection(['testuser'])); | ||
|
||
$twitterAuth->setUsername('testuser'); | ||
expect($twitterAuth->authenticate() instanceof Result)->toBeTrue(); | ||
expect($twitterAuth->authenticate()->isValid())->toBeTrue(); | ||
}); |
This file was deleted.
Oops, something went wrong.
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,19 @@ | ||
<?php declare(strict_types=1); | ||
|
||
use Noesis\Support\Session; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use SlimSession\Helper; | ||
|
||
test('Session calls Request::getAttribute with string "session"', function () { | ||
$request = mock(ServerRequestInterface::class) | ||
->expect( | ||
getAttribute: function ($attribute) { | ||
// We only return a Helper instance if 'session' is passed | ||
return ($attribute === 'session') ? new Helper : false; | ||
} | ||
); | ||
|
||
$session = Session::from($request); | ||
|
||
expect($session instanceof Helper)->toBeTrue(); | ||
}); |
Oops, something went wrong.