Exemple #1
0
            $api->output(403, 'Admin scope is required for editing artist');
            //indicate the requester do not have the required scope for updating artist
            return;
        }
        if (!$api->checkParameterExists('id', $id)) {
            $api->output(400, 'Artist identifier must be provided');
            //artist was not provided, return an error
            return;
        }
        $artist = new Artist($id);
        if (!$artist->populate(['id' => $id])) {
            $api->output(404, 'Artist not found');
            //indicate the artist was not found
            return;
        }
        //adapt and validate object received
        $updatedArtist = $api->query['body'];
        if (!$artist->validateModel($updatedArtist, $errorMessage)) {
            $api->output(400, 'Artist is not valid: ' . $errorMessage);
            //provided user is not valid
            return;
        }
        if (!$artist->update($errorMessage)) {
            $api->output(500, 'Error during artist update' . $errorMessage);
            //something gone wrong :(
            return;
        }
        $artist->getTracks();
        $api->output(200, $artist->structureData());
        break;
}
Exemple #2
0
 /**
  * @covers Artist::getTracks
  */
 public function testGetTracks()
 {
     $this->object->id = 1;
     $result = $this->object->getTracks();
     $this->assertInternalType('array', $result);
 }