Added test for weird edge case (which isn't triggering awesome).
This commit is contained in:
parent
7521d0ee82
commit
1ee6dc8115
2 changed files with 19 additions and 2 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
0.2503.202342
|
||||
0.2503.210003
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
// RouterTest.php
|
||||
// Created: 2022-01-20
|
||||
// Updated: 2025-03-19
|
||||
// Updated: 2025-03-21
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
@ -254,6 +254,19 @@ final class RouterTest extends TestCase {
|
|||
public function testOutputBencode(): array {
|
||||
return ['benben' => 12345];
|
||||
}
|
||||
|
||||
#[After('output:bencode')]
|
||||
#[ExactRoute('GET', '/output/bencode/object')]
|
||||
public function testOutputBencodeObject(): object {
|
||||
return new class implements \Index\Bencode\BencodeSerializable {
|
||||
use \Index\Bencode\BencodeSerializableCommon;
|
||||
|
||||
public function __construct(
|
||||
#[\Index\Bencode\BencodeProperty('failure reason')]
|
||||
public private(set) string $reason = 'Invalid info hash.'
|
||||
) {}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
$response = $router->handle(HttpRequest::createRequestWithoutBody('GET', '/output/stream'));
|
||||
|
@ -288,6 +301,10 @@ final class RouterTest extends TestCase {
|
|||
$this->assertSame('application/x-bittorrent', $response->getHeaderLine('Content-Type'));
|
||||
$this->assertSame('d6:benbeni12345ee', (string)$response->getBody());
|
||||
|
||||
$response = $router->handle(HttpRequest::createRequestWithoutBody('GET', '/output/bencode/object'));
|
||||
$this->assertSame('application/x-bittorrent', $response->getHeaderLine('Content-Type'));
|
||||
$this->assertSame('d14:failure reason18:Invalid info hash.e', (string)$response->getBody());
|
||||
|
||||
$response = $router->handle(HttpRequest::createRequestWithoutBody('POST', '/optional-form'));
|
||||
$this->assertSame(200, $response->getStatusCode());
|
||||
$this->assertSame('none', (string)$response->getBody());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue