Update APIv2 controller

This commit is contained in:
DariusIII
2026-07-12 12:03:34 +02:00
parent 11734a4163
commit 1e6c6f5193
2 changed files with 69 additions and 15 deletions
+44
View File
@@ -146,6 +146,50 @@ class ApiRequestMatrixTest extends TestCase
$this->assertSame([], $secondResponse->getData(true)['results']);
}
public function test_v2_search_keeps_category_separator_unescaped_in_json_body(): void
{
$token = (string) DB::table('users')->value('api_token');
$request = Request::create('/api/v2/search', 'GET', [
'api_token' => $token,
'id' => 'ubuntu',
]);
$releaseSearchService = Mockery::mock(ReleaseSearchService::class);
$releaseSearchService->shouldReceive('apiSearch')
->once()
->with('ubuntu', -1, 0, 100, -1, [5030], [-1], 0, 'posted_desc')
->andReturn(collect([
(object) [
'_totalrows' => 1,
'searchname' => 'Ubuntu.Movie.Release',
'guid' => 'movie-release-guid',
'categories_id' => 2040,
'category_name' => 'Movies > WEBDL',
'adddate' => '2026-01-03 00:00:00',
'size' => 123456,
'totalpart' => 10,
'grabs' => 2,
'comments' => 1,
'passwordstatus' => 0,
'postdate' => '2026-01-02 00:00:00',
],
]));
$releaseBrowseService = Mockery::mock(ReleaseBrowseService::class);
$releaseBrowseService->shouldNotReceive('getBrowseRangeForApi');
$controller = new ApiV2Controller(app(ApiController::class), $releaseSearchService, $releaseBrowseService);
$response = $controller->apiSearch($request);
$content = $response->getContent();
$this->assertSame(200, $response->getStatusCode());
$this->assertIsString($content);
$this->assertSame('Movies > WEBDL', $response->getData(true)['results'][0]['category_name']);
$this->assertStringContainsString('"category_name":"Movies > WEBDL"', $content);
$this->assertStringNotContainsString('\u003E', $content);
}
public function test_v1_search_reuses_cached_release_rows(): void
{
$token = (string) DB::table('users')->value('api_token');