SelfSignedTLSClientAuthTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 18
dl 0
loc 32
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetSupportedMethod() 0 4 1
A testCreateRequest() 0 24 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Facile\OpenIDClientTest\AuthMethod;
6
7
use Facile\OpenIDClient\AuthMethod\SelfSignedTLSClientAuth;
8
use Facile\OpenIDClient\Client\ClientInterface;
9
use Facile\OpenIDClient\Client\Metadata\ClientMetadataInterface;
10
use Facile\OpenIDClientTest\TestCase;
11
use Psr\Http\Message\RequestInterface;
12
use Psr\Http\Message\StreamInterface;
13
14
class SelfSignedTLSClientAuthTest extends TestCase
15
{
16
    public function testGetSupportedMethod(): void
17
    {
18
        $auth = new SelfSignedTLSClientAuth();
19
        static::assertSame('self_signed_tls_client_auth', $auth->getSupportedMethod());
20
    }
21
22
    public function testCreateRequest(): void
23
    {
24
        $auth = new SelfSignedTLSClientAuth();
25
26
        $stream = $this->prophesize(StreamInterface::class);
27
        $request = $this->prophesize(RequestInterface::class);
28
        $client = $this->prophesize(ClientInterface::class);
29
        $metadata = $this->prophesize(ClientMetadataInterface::class);
30
31
        $client->getMetadata()->willReturn($metadata->reveal());
32
        $metadata->getClientId()->willReturn('foo');
33
        $metadata->getClientSecret()->shouldNotBeCalled();
34
35
        $stream->write('foo=bar&client_id=foo')->shouldBeCalled();
36
37
        $request->getBody()->willReturn($stream->reveal());
38
39
        $result = $auth->createRequest(
40
            $request->reveal(),
41
            $client->reveal(),
42
            ['foo' => 'bar']
43
        );
44
45
        static::assertSame($request->reveal(), $result);
46
    }
47
}
48