blob: 172bc88fd49b1d3e8c2e2e91e6eca6cd298be7aa [file] [log] [blame]
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +01001<?php
2
3namespace OAuth2;
4
5use PHPUnit\Framework\TestCase;
6
7class ResponseTest extends TestCase
8{
9 public function testRenderAsXml()
10 {
11 $response = new Response(array(
12 'foo' => 'bar',
13 'halland' => 'oates',
14 ));
15
16 $string = $response->getResponseBody('xml');
17 $this->assertContains('<response><foo>bar</foo><halland>oates</halland></response>', $string);
18 }
19
20 public function testSetRedirect()
21 {
22 $response = new Response();
23 $url = 'https://foo/bar';
24 $state = 'stateparam';
25 $response->setRedirect(301, $url, $state);
26 $this->assertEquals(
27 sprintf('%s?state=%s', $url, $state),
28 $response->getHttpHeader('Location')
29 );
30
31 $query = 'query=foo';
32 $response->setRedirect(301, $url . '?' . $query, $state);
33 $this->assertEquals(
34 sprintf('%s?%s&state=%s', $url, $query, $state),
35 $response->getHttpHeader('Location')
36 );
37 }
38}