public function testGetAlbumTracks()
 {
     $options = array('limit' => 10, 'market' => 'SE');
     $expected = array('limit' => 10, 'market' => 'SE');
     $headers = array('Authorization' => 'Bearer ' . $this->accessToken);
     $return = array('body' => get_fixture('album-tracks'));
     $stub = $this->setupStub('GET', '/v1/albums/1oR3KrPIp4CbagPa3PhtPp/tracks', $expected, $headers, $return);
     $api = new SpotifyWebAPI\SpotifyWebAPI($stub);
     $api->setAccessToken($this->accessToken);
     $response = $api->getAlbumTracks('1oR3KrPIp4CbagPa3PhtPp', $options);
     $this->assertObjectHasAttribute('items', $response);
 }
 $spotify_tracks = new stdClass();
 $spotify_tracks->items = array();
 $spotify_tracks_result = $db->query("select * from tracks where Album_id='" . SQLite3::escapeString($spotify_album_id) . "'");
 while ($track = $spotify_tracks_result->fetchArray()) {
     // Geting tracks using albums id in database.
     //here you have database fetched artist albums tacks. saved during last run. use it
     $item = new stdClass();
     $item->name = $track['Track'];
     $item->external_urls = new stdClass();
     $item->external_urls->spotify = $track['Link'];
     //That's how you fill a dictionary.  If you don't get any tracks with this  -- fill the database with empty uri.
     $spotify_tracks->items[] = $item;
 }
 if (count($spotify_tracks->items) == 0) {
     // search spotify for artist tracks only if database does not contain any albums.
     $spotify_tracks = $api->getAlbumTracks($spotify_album_id);
     foreach ($spotify_tracks->items as $track) {
         $spotify_track_name = $track->name;
         $spotify_track_uri = $track->external_urls->spotify;
         //Filling the database with tracks using id.
         $db->exec('insert into tracks ("Track","Artist","Link", "Album", "Album_id") values (' . "'" . SQLite3::escapeString($spotify_track_name) . "','" . SQLite3::escapeString($artist) . "','" . $spotify_track_uri . "','" . SQLite3::escapeString($spotify_album_name) . "','" . $spotify_album_id . "')");
     }
 }
 /*if (!$album_id) {
 
                                 $db->exec('insert into album ("Album_name","Album_id", "Artist_spotify_id") values ('."'" . SQLite3::escapeString($spotify_album_name) . "','" . $spotify_album_id . "','" . $artist_id . "')");
 
                                 $tracks_in_album = $db->querySingle('select id from tracks where Album_id="' . $spotify_album_id . '" ');
 
                                 $spotify_tracks = $api->getAlbumTracks($spotify_album_id);