sjgianotti sjgianotti
3
Hello! I'm sort of new to TDD methodology and have a small question about how to properly write HTTP Feature tests. I've inherited a system which has 3 user guards: Users, Vendors, and Admin. There is a Polymorphic relationship to the entity Address...
BrownieCoffee BrownieCoffee
15
Hello guys, are are you? Can you help me to fix this error please? I try since 1 week to fix that but nothing yet. I did test to know if a user can login public function user_can_login_with_valid_fields(){ $user = factory(User::class, 1...
saulsolorzano saulsolorzano
1
Hi! I'm using laravel 8.5 and laravel Sail. I have the following code Bus::fake(); Mail::fake(); TheProductDoesNotExists::dispatch($this->channel, $document['product'], $document['name']); Bus::assertDispatched(TheProductDoesNotExists::class); Mai...
saulsolorzano saulsolorzano
3
Hi! I'm using laravel 8.5 and laravel Sail. I'm trying to test a job but is not being dispatched, no matter what I do. Here's my code Event::fake(); TheProductDoesNotExists::dispatch($this->channel, $document['product'], $document['name']); Event:...
esbensp esbensp
3
Hey guys, The class \Illuminate\Foundation\Testing\Concerns\MakesHttpRequests is used by Laravel in test cases so you can test and endpoint (like $this->post) the bug I am facing is that if I call $request->getContent(); in my controller it wil...
jrdavidson jrdavidson
1
I'm trying to figure out what I'm doing wrong in my test. Currently my test passes until it hits the assertSessionHas('company_id', null) part of the test. Currently the test is failing due to Session is missing expected key [company_id]. I go throu...
gcbenlloch gcbenlloch
1
I'm starting learning tests and I'm a bit stuck in one in particular I'm making a book selling website for a school and I have 3 models, book, publisher and grade, when getting all books i do a join and get the publisher name as a field named "p...
talentia talentia
6
Within my PHPUnit test I'm trying to assert that an API endpoint properly stores the data sent to it. In my database I have a field called settings which stores data using the type: JSON. Everything works just fine. I just can't get PHPUnit to accept...
keizah replied
Solved
keizah keizah
1
I'm using ray and it works everywhere except tests. Where problem can be? https://spatie.be/docs/ray/v1/introduction /** @test */ function user_can_create_translatable_category() { ray('test'); $this->assertTrue(true); }...
keizah replied
Solved
Hello, I'm onto a new personal project and following Uncle Bob's advices (Clean Code) I thought it'd be good to give it a shot to test every line of code. That includes testing validation rules, which I wasn't familiar with until now. But I have a bi...
ecd replied
Solved
futurefuture futurefuture
3
Love the idea of this feature in L8! However, I am using sqlite in memory for phpunit - anyone know how to implement the schema:dump just for sqlite in memory for tests??...
kossa kossa
7
Hello, I'm starting new Laravel app for an existing app, I dont want to create or copy old migration, so in old app I generated schema, I copied the schema to the new app. When I run : php artisan migrate I have all old table, but in testing(using me...
jeFFF jeFFF
2
Hello there, Quick question about factories. I'm trying to create 20 models and each one should have a different start date. In my test I'm doing this which works without any problem : $tickets = Ticket::factory()->count(20)->active()->creat...
jeFFF replied
Solved
Spyralex Spyralex
1
I have my ProductFactory as below: class ProductFactory extends Factory { protected $model = Product::class; public function definition(): array { static $order_column = 1; return [ 'title' => $this->fa...
I know there used to be an Inertia testing packing, but it has since been merged into Laravel as the new json testing helpers. But I don't understand how I would test a simple controller method like this: public function show(Client $client) { re...
Swaz replied
Solved
debjit debjit
18
Here is my test code. <?php namespace Tests\Feature; use App\Providers\RouteServiceProvider; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Foundation\Testing\WithFaker; use Tests\TestCase; class UserRegistrationTest extends...
Salvis Salvis
0
Hi guys. I'm not able to get route prefix added to a url, when calling the route() helper function from a feature test. Within a test I set Auth::company($user->defaultCompany) and I'm able to retrieve the value by calling Auth::company() just fin...
2tunnels 2tunnels
4
I have a method on my controller: public function show($slug) { $category = Category::whereSlug($slug)->firstOrFail(); } I want to write a simple test: public function testCagegoryDoesNotExist() { $this->visit('category/lorem')->ass...
Kusanagi Kusanagi
4
Hello, is there a way to test my website to see how fast it is with a certain number of traffic, so that I could better plan on which web hosting server I should get ?...
jrrmcalcio jrrmcalcio
3
Hello, what is the best way to test inertia with Jest? I have been trying to test but i'm unable to inject/mock the $inertia and the $page objects into my component instance. I tried to initialize it via localVue but still can't make it work... have...
Spyralex Spyralex
1
In order to handle the database error connection during a database interaction using eloquent I am using a try - catch statement. Now I want to turn off the database in one of my phpunit tests to test that behavior. How can I do that?...
Kusanagi Kusanagi
1
Hello, so I am testing my website with telescope and the average time for one request is about 250ms ( that is because I load a lot of images when making the request, the queries only take 1ms at most ) But what does that mean if I were to publish my...
MirasMustimov MirasMustimov
2
Hi, i am mocking an interface and two of its methods are called. I want to mock only one method. but i do get Mockery\Exception\BadMethodCallException: Received Mockery_2_Domain_Location_Repository_LocationRepositoryInterface::persist(), but no expec...
JoshWegener JoshWegener
18
Hello, I'm working with database factories today, I was wondering how one would seed this? Factory, Create 50 Users With 2 Threads (per user) and has 4 Replies (per Thread) // App\Models\Thread class Thread extends Model { use HasFactory; pu...
lemmon replied
Solved
Wakanda Wakanda
13
I have a test that can test if an admin can edit products and when I run it I get the error Failed asserting that two strings are equal. how can I fix this? Test public function test_admin_can_edit_products() { $this->withExceptionHand...
mohib_ullah mohib_ullah
1
i was trying to test my newly created package by running bellow code public function testBasicTest() { $response = $this->call('GET','/'); $response->assertStatus(200); } and getting this error [email protected]:~/home-re...
laracoft laracoft
6
I have a scenario where I need to test the creation/update of purchase orders, However, to test that, suppliers have to exists first. Also, to test updates, purchase orders must be created first. If I break up the tests in Can_create_PO, Can_update_P...
ServiceDeliveryCode ServiceDeliveryCode
2
Hello! I'm generating enough test data now that the unique method is starting to throw errors about exceeded threshold. What is the way to reset the 'used values cache' between say test suites? I understand I have to get access to the same Faker inst...
LiamA LiamA
5
Hi, Is the only way to test cookies is using the withCookie() method? I mean, I have a middleware defined where I check if a cookie is defined. If it's not, then I'm attaching a cookie to the request: public function handle(Request $request, Closure...
sardar1592 sardar1592
1
Hi, I am running Laravel dusk tests in the AWS code build pipeline for a Laravel monolith. And while they are all passing locally, they are throwing a lot of timeout exceptions when running in code build. I have tried adding pauses but the errors are...
Maged Maged
2
I have this table order_products migration but i forgot the quantity field after adding many data, so i did this php artisan make:migration add_quantity_to_order_products_table and added it and it's works fine and the field was added but now all unit...
paulomanrique paulomanrique
1
Is there a way to record a video of Laravel Dusks tests with the browser, instead of having to take screenshots all around?...
huntwu huntwu
4
laravel 6, Passport 7 I have a controller method that would access client id from the token created by passport. The grant type is Authorization Code grant function example(Request $request) { $clientId = $request->user()->token()->client-...
jmacdiarmid jmacdiarmid
7
I'm following the TDD workflow and trying to test Post and resource routing. I have read several posts here and on other sites that have indicated that the csrf function is needed if using a form. I'm not there yet (using Dusk) just phpunit at the mo...
bradycharron bradycharron
0
I have been using Passport::actingAsClient in PHPUnit tests in a new project, and have found that my tests are passing without any explicit assertions in the tests. After debugging why, I found that the actingAsClient method is doing shouldReceive a...
Create a New Discussion Button