File tree 2 files changed +38
-4
lines changed
2 files changed +38
-4
lines changed Original file line number Diff line number Diff line change @@ -1133,9 +1133,10 @@ public function getMultipleAudioFeatures(string|array $trackIds): array|object
1133
1133
* - string market Optional. ISO 3166-1 alpha-2 country code, provide this if you wish to apply Track Relinking.
1134
1134
* - string|array additional_types Optional. Types of media to return info about.
1135
1135
*
1136
- * @return array|object The user's currently playing track. Type is controlled by the `return_assoc` option.
1136
+ * @return array|object|null The user's currently playing track or null if nothing's currently playing.
1137
+ * Type is controlled by the `return_assoc` option.
1137
1138
*/
1138
- public function getMyCurrentTrack (array |object $ options = []): array |object
1139
+ public function getMyCurrentTrack (array |object $ options = []): array |object | null
1139
1140
{
1140
1141
$ uri = '/v1/me/player/currently-playing ' ;
1141
1142
$ options = (array ) $ options ;
@@ -1172,9 +1173,10 @@ public function getMyDevices(): array|object
1172
1173
* - string market Optional. ISO 3166-1 alpha-2 country code, provide this if you wish to apply Track Relinking.
1173
1174
* - string|array additional_types Optional. Types of media to return info about.
1174
1175
*
1175
- * @return array|object The user's playback information. Type is controlled by the `return_assoc` option.
1176
+ * @return array|object|null The user's playback information or null if nothing's currently playing.
1177
+ * Type is controlled by the `return_assoc` option.
1176
1178
*/
1177
- public function getMyCurrentPlaybackInfo (array |object $ options = []): array |object
1179
+ public function getMyCurrentPlaybackInfo (array |object $ options = []): array |object | null
1178
1180
{
1179
1181
$ uri = '/v1/me/player ' ;
1180
1182
$ options = (array ) $ options ;
Original file line number Diff line number Diff line change @@ -1266,6 +1266,22 @@ public function testGetMyCurrentTrack()
1266
1266
$ this ->assertObjectHasProperty ('item ' , $ response );
1267
1267
}
1268
1268
1269
+ public function testGetMyCurrentTrackEmptyResponse ()
1270
+ {
1271
+ $ return = ['body ' => null ];
1272
+ $ api = $ this ->setupApi (
1273
+ 'GET ' ,
1274
+ '/v1/me/player/currently-playing ' ,
1275
+ [],
1276
+ [],
1277
+ $ return
1278
+ );
1279
+
1280
+ $ response = $ api ->getMyCurrentTrack ([]);
1281
+
1282
+ $ this ->assertNull ($ response );
1283
+ }
1284
+
1269
1285
public function testGetMyDevices ()
1270
1286
{
1271
1287
$ return = ['body ' => get_fixture ('user-devices ' )];
@@ -1308,6 +1324,22 @@ public function testGetMyCurrentPlaybackInfo()
1308
1324
$ this ->assertObjectHasProperty ('item ' , $ response );
1309
1325
}
1310
1326
1327
+ public function testGetMyCurrentPlaybackInfoEmptyResponse ()
1328
+ {
1329
+ $ return = ['body ' => null ];
1330
+ $ api = $ this ->setupApi (
1331
+ 'GET ' ,
1332
+ '/v1/me/player ' ,
1333
+ [],
1334
+ [],
1335
+ $ return
1336
+ );
1337
+
1338
+ $ response = $ api ->getMyCurrentPlaybackInfo ([]);
1339
+
1340
+ $ this ->assertNull ($ response );
1341
+ }
1342
+
1311
1343
public function testGetMyPlaylists ()
1312
1344
{
1313
1345
$ options = ['limit ' => 10 ];
You can’t perform that action at this time.
0 commit comments