generated from rich-id/bundle-template
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Dumazeau
committed
Jul 22, 2021
1 parent
af64040
commit ab5361a
Showing
9 changed files
with
125 additions
and
27 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,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace RichId\TermsModuleBundle\Domain\Port; | ||
|
||
use Symfony\Component\Security\Core\User\UserInterface; | ||
|
||
interface SecurityInterface | ||
{ | ||
public function getUser(): ?UserInterface; | ||
} |
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,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace RichId\TermsModuleBundle\Infrastructure\Adapter; | ||
|
||
use RichId\TermsModuleBundle\Domain\Port\SecurityInterface; | ||
use Symfony\Component\Security\Core\Security as SymfonySecurity; | ||
use Symfony\Component\Security\Core\User\UserInterface; | ||
|
||
class Security implements SecurityInterface | ||
{ | ||
/** @var SymfonySecurity */ | ||
protected $security; | ||
|
||
public function __construct(SymfonySecurity $security) | ||
{ | ||
$this->security = $security; | ||
} | ||
|
||
public function getUser(): ?UserInterface | ||
{ | ||
return $this->security->getUser(); | ||
} | ||
} |
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
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,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace RichId\TermsModuleBundle\Tests\Infrastructure\Adapter; | ||
|
||
use RichCongress\TestFramework\TestConfiguration\Annotation\TestConfig; | ||
use RichCongress\TestSuite\TestCase\TestCase; | ||
use RichId\TermsModuleBundle\Infrastructure\Adapter\Security; | ||
use RichId\TermsModuleBundle\Tests\Resources\Entity\DummyUser; | ||
use RichId\TermsModuleBundle\Tests\Resources\Fixtures\DummyUserFixtures; | ||
|
||
/** | ||
* @covers \RichId\TermsModuleBundle\Infrastructure\Adapter\Security | ||
* @TestConfig("fixtures") | ||
*/ | ||
final class SecurityTest extends TestCase | ||
{ | ||
/** @var Security */ | ||
public $adapter; | ||
|
||
public function testGetUserNotLogged(): void | ||
{ | ||
$user = $this->adapter->getUser(); | ||
$this->assertNull($user); | ||
} | ||
|
||
public function testGetUserLogged(): void | ||
{ | ||
$this->authenticate(DummyUser::class, DummyUserFixtures::USER); | ||
|
||
$user = $this->adapter->getUser(); | ||
$this->assertInstanceOf(DummyUser::class, $user); | ||
} | ||
} |