Browse AI Field GuideForum Podcast
All ThreadsLeaderboard
  1. Discussions

    1. Popular This Week
    2. Popular All Time
    3. Solved
    4. Unsolved
    5. No Replies Yet

ziggyspider's avatar

how browserSync makes livereload with a .test domain?

how makes browserSync works with domain? not localhost by example if I run this: mix.browserSync({ proxy: "mysite.test" }); I got his: [Browsersync] Proxying: http://mysite.test [Browsersync] Access URLs: --------------------------------------- Local: http://localhost:3000 External: http://192.168.100.16:3000 ---------------------------------

ziggyspider's avatar
ziggyspider's avatar ziggyspide...5yrs agoMix
1
1
Last reply by ziggyspider 5yrs ago
Ajvanho's avatar

Test does table contain rows

How to test does DB::table('posts'); contain data - rows ?

Ajvanho's avatar
Ajvanho's avatar MichalOrav...5yrs agoLaravel
1
1
Last reply by MichalOravec 5yrs ago
rajeshtva's avatar

Assertsee function test passing correctly even when it should fail

I have a simple test in which i am creating a model instance and then. i am visiting a route to check the details of that model object. i have just defined a controller file and there is no function defined in there. The view file is not created. then i am asserting to see some string in the blade file. l am sharing all codes. yet i see all test passing when it should fail. te

rajeshtva's avatar
rajeshtva's avatar lukas6534yrs agoLaravel
6
1
Last reply by lukas653 4yrs ago
rslanzi's avatar

How to test HTTP attach() with a faker uploaded file

I have a method on a controller that receive a file upload and then retransmits via HTTP Client to an external post API route. It works but I'm unable to test it properly: when I retrive to get the fake storage file (with Storage::get()) I obtain an empty string and so the attach() method on the HTTP call fails with this error: InvalidArgumentException: A 'contents' key is requ

rslanzi's avatar
rslanzi's avatar rslanzi5yrs agoTesting
2
1
Last reply by rslanzi 5yrs ago
marbobo's avatar

How do you UNIT test your controller?

Hi. I really dont do unit testing on my controllers classes. And I just got a tasks that requires me to do it. can you guys give me some idea on how to UNIT test a controller class ?

marbobo's avatar
marbobo's avatar automica3yrs agoTesting
8
2
Last reply by automica 3yrs ago
Crazylife's avatar

How to delete s3 image in feature test?

In my feature test was using Storage::fake('s3'), but when calling my api to delete the image then it will throw error as my API using Storage::disk('s3')->delete($path). Any idea how i can achieve this?

Crazylife's avatar
Crazylife's avatar martinbean5yrs agoLaravel
3
3
Last reply by martinbean 5yrs ago
rajeshtva's avatar

how to test certain parameters on Model instance and its table.

I am creating a model and i want to test properties of a model like whether it shows and store date in specified format like in case of date and time but not limited to it. its table name is 'some_name', it has relation with other model with specified foreign keys. its some fields are guarded. some of its field are hidden. its primary key is some other keys like 'username' ins

rajeshtva's avatar
rajeshtva's avatar neilstee5yrs agoLaravel
7
1
Last reply by neilstee 5yrs ago
farshadf's avatar

how to check if an array has subkey in laravel test

hi , i have a multi dimention array that i want to write test for . i read on web that there was a function called arrayHasSubKey but it does not exists any more it seems . i am using laravel 5.8 and i want to check if this array has a subkey this is what my array looks like : key =>value [ key2 =>value2 [ key3 => [ key4 =>value4, key5=>value5 ] ] ] n

farshadf's avatar
farshadf's avatar sr575yrs agoLaravel
1
1
Last reply by sr57 5yrs ago
FrazeColder's avatar

Laravel Reset Password Notification does not get dispatched in test but does send an email

I am writing tests for my Laravel project. Right now I am testing the authentication code like login, logout, reset password and so on. Sadly, my test is failing because there is no notification send. I have mocked the notifications but assertSendTo always fails with the reason The expected [Illuminate\Auth\Notifications\ResetPassword] notification was not sent.. However, when

