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

serge-benard's avatar

Validation Fails on Second Unique Value Test on Update

Hello! I've got a problem with Validation. I've googled for an answer, but the only option I saw (doesn't relate directly to my issue) requires me to create my own Validation rule, which seems like overkill? I have a table with two columns which need to be Unique. When creating the record, the validation works fine. When I try to Update, the 'Abbreviation' field shows as duplic

serge-benard's avatar
serge-benard's avatar serge.bena...9yrs agoLaravel
4
1
Last reply by serge.benard 9yrs ago
mahmandev's avatar

How to only run a specific Dusk test?

I don't want to run all of them as it takes forever, only want to run the one I'm currently working on. Can't find anything online about it.

mahmandev's avatar
mahmandev's avatar mitechnolo...7yrs agoLaravel
6
1
Last reply by mitechnologies 7yrs ago
nezarfadle's avatar

Dusk: How to test an ajax request triggered by a Modal ( onScroll event )

I wish this is gonna be useful for somebody http://laravel-tricks.com/tricks/dusk-testing-an-ajax-request-performed-by-a-modal-onscroll-event

nezarfadle's avatar
nezarfadle's avatar nezarfadle9yrs agoTips
0
1
huntsfromshadow's avatar

HTTP Integration Test: Following Redirect

I'm trying to write some start to finish integration tests four our oauth application. APP is using laravel 5.4 and Passport. I'm able to make the initial call to oauth/authorize and I get back a Redirect to /login. From their I can't figure out how to tell the system to go ahead and follow the redirect. My code currently is a standard Laravel TestCase. ''' $params = [ "c

huntsfromshadow's avatar
huntsfromshadow's avatar huntsfroms...9yrs agoLaravel
0
1
paulbarker's avatar

Composer Autoloading Issue With Test Files and Autoload-Dev

The other day, after implementing some tests for our application, I got a deploy failure with this error: Mon Feb 27 16:48:31 PST 2017 From bitbucket.org:********/******** * branch production -> FETCH_HEAD Already up-to-date. Loading composer repositories with package information Installing dependencies from lock file Nothing to install or update Generating autol

paulbarker's avatar
paulbarker's avatar golonix9yrs agoForge
1
7
Last reply by golonix 9yrs ago
shez1983's avatar

need someone from australia to do a really quick test for me?

I am testing currencies on my server but VPN doesnt seem to work for AUS as it shows that i am in USA.. it works for EUR and GBP.. so could someone kind enough contact me and i will tell them what to do?

shez1983's avatar
shez1983's avatar kerrin9yrs agoGeneral
1
1
Last reply by kerrin 9yrs ago
ohffs's avatar

Basic http test of file download route?

In the olden days I used to be able to do things like : $response = $this->get(route('user.whatever', $user->id)); $this->assertEquals(true, $response->getFile()->whatever()); But now if I try with the newer tests I get an UnexpectedValueException: The Response content must be a string or object implementing __toString(), "boolean" given. back from php

ohffs's avatar
ohffs's avatar SaeedPrez9yrs agoTesting
10
1
Last reply by SaeedPrez 9yrs ago
omrakhurs's avatar

Best way to test for variables that are not set or set to null?

I'm trying to learn what is a best one-size-fits-all way in Laravel to detect if something is a)set to null and/or b) not set. There's isset(), is_null(), and others. But I'm looking to see how other developers do it.

omrakhurs's avatar
omrakhurs's avatar tomi9yrs agoLaravel
3
1
Last reply by tomi 9yrs ago
iampawan31's avatar

How to test a feature which contains relationships

I want to implement a user profile feature. A user has various attributes (Address, work experience,education, user reviews,etc). All these attributes are defined in separate relationships. How do i go about doing this in TDD Environment?

iampawan31's avatar
iampawan31's avatar bobbybouwm...9yrs agoTesting
8
1
Last reply by bobbybouwmann 9yrs ago
Kriptic's avatar

test post

delete me

Kriptic's avatar
Kriptic's avatar ThisJonah9yrs agoSpark
1
1
Last reply by ThisJonah 9yrs ago
stwilson's avatar

v-if: how to test if object is empty?

Trying to do figure out how to check my data object empty or not. No matter what I try, I get "error when evaluating expression". Here's what I'm trying to figure out. my-object is fetched by ajax, and I don't want to display certain elements until the object is not empty. <span v-if=" my-object.areyouemptyornot ">See me or not</span>

stwilson's avatar
stwilson's avatar alexteie6yrs agoVue
7
98
Last reply by alexteie 6yrs ago
SaeedPrez's avatar

User Test - Which option makes sense to you?

Hello guys, I'm doing some user testing to find out which of the below options makes most sense.. Would appreciate your feedback ♥ Which option makes more sense to you? NOTE: In all below options only one of the buttons will be shown at any time (they will toggle). I have put them in the same image just to demonstrate both states. Option A Button TEXT shows the state that wi

SaeedPrez's avatar
SaeedPrez's avatar ohffs9yrs agoGeneral
16
1
Last reply by ohffs 9yrs ago
benjamincrozat's avatar

Problem running integration test on Travis

Hello people, I'm looking to run integration tests on Travis, but despite running "php artisan serve", http://localhost:8000 isn't accessible. Here's a part of my .travis.yml file: before_script: # [...] - composer update - composer run-script post-root-package-install - composer run-script post-create-project-cmd - mysql -e "create database l

benjamincrozat's avatar
benjamincrozat's avatar benjamincr...9yrs agoTesting
0
1
Ronster's avatar

setting right database for test

Hi, I use the model connection attribute in all my models since i'm working with multiple databases/schema's. I'm at a point where I need to write tests and this is where I'm struggling with at the moment. At the moment I set the DB_Connection through the models constructor. I named it "SHARED_CONNECTION" public function __construct() { Parent::__construct

Ronster's avatar
Ronster's avatar Ronster9yrs agoLaravel
0
1
cactus's avatar

How to test a controller method with Dependency injection

File: routes.php Route::post('get-details/{jobCode}','MyController@getDetails'); File: MyController.php use VendorApi; Class MyController extends Controller{ public function getDetails($jobCode, VendorApi $vendorApi){ $vendorDetails = $vendorApi($jobCode); if($vendorDetails['status'] == 'Error'){ print json_encode(['status' => 'Error', 'message' =>

cactus's avatar
cactus's avatar cactus9yrs agoTesting
1
1
Last reply by cactus 9yrs ago
dgdavidson's avatar

Route doesn't work on test server

I have one route that works on my local machine but not on a Forge/Linode install. Just one route in particular gives a NotFoundHttpException . What possible reasons are there for something like this? Code is the same, permissions are the same. Route::group(['prefix' => 'user'], function() { Route::get('profile', 'UserController@show'); Route::post('profile', 'UserCo

dgdavidson's avatar
dgdavidson's avatar dgdavidson9yrs agoServers
11
1
Last reply by dgdavidson 9yrs ago
EventFellows's avatar

Unit test rendered html output NOT the source html

I'd like to check a page against unwanted/ forgotten html parts as part of phpunit tests in an automated fashion. Use case is the following: There can be a lot of dd() and var_dump() during development if something fails and things need to be debugged in a manual way all of these should be removed before the next release, of course sometimes one might forget one of the places

EventFellows's avatar
EventFellows's avatar Thijmen9yrs agoTesting
2
1
Last reply by Thijmen 9yrs ago
DevroMeister's avatar

How to upload and Unit test a CSV file via resource controller

Hi all, I am rather new to Laravel and i have been tasked with created a upload API and unit testing it. I would be so grateful if someone could guide me through the steps. needed to get the test's green light :) I currently have a ListImportController class with a function of store() and a ListImportControllerTest class with a function of testCreate(). Thanks in advance.

DevroMeister's avatar
DevroMeister's avatar DevroMeist...10yrs agoLaravel
2
1
Last reply by DevroMeister 10yrs ago
flashman's avatar

Spark Test

Hi, is it possible to install localy and make app with Spark before purchase, and purchase it after project is done and ready for production?

flashman's avatar
flashman's avatar samo10yrs agoSpark
1
1
Last reply by samo 10yrs ago
timgavin's avatar

Serving a "Test" site

My client's website is currently in Wordpress and located in public. I have built a new site for them in Laravel and need to show them the new site before replacing the Wordpress site. I've uploaded all of the Laravel files and named the Laravel public directory to public2 so that it doesn't conflict with the WP site. .env app bootstrap database public <-- current live WP s

timgavin's avatar
timgavin's avatar goatshark10yrs agoServers
2
1
Last reply by goatshark 10yrs ago
tylernathanreed's avatar

Eloquent is not Working in Test Cases

I've having the strangest issue. If I do something simple, like this: groups id ... users id ... group_user group_id user_id ... With proper Migrations, Models, etc, like so: Group.php function users() { return $this->belongsToMany(User::class); } function attachUser(User $user) { $this->users()->attach($user->id); } Calling

tylernathanreed's avatar
tylernathanreed's avatar tylernatha...10yrs agoTesting
1
1
Last reply by tylernathanreed 10yrs ago
jmfs's avatar

Appendin POST variable to form test

I have a form that uses Angular JS to create and populate a hidden field. Can I append this to in Laravel's unit testing? If I do: $this->visit('/page') ->type('Yo Momma', 'name') ->type(123, 'hidden_field_name') ->press('Do It') it can't find the field as it's created by JavaScript. Thanks.

jmfs's avatar
jmfs's avatar jmfs10yrs agoTesting
0
1
ChristopherSFSD's avatar

Organizing Behat test classes / traits

I have a number of Behat context classes that use traits. I'd like to be able to organize these traits into sub directories but when I attempt to use them, they are not found. None of these classes are namespaced. I'm not sure if namespacing them is the way to solve this. Any tips would be appreciated. Example ... - boostrap - UserContext (extends BaseContext, uses UserTrai

ChristopherSFSD's avatar
ChristopherSFSD's avatar Christophe...10yrs agoTesting
1
1
Last reply by ChristopherRaymond 10yrs ago
Dracool's avatar

Local Database Test without Homestead

Hi. I'm using laravel with xampp on windows 7. I want to go along with the Laravel Fundamentals tutorials but I'm having difficult time figuring out how to set the database up. Previously with Codeigniter, I just made a function to connect to it. But now since Laravel is so automatic and comes pre-packaged I'm confused. I know that App/Database.php file holds all information a

Dracool's avatar
Dracool's avatar Sulieman10yrs agoTesting
1
1
Last reply by Sulieman 10yrs ago
jcergolj's avatar

how to test in laravel 5: user can't edit other user

Why response2 dosen't have status 403? It has status 302. How to check if user is redirected if he tries to update another user? $response1 = $this->call('GET', route('team.member.edit', [$team->id, $teamAdmin['user']->id])); $this->assertEquals(403, $response->status()); $response2 = $this->call('PUT', route('team.member.update', [$team->id, $teamAdmin['u

jcergolj's avatar
jcergolj's avatar Prullenbak10yrs agoTesting
3
1
Last reply by Prullenbak 10yrs ago
bjones2015's avatar

How To Test Artisan Commands

I'm wanting to build an Artisan command to clear out some old records every month. I understand how to build the command, but I'm having trouble with testing it. Using the TestCase class how am I suppose to run the command?

bjones2015's avatar
bjones2015's avatar ingrammonk10yrs agoTesting
2
1
Last reply by ingrammonk 10yrs ago
salarmehr's avatar

How test all routs to ensure they return at least a none-500 response?

I want to be sure that all GET routes defined in routes.php file return a 200 response and all non-get routes return at least a non-500 http response. How can I do that using phpunit and Laravel testing facilities?

salarmehr's avatar
salarmehr's avatar salarmehr10yrs agoRequests
2
1
Last reply by salarmehr 10yrs ago
toniperic's avatar

[Codeception] Send email when test fails

I'm using Codeception. I want to trigger tests tests via a cron job once a day at midnight (checked), and if those acceptance tests fail I'd like to be notified immediately (I guess via email). How can I accomplish this?

toniperic's avatar
toniperic's avatar toniperic10yrs agoTesting
2
1
Last reply by toniperic 10yrs ago
ARCANEDEV's avatar

Test if we can add (GIF) images in laracasts forum

Update : Yay

ARCANEDEV's avatar
ARCANEDEV's avatar ARCANEDEV10yrs agoGeneral
0
1
Vincent's avatar

Access middleware stack in unit test

Is there a way to access the middleware stack of the current request to call disableFor() on the used EncryptCookies middleware instance? Making app('App\Http\Middleware\EncryptCookies') returns a different object each call.

Vincent's avatar
Vincent's avatar Vincent10yrs agoTesting
1
1
Last reply by Vincent 10yrs ago
eagle_arg's avatar

Phpunit how to test a form having dependency between dropdowns

Hi, I'm trying to use phpunit in my app (I'm learning how to use it)... Now I have the next question... How I can complete a form having 2 dropdowns, when the second dropdown only is completed if the first one is chose (using ajax and json). e.g. first I completed the dropdown called Country (when you selected a value then it will complete the other dropdown which is City). So

eagle_arg's avatar
eagle_arg's avatar eagle_arg10yrs agoTesting
4
1
Last reply by eagle_arg 10yrs ago
jrean's avatar

Test attributes/columns existence

Hi, Lets say I take the App\User model and I create a User instance. I would like to know if the model table has a column named foo. Better, I would like know if the model has a foo attribute and so the table a foo column. How could I achieve this the clean way? I writing a small package where users should add one column to the App\User model. Before running a certain method of

jrean's avatar
jrean's avatar razoxane2yrs agoEloquent
11
24
Last reply by razoxane 2yrs ago
shawnyv's avatar

Cron to test database is running and restart if necessary?

Hi all, I've got a project for a client that is presenting me some interesting challenges. I'm using Google Maps Heatmap layer to show a ton of location data from a coordinate database of 5M+ points, filtered based on user criteria. Sometimes, of course, there are just a ton of rows post filtering (100k-200k results), and I'm finding this is shutting down the mysql connection,

shawnyv's avatar
shawnyv's avatar willvincen...10yrs agoForge
3
1
Last reply by willvincent 10yrs ago
dillscher's avatar

How to test forms with phpunit without removing CSRF-Middleware?

Hi folks, currently I'm stuck here trying to use laravel 5.1 integrated tests to check some forms. As there is the CSRF-verification I had to temporarily comment the middleware \App\Http\Middleware\VerifyCsrfToken::class to get rid of token mismatches. But as I want to be sure to not forget this kind of protection on deployment to production it seems to be a risky way. So, is t

dillscher's avatar
dillscher's avatar addorange10yrs agoTesting
2
1
Last reply by addorange 10yrs ago
dancourse's avatar

Why we test… the two other tests I’m forgetting to write

Hey Laracast peeps, Just thought I'd share a couple of my simple testing thoughts. If I'd have written more thorough tests in my last sprint, it would have saved me like a few hours this morning. Hence why I'm sharing! http://www.dancourse.co.uk/2015/07/why-we-test-the-two-other-tests-im-forgetting-to-write/ Any comments gladly received! All the best, DanC

dancourse's avatar
dancourse's avatar dancourse10yrs agoTips
2
1
Last reply by dancourse 10yrs ago
jakeharris's avatar

Only one test will pass at a time (5.1)

I tried to post this a bit ago but I think the original post got lost in the nether thanks to some pasted smart quotes. If this is a double-post I do apologize. I'm making a point to work on testing early on with a new project, but having a pretty rough time. If I run either one of the tests below on their own, it will pass. However, when I attempt to run both tests, I am greet

jakeharris's avatar
jakeharris's avatar luceos10yrs agoTesting
3
1
Last reply by luceos 10yrs ago
jakeharris's avatar

Only one test will pass at a time

I'm making a point to work on testing early on with a new project, but having a pretty rough time. If I run either one of the tests below on their own, it will pass. However, when I attempt to run both tests, I am greeted with: exception 'ErrorException' with message 'Undefined variable: errors’ in <compiled template path> The views have some basic validation error rende

jakeharris's avatar
jakeharris's avatar jakeharris10yrs agoTesting
0
1
Chimeara's avatar

Moving from local to test server

I have used option 2 on this site https://driesvints.com/blog/laravel-4-on-a-shared-host to move my site from my localhost (Windows WAMP) to an Ubuntu shared server but the views don't seem to be working. I am using var/www/html/blue as my site folder with the recommended .htaccess file. My routes.php has the following: Route::get('welcome', function () { return view('welc

Chimeara's avatar
Chimeara's avatar frezno10yrs agoServers
11
1
Last reply by frezno 10yrs ago
zot24's avatar

[L5.1][Unit Test] basic authentication `be` from tests when using `onceBasic` as middleware doesn't work

I need to access my end points authenticated, however it's seems like is not working properly, I'm doing this from my controllers: $this->actingAs($user)->getJson("api/v1/contacts"); $this->assertResponseOk(); or $this->be($user); $this->getJson("api/v1/contacts"); $this->assertResponseOk(); However I don't get authenticated and I'm alw

zot24's avatar
zot24's avatar schnittsta...8yrs agoLumen
3
3
Last reply by schnittstabil 8yrs ago
rikh's avatar

Debug phpunit test using PHPStorm and Homestead

I use homestead as my VM and normally ssh in and run PHPUnit. I also use PHPStorm and use the debugger to track down problems. However, I've only been able to get this to work when debugging the site from the browser. I've never been able to get PHPStorm to start a debug session when running something on the command line in the VM. I've got PHPStorm 9 at the moment and have set

rikh's avatar
rikh's avatar Aleh10yrs agoTesting
3
2
Last reply by Aleh 10yrs ago
lara8818's avatar

Using Behat to test RESTful APIs

I've been trying to set up Behat to work with a Laravel 5 project my team is working on. The reason we've decided to go with Behat over something more traditional like PHPUnit or PHPSpec is because the Gherkin syntax is something that our product team can write for us and can be directly posted in our project management tool. While the Laravel-specific extension for Mink works

lara8818's avatar
lara8818's avatar waled8yrs agoTesting
5
1
Last reply by waled 8yrs ago
armomkrtchyan's avatar

Test file store method

$response = $this->call($method, $uri, $parameters, $cookies, $files, $server, $content); someone could bring example with uploading $files ?

armomkrtchyan's avatar
armomkrtchyan's avatar bobbybouwm...11yrs agoTesting
3
1
Last reply by bobbybouwmann 11yrs ago
montogeek's avatar

How to test a CRUD controller?

Hi! I am learning about testing and want to write tests for a CRUD controller before actually write the code, but I do not know how to start. I am using CodeCeption. Thanks!

montogeek's avatar
montogeek's avatar CommandZ11yrs agoTesting
2
1
Last reply by CommandZ 11yrs ago
Jonathan's avatar

View Composer in Integration Test?

I'm trying Jeffrey's new Integrated testing package. In my app, I set a wildcard view composer using $this->app['view']->composer('*', function ($view) { $view->with('currentUser', $this->app['auth']->user()); }); In one of my views, I display an 'Edit' button, if the currentUser id is equal to the profileUser id. However, when running the integration tests

Jonathan's avatar
Jonathan's avatar Jonathan11yrs agoTesting
1
1
Last reply by Jonathan 11yrs ago
rappasoft's avatar

Can someone test my github project?

I have been working on this boilerplate for a while, and the master branch works fine. However I started a feature branch for socialite integration, and I'm having issues locally. Trying to see if its just my localhost or my code. The branch is here: https://github.com/rappasoft/laravel-5-boilerplate/tree/feature/socialite_integration The bug i'm getting on localhost is after h

rappasoft's avatar
rappasoft's avatar rappasoft11yrs agoGeneral
0
1
nolros's avatar

Best approach to test DB

Hey guys What would be the best testing lib and approach to testing DB related methods. Example, $count = 0; foreach($create as $userPermission) { $spaceUser = SpaceUser::where('id', '=', $userPermission->target_user_id)->first(); $granted = $this->userPermissionEloquent->hasAnyUserPermissions($space, $spaceUser);

nolros's avatar
nolros's avatar olimorris11yrs agoTesting
2
1
Last reply by olimorris 11yrs ago
pasadinhas's avatar

Google Page Speed Test

Very interesting! :) https://developers.google.com/speed/pagespeed/insights/?url=http%3A%2F%2Flaracasts.com (not a question, just sharing)

pasadinhas's avatar
pasadinhas's avatar pasadinhas11yrs agoGeneral
0
1
zeecher's avatar

[PhpUnit] How to test custom headers

Hi, could anybody tell me how to access request headers during unit testing? Giving following error:

zeecher's avatar
zeecher's avatar zeecher11yrs agoTesting
1
1
Last reply by zeecher 11yrs ago
zoransa's avatar

L5 .env how to put test env in the same folder

Earlier we just could make .env.local.php .env.test.php and trsting scripts would pick up testing environment where scripts truncate tables and do havoc while on local I would actually like to preserve data that we pull from backup of production database.

zoransa's avatar
zoransa's avatar anand-mogh...8yrs agoGeneral
16
1
Last reply by anand-moghe 8yrs ago
dev3cplusnow's avatar

Call in a test with parameters

Hello, I'm trying to make a call to a URL using GET method and parameters, this way: $this->call('GET', 'company', ['foo'=>'bar']); or $this->call('GET', 'company?foo=bar'); but either don't work. Any idea about how to do this call?

dev3cplusnow's avatar
dev3cplusnow's avatar diogo.hart...11yrs agoGeneral
2
1
Last reply by diogo.hartmann 11yrs 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.