forked from lexik/LexikJWTAuthenticationBundle
-
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.
- Loading branch information
Showing
4 changed files
with
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Lexik\Bundle\JWTAuthenticationBundle\Services\PayloadEnrichment; | ||
|
||
use Lexik\Bundle\JWTAuthenticationBundle\Services\PayloadEnrichmentInterface; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Security\Core\User\UserInterface; | ||
|
||
class ChainEnrichmentTest extends TestCase | ||
{ | ||
public function testEnrich(): void | ||
{ | ||
$payload = ['foo' => 'bar']; | ||
|
||
$enrichmentFoo = new class () implements PayloadEnrichmentInterface { | ||
public function enrich(UserInterface $user, array &$payload): void | ||
{ | ||
$payload['foo'] = 'baz'; | ||
} | ||
}; | ||
|
||
$enrichmentBar = new class () implements PayloadEnrichmentInterface { | ||
public function enrich(UserInterface $user, array &$payload): void | ||
{ | ||
$payload['bar'] = 'qux'; | ||
} | ||
}; | ||
|
||
$chainEnrichment = new ChainEnrichment([$enrichmentFoo, $enrichmentBar]); | ||
$chainEnrichment->enrich($this->createMock(UserInterface::class), $payload); | ||
|
||
$this->assertEquals(['foo' => 'baz', 'bar' => 'qux'], $payload); | ||
} | ||
} |
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,18 @@ | ||
<?php | ||
|
||
namespace Lexik\Bundle\JWTAuthenticationBundle\Services\PayloadEnrichment; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Security\Core\User\UserInterface; | ||
|
||
class NullEnrichmentTest extends TestCase | ||
{ | ||
public function testEnrich(): void | ||
{ | ||
$payload = ['foo' => 'bar']; | ||
$enrichment = new NullEnrichment(); | ||
$enrichment->enrich($this->createMock(UserInterface::class), $payload); | ||
|
||
$this->assertEquals(['foo' => 'bar'], $payload); | ||
} | ||
} |
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