matt-oakes / PHP-Last.fm-API

PHP Last.fm API is a set of classes which help you gain access to Last.fm's API using PHP. It allows you to get information on users, artists, albums, tracks, groups, events and tags. It also contains geographic API classes to get musical geo information
MIT License
107 stars 45 forks source link

Error while trying to load tests #27

Closed ColorTwist closed 6 years ago

ColorTwist commented 6 years ago

When i try to execute one of the tests (any test) i receive an error: Example: http://localhost/PHP-Last.fm-API-master/tests/Api/AlbumTest.php

I receive error: ( ! ) Fatal error: Class 'Tests\Api\BaseNotAuthenticatedApiTest' not found in C:\www\PHP-Last.fm-API-master\tests\Api\AlbumTest.php on line 13Call Stack#TimeMemoryFunctionLocation10.0008407528{main}( )...\AlbumTest.php:0

I did install all composer and the project dependacies, added .env file, I did try to implement my own test like in the readme file but it always return nothing (blank) (without the BaseNotAuthenticatedApiTest class)

devilcius commented 6 years ago

Try with phpunit tests/Api/ --bootstrap vendor/autoload.php. Let me know if it doesn't work.

ColorTwist commented 6 years ago

I am using WAMP / Windows. How exactly should i exactly that?

devilcius commented 6 years ago

I presume you have phpunit installed. If not, you can install it with composer composer global require "phpunit/phpunit=5.1.*" Then open a cmd and run phpunit tests/Api/ --bootstrap vendor/autoload.php from the root of the project.

ColorTwist commented 6 years ago

Yeah, installed it now. thanks. It writes:

Deprecated: The each() function is deprecated. This message will be suppressed on further calls in C:\Users\User\AppData\Roaming\Composer\vendor\phpunit\phpunit\src\Util\Getopt.php on line 38

Fatal error: Uncaught You must provide a valid api key, api secret, session key and username to test this method!

C:\wamp64\www\PHP-Last.fm-API-master\tests\Api\BaseAuthenticatedApiTest.php:26 C:\wamp64\www\PHP-Last.fm-API-master\tests\Api\AuthenticatedTrackTest.php:22 C:\Users\User\AppData\Roaming\Composer\vendor\phpunit\phpunit\src\TextUI\Command.php:128 C:\Users\User\AppData\Roaming\Composer\vendor\phpunit\phpunit\src\TextUI\Command.php:106

I did provide .env file inside tests/Api/, however, i did not fill: lastfm_token= lastfm_session_key=

devilcius commented 6 years ago

Fill them with a random string then. All test will pass, except for those that need last.fm token and session key. You should pass around 90% of tests.

ColorTwist commented 6 years ago

Hey,

I filled token and session with random keys. I thought i can run tests directly in browsers . Quite new to this methods.

Here is what i get: (i guess some passed):

.........E.......EEEE.............................. 51 / 51 (100%)

Time: 29.36 seconds, Memory: 6.00MB

There were 5 errors:

1) Tests\Api\ArtistTest::testSimilar Error: Cannot use string offset as an array

C:\wamp64\www\PHP-Last.fm-API-master\src\lastfmapi\Api\ArtistApi.php:262 C:\wamp64\www\PHP-Last.fm-API-master\tests\Api\ArtistTest.php:69 C:\Users\User\AppData\Roaming\Composer\vendor\phpunit\phpunit\src\TextUI\Command.php:155 C:\Users\User\AppData\Roaming\Composer\vendor\phpunit\phpunit\src\TextUI\Command.php:106

2) Tests\Api\AuthenticatedTrackTest::testLoveTrack LastFmApi\Exception\ApiFailedException: Invalid session key - Please re-authenticate

C:\wamp64\www\PHP-Last.fm-API-master\src\lastfmapi\Api\BaseApi.php:187 C:\wamp64\www\PHP-Last.fm-API-master\src\lastfmapi\Api\BaseApi.php:261 C:\wamp64\www\PHP-Last.fm-API-master\src\lastfmapi\Api\TrackApi.php:346 C:\wamp64\www\PHP-Last.fm-API-master\tests\Api\AuthenticatedTrackTest.php:32 C:\Users\User\AppData\Roaming\Composer\vendor\phpunit\phpunit\src\TextUI\Command.php:155 C:\Users\User\AppData\Roaming\Composer\vendor\phpunit\phpunit\src\TextUI\Command.php:106

