Skip to content

Commit

Permalink
Rename SpotifyWebAPI::replacePlaylistTracks() to SpotifyWebAPI::repla…
Browse files Browse the repository at this point in the history
…ceUserPlaylistTracks()
  • Loading branch information
jwilsson committed Jul 6, 2015
1 parent 2ce8fc5 commit 6362510
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/SpotifyWebAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,16 @@ public function reorderUserPlaylistTracks($userId, $playlistId, $options)
return false;
}

/**
* @deprecated Use SpotifyWebAPI::replaceUserPlaylistTracks() instead. This dummy function will be removed in 1.0.0.
*/
public function replacePlaylistTracks($userId, $playlistId, $tracks)
{
trigger_error('Use SpotifyWebAPI::replaceUserPlaylistTracks() instead', E_USER_DEPRECATED);

return $this->replaceUserPlaylistTracks($userId, $playlistId, $tracks);
}

/**
* Replace all tracks in a user's playlist with new ones.
* Requires a valid access token.
Expand All @@ -1012,7 +1022,7 @@ public function reorderUserPlaylistTracks($userId, $playlistId, $options)
*
* @return bool Whether the tracks was successfully replaced.
*/
public function replacePlaylistTracks($userId, $playlistId, $tracks)
public function replaceUserPlaylistTracks($userId, $playlistId, $tracks)
{
$tracks = $this->idToUri($tracks);
$tracks = array(
Expand Down
25 changes: 25 additions & 0 deletions tests/SpotifyWebAPITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -501,16 +501,22 @@ public function testReorderUserPlaylistTracks()
$this->assertNotFalse($response);
}

// Deprecated test, to be removed in 1.0. See testReplaceUserPlaylistTracksSingle
public function testReplacePlaylistTracksSingle()
{
$this->setExpectedException('PHPUnit_Framework_Error');

$api = $this->setupMock(201);
$response = $api->replacePlaylistTracks('mcgurk', $this->playlistID, '7eEfbAG7wgV4AgkdTakVFT');

$this->assertTrue($response);
}

// Deprecated test, to be removed in 1.0. See testReplaceUserPlaylistTracksMultiple
public function testReplacePlaylistTracksMultiple()
{
$this->setExpectedException('PHPUnit_Framework_Error');

$api = $this->setupMock(201);
$response = $api->replacePlaylistTracks('mcgurk', $this->playlistID, array(
'7kz6GbFr2MCI7PgXJOdq8c',
Expand All @@ -520,6 +526,25 @@ public function testReplacePlaylistTracksMultiple()
$this->assertTrue($response);
}

public function testReplaceUserPlaylistTracksSingle()
{
$api = $this->setupMock(201);
$response = $api->replaceUserPlaylistTracks('mcgurk', $this->playlistID, '7eEfbAG7wgV4AgkdTakVFT');

$this->assertTrue($response);
}

public function testReplaceUserPlaylistTracksMultiple()
{
$api = $this->setupMock(201);
$response = $api->replaceUserPlaylistTracks('mcgurk', $this->playlistID, array(
'7kz6GbFr2MCI7PgXJOdq8c',
'6HM9UgDB38hLDFm7e1RF6W',
));

$this->assertTrue($response);
}

public function testSearchAlbum()
{
$api = $this->setupMock('search-album');
Expand Down

0 comments on commit 6362510

Please sign in to comment.