aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/bshaffer/oauth2-server-php/test/OAuth2/ResponseTest.php
blob: 172bc88fd49b1d3e8c2e2e91e6eca6cd298be7aa (plain) (blame)
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
31
32
33
34
35
36
37
38
<?php

namespace OAuth2;

use PHPUnit\Framework\TestCase;

class ResponseTest extends TestCase
{
    public function testRenderAsXml()
    {
        $response = new Response(array(
            'foo' => 'bar',
            'halland' => 'oates',
        ));

        $string = $response->getResponseBody('xml');
        $this->assertContains('<response><foo>bar</foo><halland>oates</halland></response>', $string);
    }

    public function testSetRedirect()
    {
        $response = new Response();
        $url = 'https://foo/bar';
        $state = 'stateparam';
        $response->setRedirect(301, $url, $state);
        $this->assertEquals(
            sprintf('%s?state=%s', $url, $state),
            $response->getHttpHeader('Location')
        );

        $query = 'query=foo';
        $response->setRedirect(301, $url . '?' . $query, $state);
        $this->assertEquals(
            sprintf('%s?%s&state=%s', $url, $query, $state),
            $response->getHttpHeader('Location')
        );
    }
}