mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 00:01:21 +00:00
Update APIv2 controller
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user