@@ -79,15 +79,43 @@ public function test_v2_invalid_maxage_returns_json_400_error(): void
7979 ->assertJsonPath ('error ' , 'Incorrect parameter (maxage must be numeric) ' );
8080 }
8181
82- public function test_v1_movie_requires_query_or_external_id (): void
82+ public function test_v1_movie_without_search_params_returns_recent_movie_feed (): void
8383 {
8484 $ token = (string ) DB ::table ('users ' )->value ('api_token ' );
85+ $ request = Request::create ('/api/v1/api ' , 'GET ' , [
86+ 't ' => 'm ' ,
87+ 'apikey ' => $ token ,
88+ ]);
89+
90+ $ releaseSearchService = Mockery::mock (ReleaseSearchService::class);
91+ $ releaseBrowseService = Mockery::mock (ReleaseBrowseService::class);
92+ $ releaseBrowseService ->shouldReceive ('getBrowseRangeForApi ' )
93+ ->once ()
94+ ->andReturn (collect ());
8595
86- $ response = $ this ->get ('/api/v1/api?t=m&apikey= ' .$ token );
96+ $ controller = new class ($ releaseSearchService , $ releaseBrowseService ) extends ApiController
97+ {
98+ /**
99+ * @var array{data:mixed,params:array<string,mixed>,xml:bool,offset:int,type:string}|null
100+ */
101+ public ?array $ capturedOutput = null ;
87102
88- $ response ->assertOk ();
89- $ response ->assertSee ('<error code="200" ' , false );
90- $ response ->assertSee ('Missing parameter (q, imdbid, tmdbid or traktid) ' , false );
103+ public function output (mixed $ data , array $ params , bool $ xml , int $ offset , string $ type = '' )
104+ {
105+ $ this ->capturedOutput = [
106+ 'data ' => $ data ,
107+ 'params ' => $ params ,
108+ 'xml ' => $ xml ,
109+ 'offset ' => $ offset ,
110+ 'type ' => $ type ,
111+ ];
112+ }
113+ };
114+
115+ $ controller ->api ($ request );
116+ $ this ->assertNotNull ($ controller ->capturedOutput );
117+ $ this ->assertSame ('api ' , $ controller ->capturedOutput ['type ' ]);
118+ $ this ->assertInstanceOf (Collection::class, $ controller ->capturedOutput ['data ' ]);
91119 }
92120
93121 public function test_v1_tv_without_search_params_returns_recent_tv_feed (): void
0 commit comments