Our Black Friday sale is now live! All individual subscriptions are 50% OFF. This week only!

phpMick phpMick
2
Hi, I'm doing this: $page = make(Page::class); $response = $this->postJson(route('pages.store'), $page->toArray()); $reload = $page::where('title','=',$page->title)->first(); $this->assertDatabaseHas('other_table',['thingable_id' =&g...
Snapey replied
Solved
rephiscorth rephiscorth
4
I recently updated my App\Exceptions\Handler::render() to use filp/whoops. It works perfectly on browser. Problem is when running phpunit and somethings goes wrong, I get undefined method ErrorException::getStatusCode() instead of the actual error. I...
KevDev KevDev
2
I have this project that has multiple db and connections. <?php return [ 'connections' => [ 'mysql_one' => [ 'driver' => env('DB_DRIVER', 'mysql'), 'url' => env('DATABASE_URL'), 'host' => env...
pazitron pazitron
8
I keep getting "Unable to find a file at path [photoA.jpg]. Failed asserting that false is true." when trying to test image upload. my controller store method: public function store(Request $request) { $validatedData = $request-...
perkola perkola
12
While developing and testing i start my local development server like this php artisan serve --host=0.0.0.0 --port=8080 which results in Laravel development server started on http://0.0.0.0:8080 I am able to access the server from all desktop compute...
pedroroccon pedroroccon
11
Greetings! I'm getting an error 404 in my PHPUnit Tests. After doing my first GET Request, every next requests returns a 404 error. To make easier to understand, I made 2 methods with exactly same tests. The first test returns me success, but the sec...
makopov replied
Solved
robdex robdex
0
Hi everybody. I'm new in L8 and I'm trying to write feature tests for API connection to my model under sanctum middleware. This is an extract of my routes/api.php: Route::middleware(['auth:sanctum'])->group(function () { JsonApi::register('def...
untymage untymage
3
I want to test if the job was delayed in unit testing how can i do that ?...
cosmic_learning cosmic_learning
3
Let's say I have a Client class that uses the Laravel HTTP Client: class BestBuyClient { public function checkAvailability($stockId): StockStatus { ////hard-coded url to simplify the example $url = "https://api.ebay.com/c...
keizah keizah
8
Hello, I have migration where I add foreign key to threads table (https://github.com/keizah7/forum/commit/e1aa1b31555c9469091be178e23f5746c377c080#diff-873a697d9df8d6d454c40acbb165080e) Problem is that in phpunit test sqlite don't set foreign key nul...
cosmic_learning cosmic_learning
6
When it comes to Queue testing in Laravel, I use the provided Queue Fake functionality. However, there is a case where I need to create a Mock for a Job class. I have the following code that pushes a job to a Redis powered queue: $apiRequest-&g...
faraz73 faraz73
2
Hi, i have ReadThreadsTest.php that i want to sort threads by popularity (number of replies ) : class ReadThreadsTest extends TestCase { use DatabaseMigrations; protected $thread; public function setUp(): void { parent::set...
faraz73 replied
Solved
kbuczynski kbuczynski
2
Hello. I have just upgrade one of my smaller project from Laravel 7 to 8 After the successful upgrade with Laravel upgrade guide I am not able to run php artisan test anymore and get error stack in terminal Error Call to undefined method Dote...
keizah keizah
1
I created new laravel project and seems that factories is not working.. Process finished with exit code 11 I have another project with laravel 8, and tests are running successfully with factories.. Where problem can be? /** * A basic test example....
lazos99 lazos99
1
Hi, I am trying to test a sample class and and when I run vendor/bin/phpunit it only runs one test and stops. For example for the below it just outputs a dot (.) that according to the documentation it pass the tests. But if you look at the second met...
lazos99 replied
Solved
deansatch deansatch
5
If I have a UserFactory with a random selection of user types, how can I write this so that it creates 1000 users, but only users with $user->type == 'author' will have a post created. As it stands, every user gets a post which isn't ideal. User:...
shaungbhone shaungbhone
3
hello guys. This$this->assertCount(0, $reply->favorites); is passed when I dd($reply->favorites), it's empty array. Illuminate\Database\Eloquent\Collection^ {#1900 #items: [] } /** @test */ function an_auth_user_can_favorite_any_reply...
chiefguru chiefguru
2
I have a clean L8 installation running under MAMP 6.0 on a Mac and I'm using PHPStorm as IDE. When I try and run the test tests/Feature/ExampleTest.php from within Storm, the assertion fails with a 404 error. It also fails when run from artisan, so m...
CrasyHorse CrasyHorse
0
Hi everyone, I'm working on a project using Laravel 7.24, VueJs 2.6.12 and Vuetify 2.3. E2e testing is done with Cypress. Now I have to write some component tests for a custom VueJs component. In the past I've used vue-test-utils but now I want to us...
untymage untymage
9
I set the QUEUE_CONNECTION in env file to database but in feature test i want to set it as sync to the phpunit.xml has this : <php> <server name="APP_ENV" value="testing"/> <server name="BCRYPT_ROUNDS&q...
jaynarayan jaynarayan
2
Is there any Laravel package for generating boilerplate test for an existing app?...
ivan2nn ivan2nn
0
I have a pivot table for a many-to-many relationship Schema::create('jobs', function (Blueprint $table) { $table->primary(['order_id','user_id']); $table->foreignId('user_id')->constrained('users'); $table->foreign...
shaungbhone shaungbhone
8
Hi, now I'm trying this episode https://laracasts.com/series/lets-build-a-forum-with-laravel/episodes/3?autoplay=true And I got error.! /** @test */ function a_user_can_read_single_threads() { $response = $this->get('en/threads/' ....
pratamatama pratamatama
5
I created a test for my app and find something weird with the authorization stuff which is failing when I enable the exception handling by command described by the title above. This is the result when $this->withoutExceptionHandling() commented ou...
tykus replied
Solved
Elenktik Elenktik
3
I have a service class called updater which I have fully covered with unit tests. Now inside my controller, I have the following method: public function __construct(Updater $updater) { $this->updater = $updater; } public function upd...
robertldeboer robertldeboer
0
I have come across an testing "issue" and was wondering if anyone else had encountered this or if this is correct and I am just crazy. I have units for my application - testing individual controller components, testing route features, etc....
bambamboole bambamboole
6
Hi, I use gitlab ci for testing a laravel 5.5 project which uses redis. I have a REDIS_HOST with the value redis. But in my phpunit pipeline I get the following error: Predis\Connection\ConnectionException: Connection refused [tcp://redis:tcp://172.1...
automica automica
7
I'm currently working on an improvement to a store which involves me writing some tests to check a site navigation works. Currently the site has a main navigation that appears on all pages and then a side navigation that lists a category tree for all...
faraz73 faraz73
6
Hi, I just want to set up some factory in my test class .. but this error occurs : Fatal error: Declaration of Tests\Feature\ReadThreadsTest::setUp() must be compatible with Illuminate\Foundation\Testing\TestCase::setUp(): void in .... this is my te...
trevorpan trevorpan
1
I'd like to know if you can keep authentication between tests using @depends? /** * @test * @depends only_administrators_can_generate_coupons */ public function it_records_a_new_coupon_in_the_database() { // : void this c...
Hi, When running php artisan test the default User factory returns InvalidArgumentException Unknown formatter "name" Using the same factory in for example web.php works fine, it only breaks when it is used in a test. I have tested in a cle...
sboulahr sboulahr
1
I am very new to testing in Laravel, I'm working in laravel 8, the function that I want to test is : When I run my test I get this error: 1) Tests\Unit\appTest\HttpTest\ControllersTest\OrderControllerTest::testStore Invalid JSON was returned from the...
faraz73 faraz73
2
Hi .. i just want to factory a model in my test .. and I got an error like this SQLSTATE[HY000]: General error: 1 no such table: threads ... but it does exist and I have modified phpunit.xml and I have done migration and factoring (i can factory my...
tykus replied
Solved
topvillas topvillas
4
Hello peeps. Please help me out here. I had a fresh installation of L8 with no changes to middleware or authetication and I'm using Pest for testing. For some reason, I'm getting a 401 with this very simple test. The route works perfectly well with P...
ivan2nn ivan2nn
5
Hello, in my migration table I have this defintion on project: $table->foreignId('user_id')->constrained('users'); in my Project Factory I have the following defintion: 'user_id' => function(){ return User::factory()-&...
aleahy replied
Solved
Create a New Discussion Button