Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame^] | 1 | <?php |
| 2 | |
| 3 | namespace OAuth2; |
| 4 | |
| 5 | use PHPUnit\Framework\TestCase; |
| 6 | |
| 7 | class 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 | } |