FrazeColder's avatar
FrazeColder's avatar FrazeColde...5yrs agoGeneral
6
1
Last reply by FrazeColder 5yrs ago
outofcontrol's avatar

Unable to get phpunit to test user role correctly

The goal is to test if the administrator to a site can see the administration dashboard. We are using Laravel 8 with Spatie laravel-permission v3.18. Roles work correctly when testing manually in the browser. My code // routes/web.php Route::group(['middleware' => ['role:admin']], function () { Route::middleware(['auth:sanctum', 'verified'])->get('/administration', fu

outofcontrol's avatar
outofcontrol's avatar outofcontr...5yrs agoCode Review
3
1
Last reply by outofcontrol 5yrs ago
marbobo's avatar

How do you test a function that returns a Generator?

Hi I have a simple service that will fetch a data api and then loop it with generator. and i dont have any idea how will i do it. please see below some example of what class that i want to test. class Service { public function fetchData() { $response = Http::get('https://external.api/data'); if ($response->status() === 200) { foreach ($response->json()['data']

marbobo's avatar
marbobo's avatar tisuchi5yrs agoTesting
3
1
Last reply by tisuchi 5yrs ago
iamamirsalehi's avatar

How to write some test for a controller that is using repository pattern

Hey there. How can I write some test for a controller that is using repository pattern?

iamamirsalehi's avatar
iamamirsalehi's avatar isamirsale...5yrs agoLaravel
6
1
Last reply by isamirsalehi 5yrs ago
TobiasS's avatar

Sqlite test database do not update when added columns

Hi! I have added a column, and changed one columnname in a new migration. I'm running Postgres. For my test I use Sqlite. Schema::table('log_services', function (Blueprint $table) { $table->date('end')->nullable(); $table->renameColumn('date', 'start'); }); The new migration look like above I get the following errormessage SQLSTATE[HY0

TobiasS's avatar
TobiasS's avatar ahinkle2yrs agoTesting
5
16
Last reply by ahinkle 2yrs ago
ahmeda's avatar

How to make a test for image file?

I have this code to store a new post (it's work as testing manually) public function store(PostRequest $request, Post $post) { $data = $request->validated(); $request->image->store('post_images'); $data['image'] = $request->image->hashName(); $post->create($data); return redirect()->route('posts.index'); } My test: /** @test */

ahmeda's avatar
ahmeda's avatar rabeea5yrs agoTesting
8
1
Last reply by rabeea 5yrs ago
cosminc's avatar

Trying to write a unit test for a service that dispaches a job

Hello, I'm currently implementing an API (using Laravel 8.26.1) that has an endpoint which receives an array of e-mails and sends those e-mails asynchronously. Everything is working fine so far, but I'm willing to write a couple of unit tests for this behavior. First, I have a controller with a send() method that calls a service like so: class MyController extends Controller {

cosminc's avatar
cosminc's avatar martinbean5yrs agoTesting
8
1
Last reply by martinbean 5yrs ago
reakky's avatar

Cannot test livewire file upload

Hey, I am trying to test a livewire file upload. This is my test case: public function test_task_document_can_be_uploaded() { $this->withExceptionHandling(); Storage::fake('local'); $file = UploadedFile::fake()->create('document.pdf', 256); $category = DocumentCategory::factory()->create(); #dump('In Test: ' . $fi

reakky's avatar
reakky's avatar reakky5yrs agoLivewire
9
1
Last reply by reakky 5yrs ago
spbaniya's avatar

How to run parallel unit test that has sequential dependent feature tests

I've some feature tests that needed to be run one after another. When I do normal php artisan test all tests pass without any issue but when I try running php artisan test --parallel I get a bunch of errors. How can I setup tests to be grouped to run sequentially in parallel mode?

spbaniya's avatar
spbaniya's avatar sr575yrs agoLaravel
1
1
Last reply by sr57 5yrs ago
whatthef's avatar

Passport test logout after actingAs

How can I test logout using passport after actingAs? Token revoke doesn't seem to work

whatthef's avatar
whatthef's avatar martinbean5yrs agoTesting
5
1
Last reply by martinbean 5yrs ago
jgravois's avatar

Failing Test due to Coalescence

$co = CompanyCustomerAgreement::whereCompanyCode($code)->first(); if(!isset($co)) { $this->redirect('/expired'); } else { $this->lcStep = $co->last_completed_step ?: 1; $this->currentStep = $co->last_completed_step ?: 1; } // end if Shouldn't null coalescence kick in??? /** @test */ public function caf_loads_properly(): void { $caf = CompanyC

jgravois's avatar
jgravois's avatar jgravois5yrs agoTesting
8
3
Last reply by jgravois 5yrs ago
dipherent's avatar

How do I test website in different browsers?

Hello everyone, Is there any suggested online tool to test my website in different browsers...I am looking for a free tool not a paid one. Thanks for your help in advance

dipherent's avatar
dipherent's avatar martinbean5yrs agoGeneral
2
1
Last reply by martinbean 5yrs ago
ahmeda's avatar

How can I write a test for facebook auth in Laravel?

I have done all my normal test but when I reach facebook auth section I do not know what is the best or correct way to make a test for it, my code: class FacebookAuthController extends Controller { public function redirect() { return Socialite::driver('facebook')->redirect(); } public function callback() { $user = Socialite::driver('fa

ahmeda's avatar
ahmeda's avatar jlrdw5yrs agoLaravel
2
1
Last reply by jlrdw 5yrs ago
jove's avatar

Best way to test code that relies on external API

So I know that you shouldn't test external APIs, but how do you test your own code when it relies on external APIs and do a lot of stuff? I do not want to not test my part here. In my case I'm using discord and this library restcord/restcord. But I don't want to be stuck with going through all my code and manually test it against the real discord each time I do changes. Example

jove's avatar
jove's avatar jove5yrs agoTesting
2
1
Last reply by jove 5yrs ago
Antonella's avatar

mock test: Mockery\Exception\BadMethodCallException: Received Mockery_0_App_ClassU_downloadCard::

I wrote this with DI: public function test_mock_get_data() { $this->mock(downloadCard::class, function ($mock) { $mock->shouldReceive('_downloadCardsFromBoard()') ->once() ->andReturn(new Request( File::get('tests/test_data/cards.json'), $status =200,

Antonella's avatar
Antonella's avatar markus.heb4yrs agoTesting
1
1
Last reply by markus.heb 4yrs ago
Swaz's avatar

See what validation rules are failing in a test?

Sometimes I want to test a feature that happens after a form is submitted. In these cases, I often don't care about any of the data being posted. The code below is one of the ways I've gone about doing this. The problem is, sometimes my factories get out of date and no longer produce code that will pass my form validation. When the validation is checking 20+ fields it can be ch

Swaz's avatar
Swaz's avatar Swaz5yrs agoTesting
3
1
Last reply by Swaz 5yrs ago
iamamirsalehi's avatar

Test Can't assertRedirect

hey there. I've written a test for my update method but the assertRedirect code gives me error. Test: public function test_owner_can_update_his_projects() { $this->actingAs(User::factory()->create()); $created_project = Project::factory()->create(['user_id' => auth()->user()->id]); $response = $this->put(route('owner.project

iamamirsalehi's avatar
iamamirsalehi's avatar Tray25yrs agoLaravel
3
1
Last reply by Tray2 5yrs ago
sr57's avatar

Collections equality test

$col1=collect('a','a','2','3'); $col2=collect('a','2','3','3'); What should be the smarter code to test than $col1 not equal to $col2?

sr57's avatar
sr57's avatar sr575yrs agoLaravel
23
1
Last reply by sr57 5yrs ago
iamamirsalehi's avatar

Vscode extension for running test cases

Hey there Could you please recommend some Vscode extension for running test cases

iamamirsalehi's avatar
iamamirsalehi's avatar Tray25yrs agoLaravel
1
1
Last reply by Tray2 5yrs ago
bellini's avatar

Dusk test in Laravel Nova

Hey I am trying to create a test of when I click on the first resource row shown on the current page. For example If I wanted to navigate to the row with id of 1 I would do: $this->browse(function (Browser $browser) { $browser->click('@1-view-button'); }); But I need to target the first row for the current logged in user on the current resourc

bellini's avatar
bellini's avatar forrestedw5yrs agoTesting
1
1
Last reply by forrestedw 5yrs ago
Antonella's avatar

test add ip server with local method

I wanted to test this method with a feature test: public function getTask(Request $requestSvr) { $requestSvr->all(); $requestSvr['id_server'] = (string) $requestSvr['id_server']; $task = Task::whereIn('works', $requestSvr['task_available'])->where('process_status','=','new')->first(); if(!empty($task)) { $task-&

Antonella's avatar
Antonella's avatar gianmarx5yrs agoTesting
4
1
Last reply by gianmarx 5yrs ago
fakeheal's avatar

Test text in HTML templates

I have an email I send when people sign up. Texts in .blade.php file are formatted by my IDE. How can I test those texts reliably? I am using Mailthief as the version of Laravel is 5.2. Test: $texts = [ "Welcome", "Proin aliquam varius sodales. Ut vel tortor molestie, sagittis quam ullamcorper, lacinia urna. Nunc dictum sodales nulla non convallis. Maecen

fakeheal's avatar
fakeheal's avatar sr575yrs agoTesting
3
1
Last reply by sr57 5yrs ago
Daniel1836's avatar

Coding Test for old job. (Laravel) Can someone help me understand?

The test is basically to create a CRUD app in Laravel The part I am confused by is this: Maybe someone can explain to me in simple terms what they want. 3 ) Three Endpoints will be needed, for categories (of products), products and markets (for the products) 4 ) Each of the 3 endpoints will have an id, timestamps and 3 pairs of fields called: title_fr/title_en, description_fr

Daniel1836's avatar
Daniel1836's avatar Tray25yrs agoLaravel
1
1
Last reply by Tray2 5yrs ago
wonder95's avatar

How to select multiple checkboxes in Dusk test

I am using VueJS with bootstrap-vue, and using Dusk, I need to test a table inside a modal that uses a checkbox to select each row. In this particular case, there are multiple rows with checkboxes, and I need to select all of the checkboxes in the form and then submit the form. My test works fine with the modal in every way except checking the checkboxes; no matter what I try,

wonder95's avatar
wonder95's avatar wonder955yrs agoTesting
1
1
Last reply by wonder95 5yrs ago
Antonella's avatar

how to test a custom command in TDD?

how can i test a command i have created with a feature test? i created this command: pruneTask protected $signature = 'prune:task {x} {y} '; public function handle() { $x = $this->argument('x'); $y = $this->argument('y'); Task::where('instance',$x)->where('job',$y)->delete(); } the command does what it has to do I was wondering how to test it with

Antonella's avatar
Antonella's avatar martinbean5yrs agoLaravel
3
1
Last reply by martinbean 5yrs ago
enderandpeter@yahoo.com's avatar

Livewire component test non-initialized model property or infinite loop

I have a component class that looks like this: <?php namespace App\Http\Livewire\Dashboard; use App\Models\Team; use App\Models\User; use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\View; use Livewire\Component; class LocationTracker extends Component { public Team $team; public bool $tracking

enderandpeter@yahoo.com's avatar
enderandpeter@yahoo.com's avatar enderandpe...5yrs agoLivewire
1
1
Last reply by [email protected] 5yrs ago
jrdavidson's avatar

Writing Test Assertions for Feature vs Unit

Hey all I’m looking for assistance with knowing what assertions should be Feature/Unit tests.I'm following along with the current series Jeffrey Way is doing on Testing and trying to think out what assertions I need but I tend to favor more of assert more than whats needed so I'd like some thoughts. /** * @test * @dataProvider administrators */ public functi

jrdavidson's avatar
jrdavidson's avatar bugsysha5yrs agoTesting
11
1
Last reply by bugsysha 5yrs ago
Tippin's avatar

Automate Test Suite to run twice with different environment flags

Still semi new with testing, but I am working on a messenger package, and give the ability to use UUID or INT for the provider models the end user will set in my packages config. I also have a flag to disable my event listeners (among many others). Given these options from a Feature Test viewpoint, all my test classes are setup so that if I manually change the config in the Fea

Tippin's avatar
Tippin's avatar Tippin5yrs agoTesting
0
1
Antonella's avatar

Test TDD lesson 1 No tests found in class "Tests\Feature\ProjectsTest".

I'm following this first lesson -> https://laracasts.com/series/build-a-laravel-app-with-tdd/episodes/2?autoplay=true I wrote this test: namespace Tests\Feature; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Foundation\Testing\WithFaker; use Tests\TestCase; class ProjectsTest extends TestCase { use WithFaker, RefreshDatabase; public function a_

Antonella's avatar
Antonella's avatar Antonella5yrs agoLaravel
4
1
Last reply by Antonella 5yrs ago
chaudigv's avatar

Livewire s3 file upload unit test

I am following Testing simple S3 uploads but facing a simple issue on assertExists() Current versions: Laravel 8.20.1 Livewire: 2.3.5 phpunit: 9.3.3 Code public function test_resume_file_is_uploaded_successfully() { $this->actingAs(User::factory()->create()); Storage::fake('s3'); $file = UploadedFile::fake()->create('resume.pdf');

chaudigv's avatar
chaudigv's avatar Nakov5yrs agoLivewire
3
1
Last reply by Nakov 5yrs ago
RonanH's avatar

Can't call API endpoint from HTTP test

Hi, I am trying to run HTTP tests on my Passport API Controllers but can't seem to access the Controller methods. I have the API setup and working fine when i access the API through Postman when using a personal access token. When i try and call the same API controllers when running the HTTP test i created i.e. when running the phpunit command from the command line, the test n

RonanH's avatar
RonanH's avatar martinbean5yrs agoLaravel
1
1
Last reply by martinbean 5yrs ago
Antonella's avatar

API STORE request->all() is empty in feature test

I have this method which makes the store in the db: public function storeApi(Request $request) { $request=$request->all(); dd($request); ... .. when I call the api from feature test it gives me empty, let me explain: $token = 'izjY6Y8fk8y4ztWuagfdaPzaszOvo1ix8ghvApUv9JRjMZP7PR'; $data = [ "title" => [ "en" => &quo

Antonella's avatar
Antonella's avatar gianmarx5yrs agoLaravel
9
1
Last reply by gianmarx 5yrs ago
Ortzinator's avatar

This test did not perform any assertions

I'm following along with the Let's Build a Forum series, while adapting it to Laravel 8. I know it's a old series so maybe there's something new I'm missing with how testing works. Here's my testing class <?php namespace Tests\Feature; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Foundation\Testing\WithFaker; use Tests\TestCase; use App\Models\Thread;

Ortzinator's avatar
Ortzinator's avatar sr575yrs agoTesting
3
1
Last reply by sr57 5yrs ago
realtebo's avatar

Laravel 8 package testing - How to test interactiomn with another package?

Our company has developed an auth package. It has migrations, and auth logic inside. I am developing a new package that must interact with auth package. For example, My package's controllers must create records using user id from current logged user. I am curios about how to proceed. Must I manually run in 'some way' the migrations from auth package .. or must I simply mock the

realtebo's avatar
realtebo's avatar realtebo5yrs agoLaravel
0
1
Sam's avatar

php artisan test - environment

Hi folks, Just wondering if anyone know if using php artisan test actually uses the phpunit.xml file or a .env.testing file at all please? Regards,

Sam's avatar
Sam's avatar Sam5yrs agoTesting
11
3
Last reply by Sam 5yrs ago
Soulouf's avatar

Laravel Socialite: .test extension not accepted by Google

Good morning all! I am a little stuck with Google which does not accept domains with the extension .test I'm a little stuck because my browser no longer accepts .dev & .app domains. Do you have any solutions to solve my problem please?

Soulouf's avatar
Soulouf's avatar yulchurin4yrs agoEloquent
3
1
Last reply by yulchurin 4yrs ago
Steady-Entertainment's avatar

test fails on member function null

Good morning friends this time I have a easy one for you but I am not experienced enough to track the bug ... I get the following error: Error : Call to a member function connection() on null <?php namespace Tests\Unit; use App\Models\Offer; use App\Models\User; use Illuminate\Foundation\Testing\RefreshDatabase; use PHPUnit\Framework\TestCase; class OfferTest extends Tes

Steady-Entertainment's avatar
Steady-Entertainment's avatar Nakov5yrs agoTesting
6
1
Last reply by Nakov 5yrs ago
tfarzin's avatar

Rate limiter is not working (at least in test)

I've defined a rate limiter to throttle the number of requests a user can send each time and now I'm trying to test it but it's not working: my routes/api.php: Route::middleware(['throttle:limiter'])->group(function () { Route::post('/audio', function () { return response()->json(['Done'], 200); }); }); my rate limiter (defined in configureRateLimiting f

tfarzin's avatar
tfarzin's avatar cfsalina4yrs agoLaravel
1
3
Last reply by cfsalina 4yrs ago
GodziLaravel's avatar

Is it possible to call APP_ENV 'test' in .env?

Hello , On the hosting server I have 3 environments : test acceptance production I'm wondering if it's possible to give these values to the APP_ENV APP_ENV=test APP_ENV=acceptance APP_ENV=production

GodziLaravel's avatar
GodziLaravel's avatar automica5yrs agoGeneral
1
1
Last reply by automica 5yrs ago
pazitron's avatar

Problem with UploadedFile::fake() and PHPUnit test - Unable to find a file at path

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->validate([ 'title' => 'required | max:100', 'description' => 'required', 'image' =&g

pazitron's avatar
pazitron's avatar pazitron5yrs agoTesting
8
1
Last reply by pazitron 5yrs ago
realtebo's avatar

Package Test: could not find driver for SQLite - (Laravel 8 - Windows 10)

I am developing a package using latest laravel 8.x. In on a windows 10 machine. I am trying to create tests. I start tests in this way C:\php-7.3.18-Win32-VC15-x64\php.exe C:/progetto/packages/product_image/vendor/phpunit/phpunit/phpunit --configuration C:\progetto\packages\product_image\phpunit.xml In the .xml I configured <php> <server name="APP_KE

realtebo's avatar
realtebo's avatar realtebo5yrs agoLaravel
1
1
Last reply by realtebo 5yrs ago
robdex's avatar

Feature test "No adapter for resource type: "

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('default')->withNamespace('\App\Http\Controllers\Api')->routes(function ($api) { // it work's Route::get('timetr

robdex's avatar
robdex's avatar robdex5yrs agoTesting
0
1

Want us to email you occasionally with Laracasts news?

Nine out of ten doctors recommend Laracasts over competing brands. Come inside, see for yourself, and massively level up your development skills in the process.

Learn
BrowseSeriesCreatorSeriesLaravel PathLarabitsPlayground
Discuss
ForumPodcastSupport
Extras
Gift CertificatesApparelFAQiOS AppTerms
Social
X(Twitter)TikTokYoutube

© Laracasts 2026. All rights reserved. Yes, all of them. That means you, Todd.

Proudly hosted with Laravel Forge and DigitalOcean.

Want us to email you occasionally with Laracasts news?

Nine out of ten doctors recommend Laracasts over competing brands. Come inside, see for yourself, and massively level up your development skills in the process.

Learn
BrowseSeriesCreatorSeriesLaravel PathLarabitsPlayground
Discuss
ForumPodcastSupport
Extras
Gift CertificatesApparelFAQiOS AppTerms
Social
X(Twitter)TikTokYoutube

© Laracasts 2026. All rights reserved. Yes, all of them. That means you, Todd.

Proudly hosted with Laravel Forge and DigitalOcean.