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

minortechnologies's avatar

No Tables Specified Error Following Successful Test

I am running into a strange error when unit testing my Lumen 5.5 application. The message I am getting in the console is: Illuminate\Database\QueryException: SQLSTATE[HY000]: General error: 1 no tables specified (SQL: select * where "batch" = batch order by "migration" desc). Note: I am using DatabaseMigrations in the test class and I am also using a sqlite

minortechnologies's avatar
minortechnologies's avatar minortechn...8yrs agoTesting
1
1
Last reply by minortechnologies 8yrs ago
D9705996's avatar

Use a different Database for a single Test?

I have the following test setup that tries to add an entry to a model and when I run the following test with the sqlite in-memory database everything passes. $this->json('POST', 'api/v1/authentications/ssh/credentials', [ 'username' => 'root', 'password' => 'goofFnBfo9mi0Y', 'description' => 'test' ])->assertSta

D9705996's avatar
D9705996's avatar D97059968yrs agoTesting
2
2
Last reply by D9705996 8yrs ago
Erwin's avatar

Test fails due to redirect to root

Hi Guys, I have a very basic test where I test the logout process. This is my test: <?php namespace Tests\Feature; use Tests\TestCase; use Illuminate\Foundation\Testing\WithFaker; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Validation\ValidationException; class LoginTest extends TestCase { use

Erwin's avatar
Erwin's avatar Erwin8yrs agoTesting
13
2
Last reply by Erwin 8yrs ago
lubart's avatar

Use visit() few times in one single test

I am testing my Laravel 5.5 application with BrowserKitTestCase package. I receive an failure every time if I use visit() method more than one time in one single test, for example: /* @test */ function my_simple_test(){ $this->visit('product/1') ->see('Product #1'); $this->visit('product/2') ->see('Product #2'); // assertion fails } but on

lubart's avatar
lubart's avatar lubart8yrs agoTesting
2
1
Last reply by lubart 8yrs ago
Webiondev123's avatar

How can you test PHP payment system ?

How can I test the PHP payment system which once card details are entered directs to bank payment gateway?

Webiondev123's avatar
Webiondev123's avatar Thyrosis8yrs agoPHP
2
1
Last reply by Thyrosis 8yrs ago
kitman's avatar

How to revert data for this unit test

hi, my fd told me that for every single test we only revert the data that it created for that test, so then we looked at the laravel doc and the only method we can use is "use RefreshDatabase;". but this will clear all the data in every table, I explain why laravel have to do it that way, but he still thinks it is strange, so is there a way we can revert the data that

kitman's avatar
kitman's avatar Nash8yrs agoTesting
1
1
Last reply by Nash 8yrs ago
ntraykov's avatar

How to test that a user is successfuly logged in?

I have the following test: /** @test */ public function after_registration_the_user_must_be_logged_in() { $email = $this->faker->email; $response = $this->sendAjax('post', '/auth/register', [ 'email' => $email, 'password' => $this->faker->password ]); $this->assertEq

ntraykov's avatar
ntraykov's avatar ntraykov8yrs agoTesting
6
1
Last reply by ntraykov 8yrs ago
tiagomatosweb's avatar

Laravel test different scenarios

Hi all, I am doing testings in Laravel 5.3+. Everything is going well, but there is a particular case that there must be a better/quicker way to create unit test. Lets say I have Project model which has an attribute called status. Status can be draft, in_progress and closed A project belongs to a user who is the owner. The owner can add other users to a project as a participan

tiagomatosweb's avatar
tiagomatosweb's avatar tiagomatos...8yrs agoLaravel
4
1
Last reply by tiagomatosweb 8yrs ago
Scoop7's avatar

How do you test a middleware in 5.5 ?

Hello, How could I test my middleware ? Here I am testing if a admin can access a middleware protected route, that returns a 500, if the user does not have a privileged ip - then the middleware returns a 401 (not authorized) when trying to access the /500 page . My test: use App\Http\Middleware\OnlyAdminIp; use Illuminate\Http\Request; use Tests\TestCase; use Illuminate\Foundat

Scoop7's avatar
Scoop7's avatar Scoop78yrs agoTesting
2
1
Last reply by Scoop7 8yrs ago
ardf16's avatar

AssertFalse - false test fail or what?

Hello, In test i have: dd($post->subscribed == false); // returns true $this->assertFalse($post->subscribed); // fails test ... any ideas??

ardf16's avatar
ardf16's avatar ardf168yrs agoTesting
2
1
Last reply by ardf16 8yrs ago
longestdrive's avatar

Laravel Dusk - Fails test but how can I see what test sees?

Hi I'm getting started with Laravel Dusk (v2) with a Laravel 5.5 app I'm starting small and want to test that a user can log in so have created this test: public function test_user_can_browse_to_login_page_and_log_in() { // $this->logout(); $this->browse(function (Browser $browser) { $browser->visit('/') ->assertSee('Y

longestdrive's avatar
longestdrive's avatar giorg6yrs agoTesting
5
1
Last reply by giorg 6yrs ago
keevitaja's avatar

Test how does a website handle load

Hello! Can anyone recomment a service (paid is fine!), where i can test how does a webpage handle load. The service should be able to mock n+1 users requesting a page. Also requests must run js for any ajax request. Not laravel spedific at all!

keevitaja's avatar
keevitaja's avatar keevitaja8yrs agoTesting
0
1
jrdi's avatar

Test fails when special characters are used

Hi, First of all, I'm not english speaker, thus sorry for my language mistakes. I'm new in PHP and Laravel world so maybe this question is a bit "silly". I'm doing a simple test that just check if a resource show page is rendered correctly. Let's say that I have a model which has a field called name and it's populated using Faker with a random name, for example, O'Con

jrdi's avatar
jrdi's avatar jurios8yrs agoTesting
2
1
Last reply by jurios 8yrs ago
jcmargentina's avatar

Test API route to retrive user (the default one) - not working

I might be doing something wrong or maybe I am confused. I am trying to delcare an API rote in routes/api.php, but first of all I tried to test the default one Route::middleware('auth:api')->get('/user', function (Request $request) { return $request->user(); }); but whenever I call it (/api/user) ... I get nothing from it. what about this ? How can I make it work? H

jcmargentina's avatar
jcmargentina's avatar jcmargenti...8yrs agoLaravel
1
1
Last reply by jcmargentina 8yrs ago
longestdrive's avatar

Redirect test passes when run on it's own but fails when run after other tests

I'm trying to do a simple test to check that a user is redirected if not logged in. When I run the test on i'ts own it passes but if I run it as part of a series of tests on a feature it fails. here is my test: <?php namespace Tests\Feature\createReservation; use Illuminate\Foundation\Testing\DatabaseMigrations; use Tests\TestCase; use Illuminate\Foundation\Testing\WithFa

longestdrive's avatar
longestdrive's avatar longestdri...8yrs agoTesting
1
1
Last reply by longestdrive 8yrs ago
aliG's avatar

Need to test whether methods have been called on a specific interface

I have got a class, which accepts multiple contracts i.e. interfaces in its constructor. class Chapter { public function __construct( XPath $xpath, MetaData $metaData, BinaryReference $binaryReference, Section $section, Keyword $keyword, AbstractContent $abstract, Affiliation $affiliation, Contribut

aliG's avatar
aliG's avatar aliG8yrs agoTesting
0
1
Webiondev123's avatar

Mailgun password reset error Expected response code 250 but got code "554", with message "554 Free accounts are for test purposes only. Please upgrade or add the address to authorized recipients in Account Settings. "

Expected response code 250 but got code "554", with message "554 Free accounts are for test purposes only. Please upgrade or add the address to authorized recipients in Account Settings. " I have my domain set up.. I want the email to be [email protected] Here is my setup in laravel MAIL_DRIVER=smtp MAIL_HOST=smtp.mailgun.org MAIL_PORT=587 MAIL_USERNAME=p

Webiondev123's avatar
Webiondev123's avatar Webiondev1...8yrs agoLaravel
3
1
Last reply by Webiondev123 8yrs ago
bertog's avatar

Test and Strange Exception behaviour

I was in doubt so I've written this little test: /** @test **/ function it_test_if_failed() { $this->get('/not-present'); $this->assertTrue(true); } Why the test in Laravel 5.6 returns green while the route is obviously not present? Why it not raise the exception? And how I can revert to the previous behaviour? Thanks in advance Guido

bertog's avatar
bertog's avatar bertog8yrs agoTesting
2
1
Last reply by bertog 8yrs ago
ashitvora's avatar

What's the best way to test a feature not dealing with calling third party API?

I am working on an app were two people receive an email with 2 links. Accept Reject When both the parties click on ACCEPT link, I want to send an email. What's the best way to test this using an automated test to make sure email is only sent out when both the parties click ACCEPT. The default state is PENDING and once the user clicks on any one of the links, the state is chan

ashitvora's avatar
ashitvora's avatar bobbybouwm...8yrs agoTesting
4
1
Last reply by bobbybouwmann 8yrs ago
mosesnagar's avatar

how to know if its unit test or feaute

hi, i'm quite new in testing. how do i know if its unit test or feature ? for example, i want to test my models. i have User, Forum, Topic and Comment with relationships between them. when i want to test their realtionships for one hand its like unit test - i am testing a small part, a method. for the other hand its a feature because it test the model with other models so their

mosesnagar's avatar
mosesnagar's avatar bobbybouwm...8yrs agoTesting
3
1
Last reply by bobbybouwmann 8yrs ago
StepToMe's avatar

Phpunit test not running with multiple database setup

We have a multi-tenancy set up with one main and other tenant databases and having some problems running non-sqlite tests. Databases are mysql. Currently trying to run tests against the main database and one tenant database. The connections in my model constructors are set like so: BaseMainModel $this->connection = config('database.main'); BaseTenantModel $this->connectio

StepToMe's avatar
StepToMe's avatar scottzirke...8yrs agoLaravel
7
1
Last reply by scottzirkel 8yrs ago
HCK's avatar

Test methods fail using Storage: Illuminate\Http\Testing\imagepng() in Laravel

Hello, I'm doing TDD to test my development, my tests were passing until I decided to reinstall php to repair the sqlite driver for testing (the main driver is mysql). So when I run my hole suite of tests this error shows in every method that uses the storage: Error : Call to undefined function Illuminate\Http\Testing\imagepng() {laravel}/framework/src/Illuminate/Http/

HCK's avatar
HCK's avatar Osama_Khal...8yrs agoTesting
1
1
Last reply by Osama_Khalid 8yrs ago
wamae's avatar

Database transactions not being cleared after test

use Tests\DuskTestCase; use Laravel\Dusk\Browser; use Illuminate\Foundation\Testing\DatabaseTransactions; use App\User; use Illuminate\Support\Facades\DB; class PlotsTest extends DuskTestCase { use DatabaseTransactions; public function setUp() { Parent::setUp(); $this->user = User::find(1); } /** * @test * @group plots */

wamae's avatar
wamae's avatar wamae8yrs agoTesting
2
1
Last reply by wamae 8yrs ago
qxoivwec's avatar

How can I run the same test but with different data?

Hi, I have an application which handles a lot of phone numbers. Now I want to test an array of items but I don't want to loop over them every time I'm writing the test. I have to repeat this for multiple tests... Here is a sample code public function testPhoneNumberLenght() { $phoneNumbers = [ '0123456789', '9876543210', ]; foreach ($phoneNumber

qxoivwec's avatar
qxoivwec's avatar qxoivwec8yrs agoTesting
2
2
Last reply by qxoivwec 8yrs ago
thinsoldier's avatar

Is it possible to use Laravel Dusk to test a non Laravel site?

I have some legacy projects that I want to first upgrade to PHP 7 and then much later convert one or two of them to Laravel. Most of them are not using OOP code so browser based testing seems like a faster and easier way to test them and Laravel Dusk seems like the fastest and easiest way to do browser based testing.

thinsoldier's avatar
thinsoldier's avatar Ironmax4yrs agoTesting
4
1
Last reply by Ironmax 4yrs ago
jward3@email.unc.edu's avatar

Set environment at runtime in phpunit test

I'd like to test a vallidation rule for passwords that has different requirements depending on the environment you're in: anything goes in 'local', but passwords must be 'strong' in production. The rule: class Password implements Rule { ... public function passes($attribute, $value) { $pattern = app()->environment('local') ? '/.+/'

jward3@email.unc.edu's avatar
jward3@email.unc.edu's avatar anilcancak...8yrs agoTesting
5
4
Last reply by anilcancakir 8yrs ago
Web Confection's avatar

Technical Interview Test

The company I work for has been trying to recruit software engineers for 2+ years with limited success. In 2+ years we have offered 6 people a role and only recruited two people, including myself. We have a generic technical test which applicants are obliged to complete before interview and the standard of entry has been quite poor. Our test is a simple... "...create a reu

Web Confection's avatar
Web Confection's avatar CJJ8yrs agoGeneral
2
1
Last reply by CJJ 8yrs ago
XSkinner's avatar

Your thoughts about this test

Hello. I'm starting with testing. I have completed almost all the testing series here at Laracasts, but I'm still not very confident about writing tests though. So, I'm creating a simple app (API), and one of my tests placed in the Feature folder is as follows. public function an_authorized_user_can_update_a_given_user_by_id() { $user = factory('App\Models\User')-&

XSkinner's avatar
XSkinner's avatar XSkinner8yrs agoTesting
2
1
Last reply by XSkinner 8yrs ago
RonB1985's avatar

Test sometimes passes, sometimes fails

I am purely focussing on testing since I haven't done that up until now. And for this I am just following the "Let's build a forum" series. I have done everything that Jeff did as well, but I am getting unexpected results. For starters, in his second lesson: https://laracasts.com/series/lets-build-a-forum-with-laravel/episodes/2 The most simple test is returning a 404

RonB1985's avatar
RonB1985's avatar azzazkhan3yrs agoTesting
4
1
Last reply by azzazkhan 3yrs ago
deepu07's avatar

How to test Email mock in laravel.

Here I'm trying to send a mail who are not registered within last date. When I'm trying to run this test case It is skipping email assertions and executing last assertion. Can you guys help me out on this? Thanks In advance. (Assume Last date is yesterday) ```$msg = [ 'subject' => 'mail subject', 'body' => 'mail body', 'username' => 'userma

deepu07's avatar
deepu07's avatar deepu078yrs agoGeneral
4
1
Last reply by deepu07 8yrs ago
phpMick's avatar

Query sqlite database while test is running.

I can't help wondering if this is possible. If I have an xdebug breakpoint in my test, is there any way that I can run up sqlite and check what is happening in the tables? Mick

phpMick's avatar
phpMick's avatar phpMick8yrs agoTesting
4
1
Last reply by phpMick 8yrs ago
skoobi's avatar

How to test Stripe vue component

Hi, Im just going through the Dusk testing tutorials and trying to implement it into my project, but i'm trying to figure out how to test the Vue component for Stripe (from the laracasts) I tried ->clickLink('Subscribe') but it doesn't recognise it. Any help would be greatful. Many thanks

skoobi's avatar
skoobi's avatar skoobi8yrs agoTesting
0
1
Philipp's avatar

How to test 'syncWithoutDetaching' function in phpunit

Whenever I create a new settlement I want to attach all current resources in the db to it - so here's all my code: Models: class Settlement extends Model { public function resources() { return $this->belongsToMany(Resource::class)->withPivot('count'); } } class Resource extends Model { public function settlements() { return $th

Philipp's avatar
Philipp's avatar bobbybouwm...8yrs agoTesting
3
1
Last reply by bobbybouwmann 8yrs ago
Kirk.Franklin's avatar

Need a look at a Laravel 5.5 feature test

My product factory contains a slug: $factory->define(Product::class, function (Faker $faker) { return [ 'title' => $faker->sentence(4, true), 'slug' => $faker->slug, 'description' => $faker->paragraph, ]; }); My feature test uses the factory to make a new instance: $product = factory(Product::class)->make();

Kirk.Franklin's avatar
Kirk.Franklin's avatar jbloomstro...8yrs agoCode Review
4
1
Last reply by jbloomstrom 8yrs ago
louposk's avatar

Start a Laravel Dusk test from inside a Laravel form

Hi guys, is there any way that i can run a laravel dusk test using a form? I would like to add the url in a form and when submit the button to run browser test using Dusk. Something like this: https://ibb.co/mh6D9R Thank you

louposk's avatar
louposk's avatar louposk8yrs agoLaravel
9
1
Last reply by louposk 8yrs ago
joeyrush's avatar

No matches from fulltext search index query within laravel test suite

So I have a very simple search method on a "Note" model that looks like this: public static function search($query) { $results = self::whereRaw("Match(name,body) AGAINST('$query')") ->get(); return self::processSearchResults($results, $query); } The processSearchResults() just attaches some extra fields onto the results - nothing to wo

joeyrush's avatar
joeyrush's avatar WillF1yr agoTesting
16
5
Last reply by WillF 1yr ago
swist's avatar

Can I attach a parameter to the test class (globally)

Hi, I have couple test classes, I am wondering can I somehow attach to every get methods a parameter to the class - f.ex. in constructor. I use $this->get($url)->assertSee('blabla'); can I put in constructor a modification that every such request will be sent with ['foo'=>'bar'] ?

swist's avatar
swist's avatar siangboon8yrs agoTesting
1
1
Last reply by siangboon 8yrs ago
mikevaldez92's avatar

Test failing on Role assignment - failed asserting False is True

Hope everyone is having a wonderful Monday afternoon! I wrote a test to check to see if a user was being assigned a Role upon visiting a particular create() route. When I manually test this through the browser, I'm seeing new Users I create be assigned the proper Role, but my test keeps failing. I was wondering if I could get some pointers on writing a test that can properly ch

mikevaldez92's avatar
mikevaldez92's avatar tykus8yrs agoTesting
3
1
Last reply by tykus 8yrs ago
gilmojoa's avatar

using a test database with dusk

hi, I am trying to get my laravel dusk tests working with a test database and I have followed the pretty straight forward steps to do this with the database configuration and the .env.dusk.local file pointing to that test database configuration. its not working for me and there are a few questions I have to help me to understand why So firstly, the issue I have is that its not

gilmojoa's avatar
gilmojoa's avatar gilmojoa8yrs agoTesting
2
1
Last reply by gilmojoa 8yrs ago
PaulClarke's avatar

Cannot correctly test a Queued Notification with email

Hi, I am trying to properly test a Notification via email on a queue so that I can be absolutely clear that one user received it and another type of user did not. The code works correctly, but I cannot get the test right. I am assuming that the reason is that I don't have a worker on the Queue during testing so the job is never processed and I am not certain how to change that.

PaulClarke's avatar
PaulClarke's avatar bobbybouwm...8yrs agoTesting
3
8
Last reply by bobbybouwmann 8yrs ago
mjlovefl's avatar

How to test a $model->create(); failure.

I am stumped on how to test a failure in a create() method. Given a function like: /** * Add an item. * * @param string $name * * @return \App\Item|null */ private function addItem( $name ) { $item = $item->create([ 'name' => $name, ]); if ( ! $item ){ return false; }

mjlovefl's avatar
mjlovefl's avatar mikepmtl8yrs agoTesting
3
1
Last reply by mikepmtl 8yrs ago
theFinalArbiter's avatar

How can I test JS code when using Laravel Mix?

Hi guys, I have a JS file I would like to write tests for but I am not sure where to start. The files full path is resources/assets/js/ModelTransformer.js I tried to setup a test class myself and run with node but then I am bypassing all the babel stuff so it wont work. I also thought about making a test page in addition to my SPA (react) but I rather not clutter the actual cod

theFinalArbiter's avatar
theFinalArbiter's avatar theFinalAr...8yrs agoJavaScript
2
2
Last reply by theFinalArbiter 8yrs ago
phpMick's avatar

Test for message after redirect.

Hi, How can I test that I get this message: public function doSomething() { if($ok){ return view('message-page') ->with('title','The message?') } } My test just looks like this: $foo->doSomething(); What can I assert to check the message that is passed to the view?

phpMick's avatar
phpMick's avatar phpMick8yrs agoTesting
7
1
Last reply by phpMick 8yrs ago
jrdavidson's avatar

Refactoring code snippet for test suite

I'm trying to figure out how I can better refactor this section in my code because it is located in every test file in my test suite. The only difference is the the slug is different for the permission. Any ideas? public function setUp() { parent::setUp(); $this->user = factory(User::class)->create(); $this->role = factory(Role::class)->create(['slug' =

jrdavidson's avatar
jrdavidson's avatar MikeHopley8yrs agoTesting
4
2
Last reply by MikeHopley 8yrs ago
deepu07's avatar

Looking for Php Unit test cases resources or code samples for Controllers and models

How to write a test cases for controllers(index, update, store, delete) and models......If you know any resources or sample codes. Please send me a link. Thanks in advance.

deepu07's avatar
deepu07's avatar bobbybouwm...8yrs agoGuides
1
1
Last reply by bobbybouwmann 8yrs ago
kiyon's avatar

How can I test a failed job

Hello everyone, I have a Job. <?php namespace App\Jobs; use Illuminate\Bus\Queueable; use Illuminate\Queue\SerializesModels; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use App\User; class StatJob implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesMode

kiyon's avatar
kiyon's avatar franciscoc...1yr agoTesting
4
1
Last reply by franciscocaldeira 1yr ago
ciarlill's avatar

A general (long) question on TDD and test organization

So lets say we have a resource called 'Organization'. The application has 3 basic roles: admin, manager, staff. The roles are not really important, just showing that we need a policy for who can change what in the Organization. We have the following classes that support working with an organization via an API: Organization (model) OrganizationController OrganizationPolicy Orga

ciarlill's avatar
ciarlill's avatar michapiets...7yrs agoTesting
2
1
Last reply by michapietsch 7yrs ago
jago86's avatar

Test package routes

Hey guys, I have a Laravel package that exposes a couple of routes. I have written all my other unit test as always. But I need to test this routes results as well. I don't know if is possible to serve the routes when the package test suite is running or if I have to take another approach for this case. Any help is appreciated.

jago86's avatar
jago86's avatar bashy8yrs agoTesting
2
1
Last reply by bashy 8yrs ago
nguonchhay's avatar

Generate test report in Laravel Dusk

Hi everyone, Is there anyway to generate a report after running test with Dusk? Like Behat, there is a report file after the test as well as a library to display that test report with a nice format. Could someone give some tips to do so with Dusk? Thanks

nguonchhay's avatar
nguonchhay's avatar thulasi7yrs agoTesting
1
1
Last reply by thulasi 7yrs ago
Dean's avatar

PHPUnit won't run one test in a file but the rest are fine

I added a new test to one of my test files, and all the other tests run fine as does running all tests but when I run just the specific test via vendor/bin/phpunit --filter only_the_validated_fields_are_set_when_creating_a_thread the test doesnt run and I jsut get a No tests executed! message. function only_the_validated_fields_are_set_when_creating_a_thread() { $this->w

Dean's avatar
Dean's avatar Dean8yrs agoGeneral
3
1
Last reply by Dean 8yrs 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.