Category "phpunit"

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

Phpunit partial mock + proxy Entity

I tried find solution to my issue but didn't find anything. I use: Symfony, Doctrine, PhpUnit I have one entity class InvoiceNumerator: /** * InvoiceNumerat

How to access Session in PHPUnit WebTestCase (Symfony 5)

I'm trying to test methods which requires Sessions in my PHPUnit WebTestCase, with no success. PHP 8.0, Symfony 5.4 Here's my code: When user log-in, I'm saving

Laravel + phpunit + github actions = Failed asserting that '1' is identical to 1

I'm trying to make CI pipeline and run phpunit tests via GitHub actions. First of all: tests work fine on my local machine (mac os). Then, when I do git push my

Laravel Collections. Is there some kind of assertStructure method?

I'm writing tests and I want to assert, that a returned collection has some specific structure. For asserting jsons I'm using assertJsonStructure() method on

PHPUnit gives error: Target [Illuminate\Contracts\View\Factory] is not instantiable

I created a simple test for my new Laravel 7 application. But when I run php artisan test I get the following error. Target [Illuminate\Contracts\View\Factory]

PHPUNIT Test - Expected Status 200 But Received 500

I keep getting status 500 when 200 is expected. These are the files: ExampleTest.php namespace Tests\Feature; use Tests\TestCase; use Illuminate\Foundation\T