jjmu15 jjmu15
2

Opposite of assertJsonFragment

Hi, Apologies if this is a silly question but how would I test for the opposite of assertJsonFragment to be sure that a record is not returned within a resource coll...
jjmu15 replied
Solved
longestdrive longestdrive
1

Cypress & Laravel - Persist user login

Further journey on cypress To avoid having to login a user each time on my tests I've been looking at ways of persisting the login session. Found this guidanc...
josebailon josebailon
2

Laravel 8 - Factory namespace when developing package

I'm learning how to develop packages for Laravel. When I try to use Factory on tests it fails because it tries to use a Factory with a fully qualified class name made by Da...
trevorpan trevorpan
4

add HasFactory trait to Model::class() vs. each model?

If each model extends: <?php namespace App\Models; ... class Order extends Model { Is it reasonable to just add it to the Model class?...
marcoCarcangiu marcoCarcangiu
3

Laravel Dusk not picking up APP_URL in .env.dusk.local file

Laravel dusk does not seem to use the APP_URL set in .env.dusk.local file. This is my .env.dusk.local file: APP_URL=http://local.project/ BASE_URL=h...
Testing
3
1814
miguellima miguellima
3

Laravel Test Pass when run single test, but fails when running all tests

Hi, everyone, So I just got stuck on testing, because when I ran my test individually it got success. When I run all tests, that test fails. When I ena...
jeFFF jeFFF
6

Deploy migrations for test env only

Hello there, I think the question is explicit but let be more precise. A client of mine have a DB which is created and seeded by his system, on top of that I have a...
Testing
6
1914
ZMChris ZMChris
0

Laravel 7 HTTP test with a Mock Object

Hi there, We are struggling to see how we might be able to test a payment platform (it's an SDK written by the provider themselves and it uses their own built cURL l...
longestdrive longestdrive
0

Cypress - Cannot read property 'add' of undefined

Hi I'm new to testing with Cypress and wading my way through but have come across an error I can't seem to resolve. In my tests I'm using Laravel/Cypress package and...

Testing with sqlite CONSTRAINT name issue

I'm updating from laravel 5.8 to 6 the issue is that all of my tests, that are depending on the database, are failing. The error I'm getting is: Illuminate\D...
nadj replied
Solved
Testing
4
126
yoeriboven yoeriboven
0

Test validation without HTTP session

I'm picking up some techniques from Jetstream but testing isn't optimal. Here's my action class and test. namespace App\Actions;...
Brainmaniac Brainmaniac
1

Run all my dusk test files

Hi! I have two different files containing one dusk test each. How can I run both/all my files? They are both placed in the Browser folder. When I run php artis...
automica automica
3

Testing Artisan Commands when developing vendor packages

I am working on adding some tests to a vendor package that provides 6 artisan commands. I'm working with it in a repo separate to my Laravel 8 installation and have...
manojow manojow
3

Cannot declare class. Conflicts between legacy and eloquent factories

I created new eloquent factories to my new project that I recently updated to laravel 8. Now when I want to test with phpunit I get this message Cannot declare class...
digitalhuman digitalhuman
5

Laravel 5.4 PHP Unit Test missing methods and not working

Hi all, I have been googling for a while now end stranded everytime. I use Laravel 5.4. What I try to do is to get a basic UnitTest (the build in artisan test) to wo...
Testing
5
2030
havvtom havvtom
3

Getting unknown formatter name when running tests

May you help me, identifying what I am doing wrong!!! I am getting an error when running my tests. My factory is as below <?php namespace Database\Factor...
ismaile replied
Solved
madsem madsem
1

Tests individually green, run together red... Ideas?

Hey Guys, Can anybody tell me why these tests turn green when run individually, but when run together in sequence the last one (fallback), turns red?...
RichardJeffery RichardJeffery
0

L8, Jetstream, spatie/laravel-permission - Guard switching to Sanctum

Setup: Laravel 8 Jetstream (Teams and API features disabled) Spatie's laravel-permissions package (Role and Permission models come from here) Issue: Wh...
Testing
0
133

Default User factory gives InvalidArgumentException: Unknown formatter "name"

Hi, When running php artisan test the default User factory returns InvalidArgumentException Unknown formatter "name"...
ismaile replied
Solved
keizah keizah
9

SQLite foreign key dont set null on delete in phpunit test

Hello, I have migration where I add foreign key to threads table (...
Testing
9
1535
LiamA LiamA
3

local.ERROR: Argument 1 passed to Illuminate\Auth\SessionGuard::login() must implement interface Illuminate\Contracts\Auth\Authenticatable, null given

I'm trying to run a simple Dusk test where I create a user, log in as that user, and then assert that the logged in user is an authenticated one. Here is the very simple co...
chrismay chrismay
1

aspectmock Class Eloquent was not found by locator

I have installed aspectmock and codeception, but I get InvalidArgumentException : Class Eloquent was not found by locator when I try to use it in my tests....
Testing
1
321
LiamA LiamA
9

SImple Dusk test from manual fails

I'm trying to follow the instructions here: https://laravel.c...
Testing
9
304
longestdrive longestdrive
2

Cypress and Laravel - testing principles questions

Hi I've just started looking at using cypress to test my front end and whilst I get most of it I'm trying to get my head around the best approaches to handle access to the...
Testing
2
119
giacholari giacholari
5

No application key - Github action for Laravel

I have setup the default laravel github actions for my project but I get an error that the application key is not set. Any idea? GITHUB WORKFLOW name: Build...
Testing
5
136
jjmeyer jjmeyer
5

What is the Laravel 8 replacement for factory->raw()

In upgrading from Laravel 7 to Laravel 8, I changed out the legacy factory approach for the new factory. It was relatively painless however;...
jjmeyer replied
Solved
Testing
5
264
lionweb lionweb
1

Commands testing

Hello, I want to test database changes performed by scheduled command, but after I creaded testing data and call command which should remove row, I still see that ro...
jewishmoses jewishmoses
1

How to assert paginations in Laravel?

I have a category model with the following method: public static function index() { return self::has('posts')->paginate(1); }...
Arnouxor Arnouxor
0

Testing Passport and HTTP Requests maker

Hello guys! During my unit tests when I call two times the same Passport webservice with two differents access token (with two different Scope), Laravel seems to kee...
bencarter78 bencarter78
1

Testing CONCAT queries with SQLite

Hi I am testing my application and have set it up to use a sqlite in-memory database. How would you go about testing the following knowing that the CONCAT doesn't wo...
Testing
1
280
Charrua Charrua
6

TDD how do you test backend and frontend

Hi, I'm new to TDD. As I'm developing my app at the moment I'm only using phpunit with assertions and HTTP tests. At this moment I'm testing features, functionalitie...
Testing
6
217
Dzale Dzale
3

Laravel Sanctum - Unit tests for logout via token

Hey guys, i've noticed a strange thing when writing unit tests for logout. Method: public function destroy(): JsonResponse { auth()-&g...
Testing
3
532
xico2k xico2k
0

Multiple User Session on same Feature Test

Hey Guys, So I need to build a test, and the goal is to have the same user login on multiple devices, and after a threshold on users logged in it will remove the ses...
tobyreed tobyreed
8

Laravel Factory creating model but when Database is queried it's not there

Hi, In my tests I am using a factory for my "process" but the issue is when I am running my test it does not throw any errors and when I dd the model that...
Testing
8
136

authorization fail

but the test pass as status 200 not 403...
Create a New Discussion Button