skip to Main Content

Can Laravel 9 replace interface implementation in tests?

Here is an example of how I declared my configuration for MyService public function register(): void { $this->app->when(MyService::class) ->needs(IUser::class) ->give(fn (Application $app) => $app->make(ICompanyUserProvider::class)->getCompanyUser()); } So I want to replace ICompanyUserProvider implementation for testing purposes. I have already seen a…

VIEW QUESTION

Magento2 unit test error "Error: Call to a member function getDirectoryWrite() on null"

Magento2 unit test for block file for admin grid extending MagentoBackendBlockWidgetGridExtended is giving error "Error: Call to a member function getDirectoryWrite() on null" added below mocks, still error continues. $this->_filesystem = $this->createMock(Filesystem::class); $this->_directory = $this->createMock(DirectoryWrite::class); $this->_filesystem->method('getDirectoryWrite')->willReturn($this->_directory); Can anyone help here?

VIEW QUESTION

MySQL datediff function not available in SQLite used for unit tests – Laravel

I have used the following Raw query in my Laravel project. $statisticsInRangeDate = $myModel->selectRaw( "floor(datediff(created_at, '{$dateInfo['currentRangeDate']}')". " / {$dateInfo['daysRange']}) * {$dateInfo['daysRange']} AS diff_days_range, count(*) as total_clicks, ". 'min(created_at) ,max(created_at)' ) ->groupByRaw('diff_days_range') ->orderByRaw('diff_days_range DESC') ->get(); The raw query is: select floor(datediff(created_at,…

VIEW QUESTION

How to test json api? – Laravel

I have a test, which testing displaying deals. This test failed and show error Failed asserting that an array has the key 'user_id'.` I don't know reason why this error is public function a_test_display_deals() { $user = User::factory()->create(); $response =…

VIEW QUESTION
Back To Top
Search