Laravel (5.8)’de test yazarken
php artisan make:test FooTest
ile testi oluşturup
$response = $this->json('POST', '/api/v1/foo/bar', ['param1' => 'value1']);
$response->assertOk()->assertJsonCounts(1, 'reports');
şeklinde talep testi yapabiliyoruz.
Fakat eğer uygulamanızda Telescope kullanıyorsanız şu hatayı almanız muhtemel:
[message] => Class env does not exist
[exception] => ReflectionException
[file] => /.../vendor/laravel/framework/src/Illuminate/Container/Container.php
[line] => 794
Bu durumda phpunit.xml
dosyanıza <env name="TELESCOPE_ENABLED" value="false"/>
satırını eklerseniz, Telescope’u test sırasında pasif duruma getirmiş olursunuz. Böylelikle hatayı almayacaksınız.
Kolay gelsin.