-
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
Showing
5 changed files
with
246 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\Test\OpenID\Factories; | ||
|
||
use Jose\Component\Signature\Algorithm\SignatureAlgorithm; | ||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use PHPUnit\Framework\TestCase; | ||
use SimpleSAML\OpenID\Algorithms\AlgorithmManager; | ||
use SimpleSAML\OpenID\Algorithms\SignatureAlgorithmBag; | ||
use SimpleSAML\OpenID\Factories\AlgorithmManagerFactory; | ||
use SimpleSAML\OpenID\SupportedAlgorithms; | ||
|
||
#[CoversClass(AlgorithmManagerFactory::class)] | ||
class AlgorithmManagerFactoryTest extends TestCase | ||
{ | ||
protected MockObject $supportedAlgorithmsMock; | ||
protected MockObject $signatureAlgorithmBagMock; | ||
protected MockObject $signatureAlgorithmMock; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->supportedAlgorithmsMock = $this->createMock(SupportedAlgorithms::class); | ||
$this->signatureAlgorithmBagMock = $this->createMock(SignatureAlgorithmBag::class); | ||
$this->signatureAlgorithmMock = $this->createMock(SignatureAlgorithm::class); | ||
|
||
$this->supportedAlgorithmsMock->method('getSignatureAlgorithmBag') | ||
->willReturn($this->signatureAlgorithmBagMock); | ||
$this->signatureAlgorithmBagMock->method('getAllInstances') | ||
->willReturn([ | ||
$this->signatureAlgorithmMock, | ||
]); | ||
} | ||
|
||
protected function sut(): AlgorithmManagerFactory | ||
{ | ||
return new AlgorithmManagerFactory(); | ||
} | ||
|
||
public function testCanCreateInstance(): void | ||
{ | ||
$this->assertInstanceOf( | ||
AlgorithmManagerFactory::class, | ||
$this->sut(), | ||
); | ||
} | ||
|
||
public function testCanBuild(): void | ||
{ | ||
$this->assertInstanceOf( | ||
AlgorithmManager::class, | ||
$this->sut()->build($this->supportedAlgorithmsMock), | ||
); | ||
} | ||
} |
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,46 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\Test\OpenID\Factories; | ||
|
||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use PHPUnit\Framework\Attributes\UsesClass; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use PHPUnit\Framework\TestCase; | ||
use Psr\SimpleCache\CacheInterface; | ||
use SimpleSAML\OpenID\Decorators\CacheDecorator; | ||
use SimpleSAML\OpenID\Factories\CacheDecoratorFactory; | ||
|
||
#[CoversClass(CacheDecoratorFactory::class)] | ||
#[UsesClass(CacheDecorator::class)] | ||
class CacheDecoratorFactoryTest extends TestCase | ||
{ | ||
protected MockObject $cacheInterfaceMock; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->cacheInterfaceMock = $this->createMock(CacheInterface::class); | ||
} | ||
|
||
protected function sut(): CacheDecoratorFactory | ||
{ | ||
return new CacheDecoratorFactory(); | ||
} | ||
|
||
public function testCacnCreateInstance(): void | ||
{ | ||
$this->assertInstanceOf( | ||
CacheDecoratorFactory::class, | ||
$this->sut(), | ||
); | ||
} | ||
|
||
public function testCanBuild(): void | ||
{ | ||
$this->assertInstanceOf( | ||
CacheDecorator::class, | ||
$this->sut()->build($this->cacheInterfaceMock), | ||
); | ||
} | ||
} |
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,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\Test\OpenID\Factories; | ||
|
||
use DateInterval; | ||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use PHPUnit\Framework\Attributes\UsesClass; | ||
use PHPUnit\Framework\TestCase; | ||
use SimpleSAML\OpenID\Decorators\DateIntervalDecorator; | ||
use SimpleSAML\OpenID\Factories\DateIntervalDecoratorFactory; | ||
|
||
#[CoversClass(DateIntervalDecoratorFactory::class)] | ||
#[UsesClass(DateIntervalDecorator::class)] | ||
class DateIntervalDecoratorFactoryTest extends TestCase | ||
{ | ||
protected DateInterval $dateInterval; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->dateInterval = new DateInterval('P1D'); | ||
} | ||
|
||
protected function sut(): DateIntervalDecoratorFactory | ||
{ | ||
return new DateIntervalDecoratorFactory(); | ||
} | ||
|
||
public function testCanCreateInstance(): void | ||
{ | ||
$this->assertInstanceOf(DateIntervalDecoratorFactory::class, $this->sut()); | ||
} | ||
|
||
public function testCanBuild(): void | ||
{ | ||
$this->assertInstanceOf( | ||
DateIntervalDecorator::class, | ||
$this->sut()->build($this->dateInterval), | ||
); | ||
} | ||
} |
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,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\Test\OpenID\Factories; | ||
|
||
use GuzzleHttp\Client; | ||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use PHPUnit\Framework\Attributes\UsesClass; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use PHPUnit\Framework\TestCase; | ||
use SimpleSAML\OpenID\Decorators\HttpClientDecorator; | ||
use SimpleSAML\OpenID\Factories\HttpClientDecoratorFactory; | ||
|
||
#[CoversClass(HttpClientDecoratorFactory::class)] | ||
#[UsesClass(HttpClientDecorator::class)] | ||
class HttpClientDecoratorFactoryTest extends TestCase | ||
{ | ||
protected MockObject $clientMock; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->clientMock = $this->createMock(Client::class); | ||
} | ||
|
||
protected function sut(): HttpClientDecoratorFactory | ||
{ | ||
return new HttpClientDecoratorFactory(); | ||
} | ||
|
||
public function testCanCreateInstance(): void | ||
{ | ||
$this->assertInstanceOf(HttpClientDecoratorFactory::class, $this->sut()); | ||
} | ||
|
||
public function testCanBuild(): void | ||
{ | ||
$this->assertInstanceOf( | ||
HttpClientDecorator::class, | ||
$this->sut()->build($this->clientMock), | ||
); | ||
} | ||
} |
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,58 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\Test\OpenID\Factories; | ||
|
||
use Jose\Component\Signature\Serializer\JWSSerializer; | ||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use PHPUnit\Framework\Attributes\UsesClass; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use PHPUnit\Framework\TestCase; | ||
use SimpleSAML\OpenID\Factories\JwsSerializerManagerFactory; | ||
use SimpleSAML\OpenID\Serializers\JwsSerializerBag; | ||
use SimpleSAML\OpenID\Serializers\JwsSerializerManager; | ||
use SimpleSAML\OpenID\SupportedSerializers; | ||
|
||
#[CoversClass(JwsSerializerManagerFactory::class)] | ||
#[UsesClass(JwsSerializerManager::class)] | ||
class JwsSerializerManagerFactoryTest extends TestCase | ||
{ | ||
protected MockObject $supportedSerializersMock; | ||
protected MockObject $jwsSerializerBagMock; | ||
protected MockObject $jwsSerializerMock; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->supportedSerializersMock = $this->createMock(SupportedSerializers::class); | ||
$this->jwsSerializerBagMock = $this->createMock(JwsSerializerBag::class); | ||
$this->jwsSerializerMock = $this->createMock(JwsSerializer::class); | ||
|
||
$this->supportedSerializersMock->method('getJwsSerializerBag') | ||
->willReturn($this->jwsSerializerBagMock); | ||
|
||
$this->jwsSerializerBagMock->method('getAllInstances') | ||
->willReturn([$this->jwsSerializerMock]); | ||
} | ||
|
||
protected function sut(): JwsSerializerManagerFactory | ||
{ | ||
return new JwsSerializerManagerFactory(); | ||
} | ||
|
||
public function testCanCreateInstance(): void | ||
{ | ||
$this->assertInstanceOf( | ||
JwsSerializerManagerFactory::class, | ||
$this->sut(), | ||
); | ||
} | ||
|
||
public function testCanBuild(): void | ||
{ | ||
$this->assertInstanceOf( | ||
JwsSerializerManager::class, | ||
$this->sut()->build($this->supportedSerializersMock), | ||
); | ||
} | ||
} |