Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why PHPUnit error ? #22

Open
ztzhu2012 opened this issue Dec 2, 2016 · 6 comments
Open

Why PHPUnit error ? #22

ztzhu2012 opened this issue Dec 2, 2016 · 6 comments

Comments

@ztzhu2012
Copy link

error message:

        Failed to get access token for grant type [password]!

         D:\Works\PHP\vmcmf\vendor\someline\rest-api-client\src\Someline\Rest\RestClient.php:357

         D:\Works\PHP\vmcmf\vendor\someline\rest-api-client\src\Someline\Rest\RestClient.php:401

         D:\Works\PHP\vmcmf\vendor\someline\rest-api-client\src\Someline\Rest\RestClient.php:412

         D:\Works\PHP\vmcmf\tests\Api\BaseApiTestCase.php:52

         D:\Works\PHP\vmcmf\tests\Api\UserTest.php:14

Which should I use access token ?

is .env file's APP_KEY ? or API_TEST_CLIENT_SECRET ?

or OAuthTest.php client_secret ?

The following is my information:

.env

APP_KEY=base64:vJhhQ0/1054RxN84fm5nNDE3nsuN5QSva9aWrLwXcc8=

API_TEST_CLIENT_SECRET=4rZFdBwG698O7t6F84dKRmWglTdEx7hhin15uM2u

OAuthTest.php

'client_secret' => 'GHhWZFvak0iEJ5yh43hP8VVquuZJTp3fPgVIm6mF',

@libern
Copy link
Member

libern commented Dec 3, 2016

have you done php artisan passport:install?

@ztzhu2012
Copy link
Author

When I run this piece of code, it displays message:

Encryption keys generated successfully.
Personal access client created successfully.
Client ID: 1
Client Secret: pLf0kt54KAUPn3R5ON6AryWTcM1NzUOhVuZiAmyG
Password grant client created successfully.
Client ID: 2
Client Secret: q0UGyoSRjU1RXc0K4fhpB9Cdjyz7iMgfNv3SL4nb

but test function testGetAllUsers() error:

D:\wamp\bin\php\php7.0.4\php.exe -ddxdebug.remote_enable=1 -ddxdebug.remote_host=127.0.0.1 -ddxdebug.remote_port=9001 -ddxdebug.remote_mode=req D:/Works/PHP/someline-starter/vendor/phpunit/phpunit/phpunit --no-configuration --filter "/::testGetAllUsers( .*)?$/" UserTest D:\Works\PHP\someline-starter\tests\Api\UserTest.php --teamcity
Testing started at 1:27 ...
PHPUnit 5.6.5 by Sebastian Bergmann and contributors.


Failed to get access token for grant type [password]!
 D:\Works\PHP\someline-starter\vendor\someline\rest-api-client\src\Someline\Rest\RestClient.php:357
 D:\Works\PHP\someline-starter\vendor\someline\rest-api-client\src\Someline\Rest\RestClient.php:401
 D:\Works\PHP\someline-starter\vendor\someline\rest-api-client\src\Someline\Rest\RestClient.php:412
 D:\Works\PHP\someline-starter\tests\Api\BaseApiTestCase.php:52
 D:\Works\PHP\someline-starter\tests\Api\UserTest.php:14

--------
REST CLIENT SERVICE: local, ENVIRONMENT: dev
REST CLIENT BASE URI: http://someline-starter.app/

Response STATUS CODE is 401:
Array
(
    [error] => invalid_client
    [message] => Client authentication failed
)


Time: 1.69 seconds, Memory: 12.00MB


ERRORS!
Tests: 1, Assertions: 0, Errors: 1.

Process finished with exit code 2

I change OAuthTest.php

        'client_id' => '1',
        'client_secret' => 'pLf0kt54KAUPn3R5ON6AryWTcM1NzUOhVuZiAmyG',

The same error occurs, but change

        'client_id' => '2',
        'client_secret' => 'q0UGyoSRjU1RXc0K4fhpB9Cdjyz7iMgfNv3SL4nb',

run PHPUnit is OK.


Other, i run code php artisan migrate --seed to 1071 error. So I change 2014_10_12_100000_create_password_resets_table.php

        $table->string('email',50)->index();
        $table->string('token',200)->index();

@geoidesic
Copy link

I can't figure out how to run the tests. I followed the YouTube video but it's not clear how you got the test to run. You did a bunch of things very quickly which I can't follow. When I click on the Run button it tries to open the test file in a browser window.

@geoidesic
Copy link

I did run php artisan passport:install but I still get errors:

RuntimeException: Failed to get access token for grant type [password]!

... and ...

Response STATUS CODE is 401:
Array
(
    [error] => invalid_client
    [message] => Client authentication failed
)

@geoidesic
Copy link

geoidesic commented Jun 7, 2017

So here's a very specific example of one problem with the phpunit tests. If you disable all the tests except for the Feature tests (by commenting out other testsuite nodes phpunit.xml), then run phpunit it shows an error of Expected status code 200 but received 302. I'm running phpunit from the docroot on the vagrant instance. PHPUnit 5.7.17

I've also tried curl -v 192.168.10.10 from both the vagrant shell and my local shell. The headers show 302 Found. Could this be an nginx config issue? Or it may have something to do with the routes/ folder but I'm not sure exactly what.

Any ideas how to fix this error?

@Muhammadinaam
Copy link

Hi, this is a nice package but I think that the developers have stopped working on it. Maybe you can try this package: https://github.com/Muhammadinaam/speed-admin. It supports Laravel 8+.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants