last day (29 days later) » 

12:26 PM
hey
 
hi
hello
 
hi
you get an empty response?
 
I am testing right now and I get a response like:
"""
PHPUnit 7.4.3 by Sebastian Bergmann and contributors.\n
\n
. 1 / 1 (100%)\n
\n
Time: 6.01 seconds, Memory: 22.00MB\n
\n
OK (1 test, 4 assertions)\n
"""
 
i am testing in controller
which laravel version used
?
 
12:29 PM
Yep, the response I see is the same as I run in the console
testing on 5.7
 
i runing on 5.5.28
can u show your controller code?
 
public function index()
{
$process = new Process(array('vendor/bin/phpunit', '--configuration', 'phpunit.xml', '--filter', 'a_visitor_can_access_login_page'), base_path());
$process->run();

// (Optional) Get the phpunit output
dd($process->getOutput());
}
 
i am using passport
 
did you you log process getOutput ?
 
yes i got
pl wait a 5 min
i try
 
12:34 PM
ok
 
12:50 PM
i am using laravel passport package i alwasys get 419
status
if i run using command then works fine
?
 
419 status is for csrf token error
either It expired of Its missing
 
how to slove this error
how to add csrf_token in request
 
If dont csrf validation for that route then in: app\Http\Middleware\VerifyCsrfToken.php add the route in $except
you using axios to make requests?
 
yes
but in testing how to solve
 
What is the code you using to test
 
12:58 PM
post request
 
axios.post?
 
if i add in verfiycsrftoken then working fine
can i pass parameter in phpunit
?
 
Not possible, but to always send the csrf token when making request using axios you could use
window.axios.defaults.headers.common['X-CSRF-TOKEN']
 
yes
now i want to send csrf_token in request with phpunit
how can i pass
 
In phpunit its not neccessary to set the csrf_token, the docs says: the CSRF middleware is automatically disabled when running tests.
 
1:06 PM
not support in laravel 5.5
add new feature in laravel 5.7
 
Not supported? oh wow, give me some mins to examine the source code to see if I can get a workaround
Does it work if you add this method to VerifyCsrfToken.php?
public function handle($request, \Closure $next)
{
if (in_array(env('APP_ENV'), ['local', 'dev'])) {
return $next($request);
}

return parent::handle($request, $next);
}
 
ok i try
same issue
419
 
Is your env value local or dev?
 
i set local
 
and the one in phpunit.xml?
 
1:20 PM
ok
yes working
thanks
 
ok buddy, I am happy to know it works
 
sir can u give ur skypeid
?
 
no using skype, but my email is erickpatrick (at) live
 
erickpatrick@live.com ?
 
1:27 PM
ok can i send mail if any help?
 
I am still new at laravel and programming, but If I know the answer then I can help you.
 
ok thanks once i again
i update your answer also
so pl accept
 
okz thanks. Have a good day.
 

  last day (29 days later) »