Category "phpunit"

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

PHP Fatal error: Class not found - PHPUnit

I'm trying to use PHPUnit in a PHP project. Here is my project structure (files are in italic font style) controllers Pages.php tests pagesTest.php vendor

How to Mock the Request Class in Laravel?

I'm trying to test a function that depends on $request->all(); in a method. How do I mock the Request class so $request->all(); returns ['includes' =

Cannot return objects in @dataProvider PHPUnit

Is it allowed to return objects from @dataProviders to test methods? public function iOsMessages() { return [ 'update available' => [1,

Autoloading classes in PHPUnit using Composer and autoload.php

I have just installed PHPUnit version 3.7.19 by Sebastian Bergmann via Composer and have written a class I would like to unit test. I would like to have all my

How to assert parameter attribute sub-structures in PHPUnit mock call expectations

I am testing an parameter sent to a mocked event handler. The parameter is an object of "Event" sub-type, which itself has some data nested inside it. I want to

PHPUnit - REST API testing

I have REST API written in php, i want to test it with phpunit. I wrote test like this, it works but response body was empty. I tested it with fiddler, it se

phpunit - testing is painfully slow

I am diving deeper and deeper in the world of unit testing. One issue I encountered, and this is where I would like feedback, is when one runs multiple test su