File: RegistrationRequestTest.php

package info (click to toggle)
php-code-lts-u2f-php-server 1.2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 208 kB
  • sloc: php: 979; xml: 51; makefile: 7
file content (30 lines) | stat: -rw-r--r-- 948 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php

declare(strict_types = 1);

namespace CodeLts\U2F\U2FServer\Tests;

use CodeLts\U2F\U2FServer\RegistrationRequest;
use PHPUnit\Framework\TestCase;

class RegistrationRequestTest extends TestCase
{

    public function testGetters(): void
    {
        $rr = new RegistrationRequest('yKA0x075tjJ-GE7fKTfnzTOSaNUOWQxRd9TWz5aFOg8', 'http://demo.example.com');
        $this->assertSame('http://demo.example.com', $rr->appId());
        $this->assertSame('yKA0x075tjJ-GE7fKTfnzTOSaNUOWQxRd9TWz5aFOg8', $rr->challenge());
        $this->assertSame('U2F_V2', $rr->version());
    }

    public function testToJson(): void
    {
        $rr = new RegistrationRequest('yKA0x075tjJ-GE7fKTfnzTOSaNUOWQxRd9TWz5aFOg8', 'http://demo.example.com');
        $this->assertSame(
            '{"version":"U2F_V2","challenge":"yKA0x075tjJ-GE7fKTfnzTOSaNUOWQxRd9TWz5aFOg8","appId":"http:\/\/demo.example.com"}',
            json_encode($rr)
        );
    }

}