3) Tests\Api\AuthenticatedTrackTest::testUnloveTrack LastFmApi\Exception\ApiFailedException: Invalid session key - Please re-authenticate

C:\wamp64\www\PHP-Last.fm-API-master\src\lastfmapi\Api\BaseApi.php:187 C:\wamp64\www\PHP-Last.fm-API-master\src\lastfmapi\Api\BaseApi.php:261 C:\wamp64\www\PHP-Last.fm-API-master\src\lastfmapi\Api\TrackApi.php:381 C:\wamp64\www\PHP-Last.fm-API-master\tests\Api\AuthenticatedTrackTest.php:42 C:\Users\User\AppData\Roaming\Composer\vendor\phpunit\phpunit\src\TextUI\Command.php:155 C:\Users\User\AppData\Roaming\Composer\vendor\phpunit\phpunit\src\TextUI\Command.php:106

4) Tests\Api\AuthenticatedTrackTest::testScrobbleASingleTrack LastFmApi\Exception\ApiFailedException: Invalid session key - Please re-authenticate

C:\wamp64\www\PHP-Last.fm-API-master\src\lastfmapi\Api\BaseApi.php:187 C:\wamp64\www\PHP-Last.fm-API-master\src\lastfmapi\Api\BaseApi.php:261 C:\wamp64\www\PHP-Last.fm-API-master\src\lastfmapi\Api\TrackApi.php:561 C:\wamp64\www\PHP-Last.fm-API-master\tests\Api\AuthenticatedTrackTest.php:53 C:\Users\User\AppData\Roaming\Composer\vendor\phpunit\phpunit\src\TextUI\Command.php:155 C:\Users\User\AppData\Roaming\Composer\vendor\phpunit\phpunit\src\TextUI\Command.php:106

5) Tests\Api\AuthenticatedTrackTest::testScrobbleABatchOfTracks LastFmApi\Exception\ApiFailedException: Invalid session key - Please re-authenticate

C:\wamp64\www\PHP-Last.fm-API-master\src\lastfmapi\Api\BaseApi.php:187 C:\wamp64\www\PHP-Last.fm-API-master\src\lastfmapi\Api\BaseApi.php:261 C:\wamp64\www\PHP-Last.fm-API-master\src\lastfmapi\Api\TrackApi.php:561 C:\wamp64\www\PHP-Last.fm-API-master\tests\Api\AuthenticatedTrackTest.php:71 C:\Users\User\AppData\Roaming\Composer\vendor\phpunit\phpunit\src\TextUI\Command.php:155 C:\Users\User\AppData\Roaming\Composer\vendor\phpunit\phpunit\src\TextUI\Command.php:106

Fatal error: Uncaught Error: Call to undefined method PHPUnit_Framework_TestResult::warningCount() in C:\Users\User\AppData\Roaming\Composer\vendor\phpunit\phpunit\src\TextUI\ResultPrinter.php:185 Stack trace:

0 C:\wamp64\www\PHP-Last.fm-API-master\vendor\phpunit\phpunit\src\TextUI\TestRunner.php(446): PHPUnit_TextUI_ResultPrinter->printResult(Object(PHPUnit_Framework_TestResult))

1 C:\Users\User\AppData\Roaming\Composer\vendor\phpunit\phpunit\src\TextUI\Command.php(155): PHPUnit_TextUI_TestRunner->doRun(NULL, Array)

2 C:\Users\User\AppData\Roaming\Composer\vendor\phpunit\phpunit\src\TextUI\Command.php(106): PHPUnit_TextUI_Command->run(Array, true)

3 C:\Users\User\AppData\Roaming\Composer\vendor\phpunit\phpunit\phpunit(47): PHPUnit_TextUI_Command::main()

4 {main}

thrown in C:\Users\User\AppData\Roaming\Composer\vendor\phpunit\phpunit\src\TextUI\ResultPrinter.php on line 185

devilcius commented 6 years ago

Yes, 46 of 51 passed. 5 failed (those that need the token or session key).

ColorTwist commented 6 years ago

Thanks.