Skip to content
Advertisement

Tag: testing

Feature test for HTTP RESTful API on Laravel 8

I’m trying to write a feature test in RESTful API that I have been created in laravel 8. I have ChatController that gets user chats by getUserChats method: that called by this route: this is my feature test on this route: the test runs successfully by this green output OK (1 test, 3 assertions) but I don’t know this is

Carbon object in mockery php test

Thank you for your time. I have stripped out the fluff from the code/test. The furthest I have got with this is that setAttribute requires two strings as paramĀ“s, but i am passing in an Carbon object, which Mockery as a test suite does not like? Is this the case, is there a better way to test dates with Mockery/PHPUnit?

Laravel. Tests clear the active DB

The tables in my active DB are empty after tests. I have the test environment variable DB_CONNECTION=mysql_testing. When I run my tests and do dd(env(‘DB_CONNECTION’)) – everything is fine. I see ‘mysql_testing’. But when I write dd( DB::connection()->getDatabaseName()) I see the wrong DB name(for example ‘db_name’, but it should be ‘testing_db_name’) . It is the name of the active DB.

Advertisement