Category "phpunit"

How do I hide '#StandWithUkraine' in PHPUnit 9.5.20?

I have recently upgraded to PHPUnit 9.5.20 and noticed that it is printing #StandWithUkraine for every test run. Eg. Testing started at 10:01 am ... Running in

Laravel: Feature test json validations unique rule issue

I recently started implementing the unit testing in Laravel 9.x framework. So far, I was able to write some basic rules without any complications. However, in m

Laravel request()->all() is empty in booted function when running tests

I created a trait sets up some Global Scopes based on the query parameters. It does that by reading from the request() helper and reading the query parameters f

Is there a way of formatting failed output from Laravel's assertSee() test?

Laravel has several built-in assertions that allow you to query the Response from a Request. public function testWebpage() { $response = $this-&

Database updates not readable while PHPunit WebTestCase (Symfony 5.1)

I have a problem asserting updates made by a form are really written in the database. I explain, I first do a create test (testCreateLactationForm), very simila

Phpunit @runInSeparateProcess ErrorException: unserialize(): Error at offset 0 of 3 bytes

I am writing a test to check the output(printing the result) of a function, that is changing headers and printing the result. To simplify it look like this: fun

How to change locale in Symfony5 / PHPUnit before calling request?

I need to change locale in my functional test: <?php namespace App\Tests\Controller; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; class Translati

Is there a way to use Foundry Model for Authentification inside Functional Tests?

1) App\Tests\Controller\Admin\Api\Promotion\PromotionDeleteControllerTest::test_deleting_promotion LogicException: The first argument of "Symfony\Bundle\Framewo

Symfony - "framework.test" config is not set to true

Using Symfony 5.2 and PhpUnit last version, I have this error with my functional test LogicException: You cannot create the client used in functional tests if t

"There is no active transaction" when refreshing database in Laravel 8.0 test

Using php 8.0.2 and Laravel 8.37.0, I am running tests where for every test the database data should be refreshed, since there is conflicting data per test (due

Trying to mock an http client that is inside a controller, using phpunit, but it doesn't work

I have to test the routes of a controller which uses Guzzle Wrapper as a client to get data from an API. The app uses Laravel as a framework. This is the part o

Where do I need to place a hook for phpunit?

The answer is probably very simple, but I've been running around in circles and I can't find an answer anywhere. I'm trying to mock a final class which is norma

Method Illuminate\Auth\RequestGuard::logout does not exist Laravel Passport

Am using Laravel Passport to build an API, I removed the web routes and its guard accordingly How can I test user logout? This is what I have so far: Lo

laravel and phpunit: could not find driver (SQL: PRAGMA foreign_keys = ON;)

I have run my laravel app with phpunit. Everything is fine until at some point when I run my test again turns out with this error. Illuminate\Database\QueryExce

Illuminate\Database\QueryException: SQLSTATE[HY000]: General error: 1 no such table - In clone project

everybody! I've finished a laravel project backend with postgres and it has a phpunit tests, everything it works. So, I did upload to Github. When I did "git

Symfony 5.2 mock service disappear in second request

I used Symfony 5.2 and I need to mock service method which execute send request to stripe payment system, obviously don't need to execute it when tests executin

Symfony 5.2 mock service disappear in second request

I used Symfony 5.2 and I need to mock service method which execute send request to stripe payment system, obviously don't need to execute it when tests executin

PHP Startup: Unable to load dynamic library, when running unit tests

when I try to run my unit tests, I get this error PHP Warning: PHP Startup: Unable to load dynamic library 'bz2' (tried: \xampp\php\ext\bz2 (The specifie

(PHPUnit) PHP Fatal error: Uncaught Error: Call to undefined function each()

firstly I was receiving a warning and a fatal error. The warning: Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue

PHPUnit 7: Failed asserting that exception of type \InvalidArgumentException is thrown

I have this code: public function method(){ //... if(!$exist) { throw new \InvalidArgumentException('Ce client inexistant', 400); } } I do the UT