@@ -53,7 +53,7 @@ |
||
| 53 | 53 | */ |
| 54 | 54 | public function getAccessByRefreshToken(string $refreshAccessToken) : string |
| 55 | 55 | { |
| 56 | - if( $this->session->refreshAccessToken($refreshAccessToken) !== true ) { |
|
| 56 | + if ($this->session->refreshAccessToken($refreshAccessToken) !== true) { |
|
| 57 | 57 | throw new \RuntimeException(Message::ERROR_GET_REFRESH_TOKEN_BY_CODE); |
| 58 | 58 | } |
| 59 | 59 | return $this->session->getAccessToken(); |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | * @param array $options |
| 27 | 27 | * @return string |
| 28 | 28 | */ |
| 29 | - public function getAuthorizeUrl(array $options = []) : string |
|
| 29 | + public function getAuthorizeUrl(array $options = [ ]) : string |
|
| 30 | 30 | { |
| 31 | 31 | return $this->baseSession->getAuthorizeUrl($options); |
| 32 | 32 | } |
@@ -9,7 +9,7 @@ |
||
| 9 | 9 | * @param array $options |
| 10 | 10 | * @return string |
| 11 | 11 | */ |
| 12 | - public function getAuthorizeUrl(array $options = []): string; |
|
| 12 | + public function getAuthorizeUrl(array $options = [ ]): string; |
|
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | 15 | * @param string $authorizationCode |
@@ -2,10 +2,10 @@ |
||
| 2 | 2 | |
| 3 | 3 | use \Xervice\DataProvider\DataProviderConfig; |
| 4 | 4 | |
| 5 | -$config[DataProviderConfig::DATA_PROVIDER_GENERATED_PATH] = dirname(__DIR__) . '/src/Domain/DataTransferObject'; |
|
| 5 | +$config[ DataProviderConfig::DATA_PROVIDER_GENERATED_PATH ] = dirname(__DIR__).'/src/Domain/DataTransferObject'; |
|
| 6 | 6 | |
| 7 | -$config[DataProviderConfig::DATA_PROVIDER_PATHS] = [ |
|
| 8 | - __DIR__ . '/xervice/schema' |
|
| 7 | +$config[ DataProviderConfig::DATA_PROVIDER_PATHS ] = [ |
|
| 8 | + __DIR__.'/xervice/schema' |
|
| 9 | 9 | ]; |
| 10 | 10 | |
| 11 | -$config[DataProviderConfig::DATA_PROVIDER_NAMESPACE] = 'SpotifyApiConnect\\Domain\\DataTransferObject'; |
|
| 12 | 11 | \ No newline at end of file |
| 12 | +$config[ DataProviderConfig::DATA_PROVIDER_NAMESPACE ] = 'SpotifyApiConnect\\Domain\\DataTransferObject'; |
|
| 13 | 13 | \ No newline at end of file |
@@ -1,3 +1,3 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -require __DIR__ . '/../vendor/autoload.php'; |
|
| 3 | +require __DIR__.'/../vendor/autoload.php'; |
|
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * @param array $options |
| 16 | 16 | * @return bool |
| 17 | 17 | */ |
| 18 | - public function addPlaylistTracks($playlistId, array $tracks, array $options = []): bool; |
|
| 18 | + public function addPlaylistTracks($playlistId, array $tracks, array $options = [ ]): bool; |
|
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * @param string $playlistId |
@@ -29,26 +29,26 @@ discard block |
||
| 29 | 29 | * @param array $options |
| 30 | 30 | * @return PlaylistDataProvider |
| 31 | 31 | */ |
| 32 | - public function getPlaylist(string $playlistId, array $options = []): PlaylistDataProvider; |
|
| 32 | + public function getPlaylist(string $playlistId, array $options = [ ]): PlaylistDataProvider; |
|
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * @param $playlistId |
| 36 | 36 | * @param array $options |
| 37 | 37 | * @return PlaylistTracksDataProvider |
| 38 | 38 | */ |
| 39 | - public function getPlaylistTracks(string $playlistId, array $options = []); |
|
| 39 | + public function getPlaylistTracks(string $playlistId, array $options = [ ]); |
|
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | 42 | * @param string $playlistName |
| 43 | 43 | * @param array $options |
| 44 | 44 | * @return PlaylistDataProvider |
| 45 | 45 | */ |
| 46 | - public function getUserPlaylistByName(string $playlistName, array $options = []): PlaylistDataProvider; |
|
| 46 | + public function getUserPlaylistByName(string $playlistName, array $options = [ ]): PlaylistDataProvider; |
|
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * @param TrackSearchRequestDataProvider $trackSearchRequest |
| 50 | 50 | * @param array $options |
| 51 | 51 | * @return TracksSearchDataProvider |
| 52 | 52 | */ |
| 53 | - public function searchTrack(TrackSearchRequestDataProvider $trackSearchRequest, array $options = []): TracksSearchDataProvider; |
|
| 53 | + public function searchTrack(TrackSearchRequestDataProvider $trackSearchRequest, array $options = [ ]): TracksSearchDataProvider; |
|
| 54 | 54 | } |
| 55 | 55 | \ No newline at end of file |
@@ -26,8 +26,8 @@ discard block |
||
| 26 | 26 | { |
| 27 | 27 | $this->config = new Config(); |
| 28 | 28 | foreach ($this->env as $envName => $envValue) { |
| 29 | - $this->env[$envName] = $_ENV[$envName]; |
|
| 30 | - $_ENV[$envName] = null; |
|
| 29 | + $this->env[ $envName ] = $_ENV[ $envName ]; |
|
| 30 | + $_ENV[ $envName ] = null; |
|
| 31 | 31 | } |
| 32 | 32 | parent::setUp(); |
| 33 | 33 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | protected function tearDown(): void |
| 36 | 36 | { |
| 37 | 37 | foreach ($this->env as $envName => $envValue) { |
| 38 | - $_ENV[$envName] = $envValue; |
|
| 38 | + $_ENV[ $envName ] = $envValue; |
|
| 39 | 39 | } |
| 40 | 40 | parent::tearDown(); |
| 41 | 41 | } |
@@ -43,8 +43,8 @@ discard block |
||
| 43 | 43 | public function testGetClientSecret() |
| 44 | 44 | { |
| 45 | 45 | $envValue = 'UnitSecret'; |
| 46 | - $_ENV['CLIENT_SECRET'] = $envValue; |
|
| 47 | - $this->assertSame($envValue,$this->config->getClientSecret()); |
|
| 46 | + $_ENV[ 'CLIENT_SECRET' ] = $envValue; |
|
| 47 | + $this->assertSame($envValue, $this->config->getClientSecret()); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | public function testGetClientSecretException() |
@@ -56,8 +56,8 @@ discard block |
||
| 56 | 56 | public function testGetClientId() |
| 57 | 57 | { |
| 58 | 58 | $envValue = 'UnitId'; |
| 59 | - $_ENV['CLIENT_ID'] = $envValue; |
|
| 60 | - $this->assertSame($envValue,$this->config->getClientId()); |
|
| 59 | + $_ENV[ 'CLIENT_ID' ] = $envValue; |
|
| 60 | + $this->assertSame($envValue, $this->config->getClientId()); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | public function testGetClientIdException() |
@@ -69,8 +69,8 @@ discard block |
||
| 69 | 69 | public function testGetRedirectUri() |
| 70 | 70 | { |
| 71 | 71 | $envValue = 'UnitRedirectUri'; |
| 72 | - $_ENV['REDIRECT_URI'] = $envValue; |
|
| 73 | - $this->assertSame($envValue,$this->config->getRedirectUri()); |
|
| 72 | + $_ENV[ 'REDIRECT_URI' ] = $envValue; |
|
| 73 | + $this->assertSame($envValue, $this->config->getRedirectUri()); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | public function testGetRedirectUriException() |
@@ -82,8 +82,8 @@ discard block |
||
| 82 | 82 | public function testGetSpotifyUsername() |
| 83 | 83 | { |
| 84 | 84 | $envValue = 'UnitSpotifyUserName'; |
| 85 | - $_ENV['SPOTIFY_USERNAME'] = $envValue; |
|
| 86 | - $this->assertSame($envValue,$this->config->getSpotifyUsername()); |
|
| 85 | + $_ENV[ 'SPOTIFY_USERNAME' ] = $envValue; |
|
| 86 | + $this->assertSame($envValue, $this->config->getSpotifyUsername()); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | public function testGetSpotifyUsernameException() |
@@ -28,22 +28,22 @@ |
||
| 28 | 28 | |
| 29 | 29 | $this->assertNotEmpty($redirectUrl, 'authorize url from spotify is empty'); |
| 30 | 30 | $parseRedirectUrl = parse_url($redirectUrl); |
| 31 | - $this->assertSame('accounts.spotify.com', $parseRedirectUrl['host']); |
|
| 32 | - $this->assertSame('/authorize', $parseRedirectUrl['path']); |
|
| 31 | + $this->assertSame('accounts.spotify.com', $parseRedirectUrl[ 'host' ]); |
|
| 32 | + $this->assertSame('/authorize', $parseRedirectUrl[ 'path' ]); |
|
| 33 | 33 | |
| 34 | - $this->assertNotEmpty($parseRedirectUrl['query']); |
|
| 34 | + $this->assertNotEmpty($parseRedirectUrl[ 'query' ]); |
|
| 35 | 35 | |
| 36 | - $info = []; |
|
| 37 | - parse_str($parseRedirectUrl['query'], $info); |
|
| 36 | + $info = [ ]; |
|
| 37 | + parse_str($parseRedirectUrl[ 'query' ], $info); |
|
| 38 | 38 | |
| 39 | - $this->assertSame('code', $info['response_type']); |
|
| 40 | - $this->assertSame($_ENV['REDIRECT_URI'], $info['redirect_uri']); |
|
| 41 | - $this->assertTrue(isset($info['client_id'])); |
|
| 39 | + $this->assertSame('code', $info[ 'response_type' ]); |
|
| 40 | + $this->assertSame($_ENV[ 'REDIRECT_URI' ], $info[ 'redirect_uri' ]); |
|
| 41 | + $this->assertTrue(isset($info[ 'client_id' ])); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | public function testRefreshAccessToken() |
| 45 | 45 | { |
| 46 | - $this->assertTrue($this->session->refreshAccessToken($_ENV['REFRESH_TOKEN'])); |
|
| 46 | + $this->assertTrue($this->session->refreshAccessToken($_ENV[ 'REFRESH_TOKEN' ])); |
|
| 47 | 47 | $this->assertNotEmpty($this->session->getAccessToken()); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | parent::setUp(); |
| 44 | 44 | $spotifyApiConnectFactory = new SpotifyApiConnectFactory(); |
| 45 | 45 | $spotifyApiAuth = $spotifyApiConnectFactory->createSpotifyApiAuth(); |
| 46 | - $accessToken = $spotifyApiAuth->getAccessByRefreshToken($_ENV['REFRESH_TOKEN']); |
|
| 46 | + $accessToken = $spotifyApiAuth->getAccessByRefreshToken($_ENV[ 'REFRESH_TOKEN' ]); |
|
| 47 | 47 | $this->spotifyWebApi = $spotifyApiConnectFactory->createSpotifyWebApi($accessToken); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | public function testGetUserPlaylists(): void |
| 52 | 52 | { |
| 53 | 53 | $spotifyPlaylist = $this->spotifyWebApi->getUserPlaylistByName( |
| 54 | - static::spotifyInfo['playlistName'] |
|
| 54 | + static::spotifyInfo[ 'playlistName' ] |
|
| 55 | 55 | ); |
| 56 | - $this->assertSame(static::spotifyInfo['playlistId'], $spotifyPlaylist->getId()); |
|
| 56 | + $this->assertSame(static::spotifyInfo[ 'playlistId' ], $spotifyPlaylist->getId()); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | public function testGetUserPlaylistsNotFoundPlayList(): void |
@@ -65,29 +65,29 @@ discard block |
||
| 65 | 65 | public function testAddPlaylistTracks() |
| 66 | 66 | { |
| 67 | 67 | $addResult = $this->spotifyWebApi->addPlaylistTracks( |
| 68 | - static::spotifyInfo['playlistId'], |
|
| 68 | + static::spotifyInfo[ 'playlistId' ], |
|
| 69 | 69 | [ |
| 70 | - static::spotifySongInit['trackId'] |
|
| 70 | + static::spotifySongInit[ 'trackId' ] |
|
| 71 | 71 | ] |
| 72 | 72 | ); |
| 73 | 73 | $this->assertTrue($addResult); |
| 74 | 74 | |
| 75 | 75 | $spotifyPlayList = $this->spotifyWebApi->getPlaylistTracks( |
| 76 | - static::spotifyInfo['playlistId'] |
|
| 76 | + static::spotifyInfo[ 'playlistId' ] |
|
| 77 | 77 | ); |
| 78 | 78 | |
| 79 | 79 | $this->assertNotEmpty($spotifyPlayList->getItems()); |
| 80 | 80 | $this->assertNotEmpty($spotifyPlayList->getTotal()); |
| 81 | - $this->assertSame(static::spotifySongInit['trackId'], $spotifyPlayList->getItems()[0]->getTrack()->getId()); |
|
| 82 | - $this->assertSame(static::spotifySongInit['artist'], $spotifyPlayList->getItems()[0]->getTrack()->getArtists()[0]->getName()); |
|
| 83 | - $this->assertSame(static::spotifySongInit['track'], $spotifyPlayList->getItems()[0]->getTrack()->getName()); |
|
| 81 | + $this->assertSame(static::spotifySongInit[ 'trackId' ], $spotifyPlayList->getItems()[ 0 ]->getTrack()->getId()); |
|
| 82 | + $this->assertSame(static::spotifySongInit[ 'artist' ], $spotifyPlayList->getItems()[ 0 ]->getTrack()->getArtists()[ 0 ]->getName()); |
|
| 83 | + $this->assertSame(static::spotifySongInit[ 'track' ], $spotifyPlayList->getItems()[ 0 ]->getTrack()->getName()); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | public function testAddPlaylistTracksNotExistTrackId() |
| 87 | 87 | { |
| 88 | 88 | try { |
| 89 | 89 | $this->spotifyWebApi->addPlaylistTracks( |
| 90 | - static::spotifyInfo['playlistId'], |
|
| 90 | + static::spotifyInfo[ 'playlistId' ], |
|
| 91 | 91 | [ |
| 92 | 92 | 'uniTest-Not_FOUND--ID' |
| 93 | 93 | ] |
@@ -106,12 +106,12 @@ discard block |
||
| 106 | 106 | public function testGetPlaylist(): void |
| 107 | 107 | { |
| 108 | 108 | $spotifyPlayList = $this->spotifyWebApi->getPlaylist( |
| 109 | - static::spotifyInfo['playlistId'] |
|
| 109 | + static::spotifyInfo[ 'playlistId' ] |
|
| 110 | 110 | ); |
| 111 | - $this->assertSame(static::spotifyInfo['playlistId'], $spotifyPlayList->getId()); |
|
| 112 | - $this->assertSame(static::spotifyInfo['playlistName'], $spotifyPlayList->getName()); |
|
| 111 | + $this->assertSame(static::spotifyInfo[ 'playlistId' ], $spotifyPlayList->getId()); |
|
| 112 | + $this->assertSame(static::spotifyInfo[ 'playlistName' ], $spotifyPlayList->getName()); |
|
| 113 | 113 | $this->assertTrue($spotifyPlayList->getPublic()); |
| 114 | - $this->assertSame(self::spotifySongInit['artist'], $spotifyPlayList->getTracks()->getItems()[0]->getTrack()->getArtists()[0]->getName()); |
|
| 114 | + $this->assertSame(self::spotifySongInit[ 'artist' ], $spotifyPlayList->getTracks()->getItems()[ 0 ]->getTrack()->getArtists()[ 0 ]->getName()); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | public function testGetNoExistUserPlaylist(): void |
@@ -134,18 +134,18 @@ discard block |
||
| 134 | 134 | { |
| 135 | 135 | $trackSearchRequestDataProvider = new TrackSearchRequestDataProvider(); |
| 136 | 136 | $trackSearchRequestDataProvider->setArtist( |
| 137 | - static::spotifySong['artist'] |
|
| 137 | + static::spotifySong[ 'artist' ] |
|
| 138 | 138 | ); |
| 139 | 139 | $trackSearchRequestDataProvider->setTrack( |
| 140 | - static::spotifySong['track'] |
|
| 140 | + static::spotifySong[ 'track' ] |
|
| 141 | 141 | ); |
| 142 | 142 | $searchResult = $this->spotifyWebApi->searchTrack($trackSearchRequestDataProvider); |
| 143 | 143 | |
| 144 | 144 | $this->assertGreaterThan(0, $searchResult->getItems()); |
| 145 | 145 | $this->assertSame( |
| 146 | - strtolower(static::spotifySong['track']), |
|
| 146 | + strtolower(static::spotifySong[ 'track' ]), |
|
| 147 | 147 | strtolower( |
| 148 | - $searchResult->getItems()[0]->getName() |
|
| 148 | + $searchResult->getItems()[ 0 ]->getName() |
|
| 149 | 149 | ) |
| 150 | 150 | ); |
| 151 | 151 | } |
@@ -167,24 +167,24 @@ discard block |
||
| 167 | 167 | public function testDeleteUserPlaylistTracks() |
| 168 | 168 | { |
| 169 | 169 | $spotifyPlayList = $this->spotifyWebApi->getPlaylistTracks( |
| 170 | - static::spotifyInfo['playlistId'] |
|
| 170 | + static::spotifyInfo[ 'playlistId' ] |
|
| 171 | 171 | ); |
| 172 | 172 | |
| 173 | 173 | $this->assertCount(1, $spotifyPlayList->getItems()); |
| 174 | 174 | $this->assertSame(1, $spotifyPlayList->getTotal()); |
| 175 | 175 | |
| 176 | 176 | $deleteTrack = new DeleteTrackInfoDataProvider(); |
| 177 | - $deleteTrack->setId(static::spotifySong['trackId']); |
|
| 177 | + $deleteTrack->setId(static::spotifySong[ 'trackId' ]); |
|
| 178 | 178 | |
| 179 | 179 | $result = $this->spotifyWebApi->deletePlaylistTracks( |
| 180 | - static::spotifyInfo['playlistId'], |
|
| 181 | - [$deleteTrack] |
|
| 180 | + static::spotifyInfo[ 'playlistId' ], |
|
| 181 | + [ $deleteTrack ] |
|
| 182 | 182 | ); |
| 183 | 183 | |
| 184 | 184 | $this->assertTrue($result); |
| 185 | 185 | |
| 186 | 186 | $spotifyPlayList = $this->spotifyWebApi->getPlaylistTracks( |
| 187 | - static::spotifyInfo['playlistId'] |
|
| 187 | + static::spotifyInfo[ 'playlistId' ] |
|
| 188 | 188 | ); |
| 189 | 189 | |
| 190 | 190 | $this->assertCount(1, $spotifyPlayList->getItems()); |
@@ -197,8 +197,8 @@ discard block |
||
| 197 | 197 | $deleteTrack = new DeleteTrackInfoDataProvider(); |
| 198 | 198 | $deleteTrack->setId('uniTest-Not_FOUND--ID'); |
| 199 | 199 | $this->spotifyWebApi->deletePlaylistTracks( |
| 200 | - static::spotifyInfo['playlistId'], |
|
| 201 | - [$deleteTrack] |
|
| 200 | + static::spotifyInfo[ 'playlistId' ], |
|
| 201 | + [ $deleteTrack ] |
|
| 202 | 202 | ); |
| 203 | 203 | } catch (\SpotifyWebAPI\SpotifyWebAPIException $e) { |
| 204 | 204 | $this->assertSame( |
@@ -215,40 +215,40 @@ discard block |
||
| 215 | 215 | { |
| 216 | 216 | $this->expectException(\RuntimeException::class); |
| 217 | 217 | $this->spotifyWebApi->deletePlaylistTracks( |
| 218 | - static::spotifyInfo['playlistId'], |
|
| 219 | - ['id' => 'hahaha'] |
|
| 218 | + static::spotifyInfo[ 'playlistId' ], |
|
| 219 | + [ 'id' => 'hahaha' ] |
|
| 220 | 220 | ); |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | public function testDeleteAllSongsInPlaylist() |
| 224 | 224 | { |
| 225 | - $songsIds = include __DIR__ . '/songs_ids.php'; |
|
| 225 | + $songsIds = include __DIR__.'/songs_ids.php'; |
|
| 226 | 226 | $addResult = $this->spotifyWebApi->addPlaylistTracks( |
| 227 | - static::spotifyInfo['playlistId'], |
|
| 227 | + static::spotifyInfo[ 'playlistId' ], |
|
| 228 | 228 | $songsIds |
| 229 | 229 | ); |
| 230 | 230 | $this->assertTrue($addResult); |
| 231 | 231 | |
| 232 | 232 | $spotifyPlayList = $this->spotifyWebApi->getPlaylistTracks( |
| 233 | - static::spotifyInfo['playlistId'] |
|
| 233 | + static::spotifyInfo[ 'playlistId' ] |
|
| 234 | 234 | ); |
| 235 | 235 | |
| 236 | 236 | $this->assertGreaterThan(210, $spotifyPlayList->getItems()); |
| 237 | 237 | |
| 238 | - $deleteTracks = []; |
|
| 238 | + $deleteTracks = [ ]; |
|
| 239 | 239 | foreach ($spotifyPlayList->getItems() as $item) { |
| 240 | 240 | $deleteTrack = new DeleteTrackInfoDataProvider(); |
| 241 | 241 | $deleteTrack->setId($item->getTrack()->getId()); |
| 242 | - $deleteTracks[] = $deleteTrack; |
|
| 242 | + $deleteTracks[ ] = $deleteTrack; |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | $this->spotifyWebApi->deletePlaylistTracks( |
| 246 | - static::spotifyInfo['playlistId'], |
|
| 246 | + static::spotifyInfo[ 'playlistId' ], |
|
| 247 | 247 | $deleteTracks |
| 248 | 248 | ); |
| 249 | 249 | |
| 250 | 250 | $spotifyPlayList = $this->spotifyWebApi->getPlaylistTracks( |
| 251 | - static::spotifyInfo['playlistId'] |
|
| 251 | + static::spotifyInfo[ 'playlistId' ] |
|
| 252 | 252 | ); |
| 253 | 253 | |
| 254 | 254 | $this->assertCount(0, $spotifyPlayList->getItems()); |