public function testBuildPlaylist()
 {
     $responseMock = json_decode(file_get_contents(__DIR__ . '/response_test_data/user_playlists.json'))->items[0];
     $result = $this->valueObjectBuilder->buildPlaylist($responseMock);
     $this->assertEquals($responseMock->collaborative, $result->isCollaborative(), 'Is collaborative should be set');
     $this->assertValueObjectPropertyEquals('href', $responseMock, $result);
     $this->assertValueObjectPropertyEquals('id', $responseMock, $result);
     $this->assertValueObjectPropertyEquals('name', $responseMock, $result);
     $this->assertEquals($responseMock->public, $result->isPublic(), 'Is public should be set');
     $this->assertValueObjectPropertyEquals('snapshot_id', $responseMock, $result);
     $this->assertValueObjectPropertyEquals('type', $responseMock, $result);
     $this->assertValueObjectPropertyEquals('uri', $responseMock, $result);
     $this->assertEquals((array) $responseMock->external_urls, $result->getExternalUrls(), 'External hrefs should be set and be arrays');
     $this->assertTrue($result->getOwner() instanceof Owner, 'Playlist owner should be an Owner');
     $this->assertTrue($result->getTracks() instanceof TracksReference, 'Tracks should be a TracksReference');
     $this->assertTrue(is_array($result->getImages()), 'Images should be an array');
     $this->assertTrue($result->getImages()[0] instanceof Image, 'First object in image array should be an Image');
 }
Exemplo n.º 2
0
 /**
  * Creates a new playlist
  *
  * @param string $name The playlist name
  * @param bool $public
  *
  * @return ValueObject\Playlist
  * @throws SpotifyWebAPIException
  */
 public function createPlaylist($name, $public = true)
 {
     $rawResponse = $this->spotifyWebApi->createUserPlaylist($this->spotifyWebApi->getSpotifyUserId(), ['name' => $name, 'public' => $public]);
     $response = $this->valueObjectBuilder->buildPlaylist($rawResponse);
     return $response;
 }