Passport: Create password grant tokens in testing

Created on 11 Oct 2018  ·  3Comments  ·  Source: laravel/passport

  • Laravel Version: 5.7.*
  • PHP Version: 7.2.9
  • Database Driver & Version: sqlite 7.2.9

Description:

I want to test my oauth server (with laravel/passport package).

I use unit tests, I use a memory database with PHPUnit, so I can not migrate the tables created by the package.

I would like to be able to call the following commands in my test:

$this->artisan('passport:client', ['--password' => null, '--no-interaction' => true]);
$this->artisan('passport:keys', ['--no-interaction' => true]);

But, I have this error:

Mockery\Exception\BadMethodCallException: Received Mockery_1_Illuminate_Console_OutputStyle::askQuestion(), but no expectations were specified

I'm sure this is due to the fact that I do not have a fully installed passport but I do not know how to do it.

Steps To Reproduce:

composer require laravel/passport
php artisan passport:client --password
php artisan passport:keys

bug

Most helpful comment

public $mockConsoleOutput = false; in my test worked for me as the upgrade guide suggests

All 3 comments

Think this is indeed a problem with the latest 5.7 release which adds support for testing commands. Will take a thorough look later but feel free to send in a PR if you figure this out yourself.

public $mockConsoleOutput = false; in my test worked for me as the upgrade guide suggests

@sethphillips is right. I totally missed this. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mehrancodes picture mehrancodes  ·  3Comments

huiyonghkw picture huiyonghkw  ·  3Comments

andcl picture andcl  ·  3Comments

soubhikchatterjee picture soubhikchatterjee  ·  4Comments

rudolfdobias picture rudolfdobias  ·  3Comments