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

X-Strike's avatar

Test render() ?

I like to test render() method that located in Handler class (app/exception) without calling $this->get() in the Test file? I need to make sure that render an exception into an HTTP response working correctly. public function render($request, Exception $e) { $response['exception'] = get_class($e); $response['message'] = $e->getMessage(); $respons

X-Strike's avatar
X-Strike's avatar X-Strike8yrs agoTesting
0
1
ayman's avatar

How to test that simple case? with Mockery

How to test that simple case? class Foo { public function m1(){ return $this->m2(); } private function m2() { return 'm2'; } } I need to test m1 and stubs m2 instead of return m2 return diff I use Mockery and phpunit class FooTest extends TestCase { public function testM1() { $foo = Mochery::mock('Foo'); $this->ass

ayman's avatar
ayman's avatar andonovn8yrs agoTesting
3
1
Last reply by andonovn 8yrs ago
ucreate.it's avatar

Penetration Test - laravel_session cookie termination

I am using laravel 5.3 , with one of the website created recently , the client demanded for the penetration test , I have a query on the question asked by one of the security expert while penetration test , can anyone help me in resolving this , here are the comments of expert: "After logging out, the previous session, identified by the laravel_session cookie, is not termi

ucreate.it's avatar
ucreate.it's avatar neilherber...8yrs agoLaravel
1
1
Last reply by neilherbertuk 8yrs ago
Ctrl+'s avatar

Test input arrays in laravel 5.5 ignore empty or null input values

I am currently testing a championship tree with 16 competitors. Each competitor can be updated via a select combo. Now, when testing this functionality in Laravel 5.5, I do: $this->select([ $competitor1->id, $competitor2->id, $competitor3->id, $competitor4->id, $competitor5->id, ], 'fighters[]') ->press('updat

Ctrl+'s avatar
Ctrl+'s avatar LuzElenaLo...8yrs agoTesting
2
1
Last reply by LuzElenaLopezRuiz 8yrs ago
arper's avatar

Test messages on the mail

the mail comes test messages : Name: 59b1495bb84a2 Tel: E-mail: [email protected] Name: 59afb372e278f Tel: E-mail: [email protected] . . . These calls are also displayed in the admin panel 10-15 per day

arper's avatar
arper's avatar arper8yrs agoLaravel
0
1
StackBoot's avatar

I have a technical Laravel test

Hello guys, This might be a lil off topic but I have no place where to ask except here; So I got a job interview as a backend Laravel Developer. My first interview went really good the CEO/ CTO interviewed me he showed me the company and introduced me with the backend dev team. After an hour of questions he said that I was the best he got to interview so far. He said If you are

StackBoot's avatar
StackBoot's avatar codo97yrs agoLaravel
7
1
Last reply by codo9 7yrs ago
jbtje's avatar

Running Unit test in PHPStorm, but not showing the web response

I've decided to give Test Driven Development a try. So far, so good, however while developing an API for my site, I do run into the problem that the test is false so now and than. Once the test fails, only little information is provided for example: Expected status code 200 but received 422. Failed asserting that false is true. It also gives the line of the test that failed, ho

jbtje's avatar
jbtje's avatar ejdelmonic...8yrs agoLaravel
1
1
Last reply by ejdelmonico 8yrs ago
bender_michael's avatar

DB Transaction not rolling back in simple test

I'm wondering what I'm doing wrong here. I'm just trying what I think is a very basic transaction test because I noticed records not rolling back in the more complex transaction. Same result using closure method. $model = new MyEloquentModel(); $model->prop = "value"; DB::beginTransaction(); $model->save(); DB::rollBack(); dd("finished"); Check my da

bender_michael's avatar
bender_michael's avatar bender_mic...8yrs agoLaravel
2
1
Last reply by bender_michael 8yrs ago
dk4210's avatar

Dusk passing variabels into test case steps

I'm trying to pass variables from a standalone page to my dusk test case, but cant seem to get it to work. I new up'd the testVariables page use Tests\Variables\TestVariables; I'm trying to figure out how to pass the var $pid to my step in the test case. ->click('a[href="javascript:onedit('. $pid .');"]') Please advise,

dk4210's avatar
dk4210's avatar dk42108yrs agoTesting
1
1
Last reply by dk4210 8yrs ago
bencarter78@hotmail.com's avatar

Mac Users: How do you test your site on different versions of IE?

Hello I'm trying to test my application which needs to support > IE10 and I'm having a real hard time getting a productive workflow. Currently, I've got Browserstack, but it's pretty horrible (slow, crashes a lot etc). Just wondering what people are using out there in Laravel land?

bencarter78@hotmail.com's avatar
bencarter78@hotmail.com's avatar bashy8yrs agoTesting
1
1
Last reply by bashy 8yrs ago
dongun's avatar

How to test a helper function that returns a response()->json()

I have this function that's a blueprint for responses for my ajax requests, and I don't know how to write a test for it. Please, how do I write a test for this. function apiSuccess(string $msg, $data) { $responder = [ 'status' => 0, 'message' => $msg, 'data' => $data ]; return response()->json( $responder ); }

dongun's avatar
dongun's avatar dongun8yrs agoTesting
0
1
pilat's avatar

Cannot test HTTP responses when using abort() inside a service provider

Hi, an't figure out one thing: I have the following code in my Service Provider (it's deferred, by the way): if ($someCond) { abort(404, 'blah-blah-blah'); } … and here's the test: /** @test */ public function test_regression_404_error_did_not_consider_auth_status() { $this ->actingAs(User::find(1)) ->get('section/somethingimaginary') ->s

pilat's avatar
pilat's avatar pilat8yrs agoTesting
0
1
eugenefvdm's avatar

Permissions table referred to in AuthServiceProvider fails to migrate during PHPUnit test

When I run vendor/bin/phpunit against a simple test I get: There was 1 error: 1) Tests\Feature\CommissionsTest::when_adding_a_subscription_also_assign_commission Illuminate\Database\QueryException: SQLSTATE[HY000]: General error: 1 no such table: permissions (SQL: select * from "permissions") I'm using an in-memory SQLite database. In AuthServiceProvider.php when I

eugenefvdm's avatar
eugenefvdm's avatar HenriqueTe...7yrs agoTesting
1
1
Last reply by HenriqueTeixeira 7yrs ago
bennigraf's avatar

Lumen: using "seeJson()" reports "This test did not perform any assertions"

Hey all, I'm testing an API with the test infrastructure provided by lumen. The test is basically something like: $this->json('POST', 'api', [ 'query' => $this->query, 'variables' => $some_variables ])->seeJson([ 'my' => 'expected_json_structure' ]); And it does run and work as it fails when the expected Structure is different, but if it's actuall

bennigraf's avatar
bennigraf's avatar salmon8yrs agoTesting
1
1
Last reply by salmon 8yrs ago
squibby's avatar

How to test file download using maatwebsite/excel

I am using maatwebsite/excel to return an excel file. This works fine but I want to be able to test this using phpunit. I have a controller method which returns the excel file. public function usersAll(){ $users = User::all(); return Excel::create('users', function($excel) use ($users) { $excel->sheet('Users', function($sheet) use ($users) {

squibby's avatar
squibby's avatar squibby8yrs agoTesting
0
1
fredmoras's avatar

test if an array contain a value.

hello, I would like to test if an array contain a value. I have 2 array : ''' var_dump($ingredients) array (size=12) 0 => object(stdClass)[303] public 'id' => int 21 public 'nom' => string 'Tomate' (length=6) public 'created_at' => null public 'updated_at' => null 1 => object(stdClass)[111] public 'id' => int 22 public 'nom' => string 'Carotte' (length=7

fredmoras's avatar
fredmoras's avatar fredmoras8yrs agoLaravel
0
1
dk4210's avatar

Dusk - Calling a specific test

Hello Guys, How would I call a specific test. For example if I create a test called MyTest php artisan dusk:make MyTest I then update the test with the testing code. How can I call the test from the command line? I tried something like this php artisan dusk Mytest That doesn't work. Maybe I'm missing something. Thanks for the help.

dk4210's avatar
dk4210's avatar gcwilliams8yrs agoTesting
8
1
Last reply by gcwilliams 8yrs ago
Lars-Janssen's avatar

Super weird test failure with assertDatabaseHas

Hello, I've got a super weird thing going on for 3 days now. And I can't get it to work. I've got 2 tables: Company Products And a pivot table company_products. So in my webapp everything is working. However in my test it keeps failing. This is the test: /** @test */ public function when_a_product_is_destroyed_linked_companies_will_go_away() { $product = create(Product::cl

Lars-Janssen's avatar
Lars-Janssen's avatar lars68yrs agoLaravel
14
2
Last reply by lars6 8yrs ago
JacDev's avatar

Test HTTPS

Hello, I'd like to test my urls for https. So I'd expect a Status 302 on normal URL's and a 200 on https URLS. The default one for the 302 is simple $response = $this->get('/'); The version for the https I cannot find any info about. How can I do a test response on an https request?

JacDev's avatar
JacDev's avatar JacDev8yrs agoLaravel
3
1
Last reply by JacDev 8yrs ago
alphasolution's avatar

How to test the sender is my expect sender?

I am using Laravel 5.4. In my application, I use a Mailable class to send the email to our customer. I create a simple test to test the email is sent by the correct sender. the Mailable class has the method hasFrom() to test the email sender is expected or not. However, it always return false. Does anyone know how the hasForm() method work?

alphasolution's avatar
alphasolution's avatar alphasolut...8yrs agoTesting
1
1
Last reply by alphasolution 8yrs ago
jericopulvera's avatar

I wanna hear your thoughts regarding Test Driven Development

Hello everyone! I'm interested in Test Driven Development and I wanna know what are you thoughts about this. These are my questions: When should I TDD and when should I not? Is TDD life changing for you? I'm currently building a booking website and I have 2 months to finish it will TDD help me work faster? Thank You!!!

jericopulvera's avatar
jericopulvera's avatar Cronix8yrs agoGeneral
1
2
Last reply by Cronix 8yrs ago
eddy1992's avatar

Property or method "test" is not defined on the instance but referenced during render....

Hi I am facing an error with vue, I have a Laravel 5.4 project and I installed and performed all the necessary steps to get laravel mix up and running. Now I am trying to perform a simple hello world using vue in my laravel project in app.js I am facing an warning app.js:32213 [Vue warn]: Property or method "test" is not defined on the instance but referenced during r

eddy1992's avatar
eddy1992's avatar bunnypro8yrs agoVue
5
1
Last reply by bunnypro 8yrs ago
Mohammed-H's avatar

SignIn a user for Unit test on laravel 5.4

How do you signIn a user in unit test on Laravel 5.4? I tried actingAs but didn't work :( Thanks Mohammed

Mohammed-H's avatar
Mohammed-H's avatar StefanBaue...8yrs agoTesting
4
1
Last reply by StefanBauer 8yrs ago
Farshad's avatar

model name and test

I create a model and migration with composer the model name is Activity and all is good but when I run my test got that error not find App\Activite class why it should looking for that class this is my test method public function it_records_activity_when_a_thread_is_created() { $this->signIn(); $thread=create('App\Thread'); $this->assertData

Farshad's avatar
Farshad's avatar bheath8yrs agoTesting
1
1
Last reply by bheath 8yrs ago
shanedara's avatar

How do you test methods with no return value & how do you mock a collection of models?

Can anyone tell me how I can test the notifySubscribers method this class? If it doesnt return anything how do I assert anything? Also it takes a collection of User models as a parameter, do I need to add a mock collection? or a collection or mock user models? How do I add state to these models? Thanks. namespace App\CoreServices; class Notifier { /** * Broadcaster object.

shanedara's avatar
shanedara's avatar shanedara9yrs agoTesting
0
1
dillscher's avatar

Database table not available in test as service providers run before use DatabaseMigrations?

Hi, I do some tests with PHPUnit on different views. Part of the view variables, i. e. $topics, is loaded through a service provider like the following: class ComposerServiceProvider extends ServiceProvider { /** * Bootstrap the application services. * * @return void */ public function boot() { if (Schema::hasTable('topics')) {

dillscher's avatar
dillscher's avatar addorange8yrs agoTesting
2
1
Last reply by addorange 8yrs ago
guice's avatar

How do I mock a Command object? Or test a service with dependences on ->info() Outputter

Object: Illuminate\Console\Command I'm building an artisan cli for importing a file into mysql. Within my command, handle() I'm passing in $this to my service for access to the info() output interface, e.g.: public function handle() { $service = resolve('MyService'); $service->setCommand($this); } Within MyService, I make several calls to info() for the purpose of

guice's avatar
guice's avatar guice9yrs agoTesting
0
1
canadianlover's avatar

PHPUnit test dealing 14 unique playing cards

So I have been stumped by this problem for a while now. I am creating a Pai Gow Poker website (for those of you who don't know what Pai Gow is, it's a game where two combined decks are shuffled. Seven cards are dealt to the player and seven for the dealer. The player and dealer make a high and low hand (the high out of 5 cards and the low 2), For more details look on the game's

canadianlover's avatar
canadianlover's avatar canadianlo...9yrs agoTesting
0
1
Belio's avatar

Async test with AVA and moxios

I am trying to move from mocha to AVA and reproduce this behavior from mocha it('renders the introduction text if api request is correct', (done) => { const vm = mount(AnswerBeat, options); moxios.stubRequest('/beatUsers/4', { status: 200, response: [ { type: 'text', question: 'example text of question' }, { type: 'introduction', question

Belio's avatar
Belio's avatar Belio9yrs agoJavaScript
1
1
Last reply by Belio 9yrs ago
mk-conn's avatar

Testing route with DELETE and GET in one test

Hi, following is in a test $this->json('DELETE', self::API_URL . '/' . $id) ->assertStatus(Response::HTTP_NO_CONTENT); $response = $this->json('GET', self::API_URL) ->decodeResponseJson(); The first test call to the api works great, but the second is somehow interpreted as DELETE request, which obviously fails and is not what

mk-conn's avatar
mk-conn's avatar mk-conn9yrs agoLaravel
0
1
AR's avatar

Feature test findOrFail not giving 404 status

I am testing if a user enters a profile page that does not exists in the database. What is the best way to test these kind of errors. I was thinking that if I get a status of 404 it will make sense but I receive an exception. Here is the test: /** @test */ public function profile_url_must_be_valid_user_id() { $response = $this->get('/invalid-user-id'); $response->

AR's avatar
AR's avatar tykus9yrs agoTesting
3
1
Last reply by tykus 9yrs ago
JacDev's avatar

OmniPay + Mollie test always paid status?

Hello, I was wondering if other people also see this. I am including Mollie payments in my application through Omnipay. Now I think I have everything set up correctly. The only problem is that, no matter what 'result' I select in the test environment @ Mollie. The result always comes up as 'paid', even if I select 'cancel'. Do others also see this on the test environment? This

JacDev's avatar
JacDev's avatar JacDev9yrs agoLaravel
0
1
Lars-Janssen's avatar

How to test emails?

Hi, I've watched this video: https://laracasts.com/series/phpunit-testing-in-laravel/episodes/12 It explains how to test emails. But that does not work in Laravel 5.4. Any good libraries or examples on how to do this? Thanks

Lars-Janssen's avatar
Lars-Janssen's avatar Devpat7yrs agoLaravel
4
2
Last reply by Devpat 7yrs ago
robertarissen's avatar

Property or method "test" is not defined

Hello Laracast, Im using Vue.js and Laravel for a long time. I want to use Vuejs without laravel. So I had copied the elixer file from laracast and now work gulp fine. Only my compontent tag don't work. Mounted() give no result en data() is also not working. My Component: <template> <div class="container-fluid"> <div class="ro

robertarissen's avatar
robertarissen's avatar robertaris...9yrs agoVue
0
1
FehriJawher's avatar

@extends Test

Hi, i wanted to do a test for wich template i will use depending on user role .. so i did this @if($_SESSION["role"] == 'Superviseur') @extends('layouts.superviseur') @elseif($_SESSION["role"] == 'administrateur') @extends('layouts.master') @endif in this case all the templates are included in the same time i tried to break after each @extends a i get this e

FehriJawher's avatar
FehriJawher's avatar FehriJawhe...9yrs agoLaravel
5
1
Last reply by FehriJawher 9yrs ago
bencarter78@hotmail.com's avatar

HTTP Test failing on actingAs

Hi there I'm trying to write a simple HTTP test for an authenticated user but I'm getting the following error. Failed asserting that '<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <meta http-equiv="refresh" content="1;url=http://myurl.dev" /> <title>Redirecting to http://myur

bencarter78@hotmail.com's avatar
bencarter78@hotmail.com's avatar bencarter7...9yrs agoTesting
2
1
Last reply by bencarter78 9yrs ago
iamripespoon's avatar

Sending Header Content-Type with Laravel 5.4 Test Request

Hello, i'm very new to tests in Laravel and i'm trying to build my first one, but i've hit a bit of a wall. I'm trying to setup a series of tests for my API. The API insists that you must provide the header Content-Type so it knows in which format to return the response in. However, when i'm creating my test and i try and send the Content-Type in the header, it's not picking up

iamripespoon's avatar
iamripespoon's avatar lars69yrs agoTesting
1
1
Last reply by lars6 9yrs ago
withmore's avatar

How to test application fully behind login

What is the best setup to test an application that is fully behind a login? I include the auth middleware through route groups. I suppose there is no point in testing all pages and actions as a not logged in user to see they indeed have no access.

withmore's avatar
withmore's avatar withmore9yrs agoTesting
4
1
Last reply by withmore 9yrs ago
besrabasant's avatar

Writing Test for resource Controller method

Hello folks, I am new to testing so please help me figure out this. I have a resource controller which has a store method public function store(CreateClientRequest $request) { $this->client->create( $request->only(['name', 'address','primary_email','contact_no']) ); return redirect()->route('clients.show',['id' => $this-&g

besrabasant's avatar
besrabasant's avatar besrabasan...9yrs agoTesting
0
1
call_me_vlad's avatar

Storage public disk files - 403 on test environment, not on local

Hi, I am getting a problem on my test environment, that I don't have on my local machine. Files displayed with the Storage class respond with a Forbidden 403. To be more precise : image files are stored on the 'public' disk with this config 'public' => [ 'driver' => 'local', 'root' => storage_path('app/public'), 'url' => env('APP_URL').'/storage', 'visibility' =&g

call_me_vlad's avatar
call_me_vlad's avatar kenmaclord8yrs agoLaravel
3
1
Last reply by kenmaclord 8yrs ago
nbbfv's avatar

how to test that mail body contains some text?

how can I test if mail body contains a link for example? I use laravel 5.3 public function we_can_send_email_verification_email_to_existing_player() { Mail::fake(); // Given if I have an admin User $admin = factory(User::class)->create(); // And a Player $player = factory(Player::class)->create(); // When Admin is log

nbbfv's avatar
nbbfv's avatar nbbfv9yrs agoTesting
2
1
Last reply by nbbfv 9yrs ago
fbmfbm's avatar

Events not fired in phpunit test ?

Hi all, I'm looking to unit test with phpunit my event's process that record logs in database but facing some trouble : In unit test, no event seam to be fired and so my log test table stay empty. I know that in prod en dev it's working because as event is well fired and on event a new record is created in db. I can test other db recording process without problem, but only even

fbmfbm's avatar
fbmfbm's avatar fbmfbm9yrs agoLaravel
3
1
Last reply by fbmfbm 9yrs ago
Naxon's avatar

Running a single test with PHPStorm opens it in the browser

Hi, I'm having a problem here with PHPUnit testing on PHPStorm. When clicking 'Run' the tests directory, it does what I expect and runs it as a test. But when I click 'Run' on a single test file, it opens it in the browser instead of running it as a test. How can I configure PHPStorm to run those files as tests so I can run a single test and not the whole suite every time? Than

Naxon's avatar
Naxon's avatar craigh4119yrs agoTesting
1
1
Last reply by craigh411 9yrs ago
ill-logical's avatar

How to test a 'store' function with optional JSON payload?

Hi. How do you test in situations when there are just too many variations to try out? Imagine you are writing a feature test "user can store a post". Your goal is to test the store method on the controller. OK, but the payload is large. Some 7 fields are optional - attachments, image gallery, perex text, tags, etc. - these all may or may not be present on submit. How

ill-logical's avatar
ill-logical's avatar ill-logica...9yrs agoTesting
0
1
120's avatar

How unit test Eloquent model save failed ?

Hello, I have difficulty testing the grounding of the save method. CategoriesController@store public function store(ArticleRequest $request) { $input = $request->input(); $data = new Article($input); $response = DB::transaction(function () use ($data, $input) { try { $data->save(); } catch (\Exception $e

120's avatar
120's avatar 1209yrs agoTesting
2
1
Last reply by 120 9yrs ago
steveperrycreative's avatar

static::deleting in a boot method is not working in test

This is my test: /** @test */ public function deleting_a_task_from_a_project_restores_its_credits() { $this->signInAsAdmin(); $project = factory('App\Project')->create(); $task = factory('App\Task')->create([ 'project_id' => $project->id, 'credits_used' => 20 ]); $project->credits = 100; $project->save(); $

steveperrycreative's avatar
steveperrycreative's avatar steveperry...9yrs agoTesting
2
1
Last reply by steveperrycreative 9yrs ago
niceseb's avatar

How to Accept Payments: Testing Stripe Webhooks : 2nd Test failed?

First test was fine, but why is it failing when $ phpunit --filter test_it_deactivates_a_users_subscription_if_deleted_on_stripes_end PHPUnit 6.1.3 by Sebastian Bergmann and contributors. F 1 / 1 (100%) Time: 200 ms, Memory: 18.00MB There was 1 failure: Tests\Feature\WebhooksControllerTest::test_it_deactivates_a

niceseb's avatar
niceseb's avatar niceseb9yrs agoLaravel
0
1
mezie's avatar

id returning empty from within test

I'm following this episode https://laracasts.com/series/lets-build-a-forum-with-laravel/episodes/6 of Let's Build A Forum with Laravel and TDD series for a project of mine. The test is failing due to the fact that $job->id is returning empty, hence the path ends up being /jobs/ instead of something like /jobs/1. Below is the code I have: Test public function an_authenticated

mezie's avatar
mezie's avatar mezie9yrs agoTesting
4
1
Last reply by mezie 9yrs ago
etrainerspy's avatar

Weird problem with phpunit, keeps running test on old file

I am watching the laravel 5.4 from Scratch video about phpunit. I modified the file, 'ExampleTest.php'. I even renamed the file. When I rerun the phpunit test on the newly named changed file, it cannot find it. However, if I run the test on the old file, it finds it and passes. What's going on? Is it somehow buffering the old file? If so, is there a way to clear it and ru

etrainerspy's avatar
etrainerspy's avatar etrainersp...9yrs agoTesting
1
1
Last reply by etrainerspy 9yrs ago
pyr0hu's avatar

What to test in a RESTful API

Hey, I'm trying to wrap my head around TDD but struggling to understand the basic concepts. When writing tests for API, I write the tests for the endpoints (e.g. POST /booking), or I'm writing for the logic (user can book a ticket) ? Should I test every endpoint for things like 'it requires auth', 'it returns the correct fields'? Or the basic concept is to test the correct logi

pyr0hu's avatar
pyr0hu's avatar Nospoon9yrs agoTesting
2
1
Last reply by Nospoon 9yrs ago

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.