Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
18 views

Github Action Runner Not Connecting To Sqlite Database

All the questions in this topic are so advanced, hard to believe that I'm the only one dumb person struggling with this. I have a Github Laravel action runner configured with the following yml file: ...
domjanzsoo's user avatar
0 votes
0 answers
32 views

How to Mock S3ClientInterface with PHPUnit 10+

So this question has been asked here before - How to Mock Aws\S3\S3Client for phpunit // how to mock magic methods but the answer there is no longer valid because addMethods was deprecated in PHPUnit ...
donatJ's user avatar
  • 3,335
0 votes
0 answers
16 views

Unplanned user logout during PhpUnit test

I had a test environment that was working perfectly fine until every request needing authentication started to fail (functionnal tests, class extending webTestCase). I suspect it does so since adding ...
Yoc's user avatar
  • 1
0 votes
0 answers
30 views

Laravel sanctum during testing: "Session store not set on request."

This error happens very often for people, most of the time because SANCTUM_STATEFUL_DOMAINS is not set correctly. I did set it correctly for local development but the error happens during testing, e.g....
Tim's user avatar
  • 953
0 votes
1 answer
66 views

PHP/Laravel: Error: Call to a member function __call() on null

I’m currently working on a Laravel project and I’m facing an issue with setting up a factory for a pivot table. Specifically, I’m trying to create a factory for a table that serves as a pivot between ...
barbgluz's user avatar
0 votes
0 answers
21 views

Symfony process component and test environment

Problem: I need to run command in test environment, so I found to use symfony/process component. Then I tried to run process in this way: public function testProblem(): void { $user = $this->...
ais's user avatar
  • 71
-1 votes
0 answers
38 views

Symfony 5 testing: why I can't get environment variables from .env files? [duplicate]

I have .env, .env.test, .env.test.local files in my project. Variables are specified in .env.test: APP_ENV=test APP_DEBUG=1 However, when the test is running (WebTestCase), these variables don't seem ...
Mik's user avatar
  • 383
0 votes
1 answer
25 views

Laravel Test not updating the new test files

I am using Laravel 11, installed Laravel Breeze and PHPUnit Test. I changed where to store my User model, something like app\Infra\Models\User.php I run "php artisan test" to run all the ...
Tommy Hoang's user avatar
0 votes
0 answers
13 views

is there a way for a PHPUnit extension to get information from within the test?

I'm trying to implement a PHPUnit extension and I need data that the test's setUp() put in a static property on a class. (Specifically, Drupal's Database::getAllConnectionInfo().) It's not there when ...
joachim's user avatar
  • 30.3k
0 votes
0 answers
55 views

Does PHPunit reset local variables?

I have such as Testcase: class GenerateTest extends AbstractTestCase { private int $requestTime = 0; ... protected function setUp(): void { $this->requestTime = $_SERVER['...
Alex's user avatar
  • 34.7k
2 votes
1 answer
95 views

Running Tests Across Multiple Repositories from a Single Test Directory

I’m currently working on a website with a somewhat complex architecture, which is structured as follows: REPO-A /.git /files /SUB-REPO /.git /files REPO-B /.git /files My technical ...
Kolobo's user avatar
  • 59
2 votes
0 answers
56 views

Laravel PHPUnit - PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 102400 bytes)

We are experiencing apparent memory leaks with our Laravel 10 application tests. We recently upgraded from version 8 to 10, hoping this would resolve the issue, however it has not. Using https://...
Drew Gallagher's user avatar
2 votes
1 answer
92 views

Laravel 10 - how to mock static function in other class:

in CommonHelper class: class CommonHelper { public static function getValue(string $category, string $name) { } } in MyService class: public function getContentOrtherService(): ...
Nguyễn Minh Đức's user avatar
0 votes
1 answer
45 views

PHPUnit 'Error : Class "path\to\class\classToTest" not found'

I'm trying to write some unit tests. However no matter what I do I keep getting this error: Error : Class "path\to\class\classToTest" not found The test I'm trying to run has a simple ...
bencher's user avatar
  • 47
1 vote
0 answers
31 views

Laravel Testing with Multiple Databases: Preventing Migrations During Tests / Migrations failing

I'm working on a Laravel project that uses multiple MySQL databases. The main database (core_db) contains system tables like users, migrations, etc., while express_db and regio_db contain most of the ...
spyro95's user avatar
  • 146
2 votes
1 answer
94 views

Laravel 11: Is it possible to force PHPUnit to trigger / "press" CTRL+C to simulate interruption of an artisan command?

I have an artisan command that can run for minutes or hours, processing multitude of records in a loop within the handle() method. I have introduced the ability to interrupt such a long process by ...
Matt Komarnicki's user avatar
0 votes
1 answer
67 views

Laravel - Mock single method in a command using PHP UNIT

I'm trying to test a command where there's a method I want to mock because it makes a call to an external service using Guzzle, but no matter what I try, I can't seem to mock it successfully. It ...
Miguel Heredia's user avatar
1 vote
1 answer
70 views

How can I test that the PHP code under test calls the proper method on a trait?

Edit: After reading one of the comments, I realized I misspoke pretty badly in the original post, I've made some edits to clarify. Essentially, I need to check the results but am struggling with that ...
jrgilman's user avatar
  • 472
1 vote
1 answer
55 views

Mocked method is not used with Instance

Inside my Export class I have created this method: public function getBranches() { return Branch::all(); } I want to Mock this Method. Now I have the following piece of code in a testcase: $mock ...
Gommiboum's user avatar
  • 107
0 votes
0 answers
60 views

tearDownAfterClass not being invoked with PHPUNIT 11 and LARAVEL 11

I cannot figured out why the tearDownAfterClass() is not being called. PHPunit version: "phpunit/phpunit": "^11.2" Laravel version: "laravel/framework": "^11.10&...
Sergio Costa's user avatar
1 vote
0 answers
63 views

How to write unit test for PHP Script without functions?

I'm trying to write a unit test for a PHP script that does not contain any functions or classes. It is just a plain PHP script that returns header('Location: ${url}') when a specific condition is met. ...
Visal's user avatar
  • 660
1 vote
0 answers
106 views

PHPUnit - Error: Call to a member function addContext() on null

When I run tests in GitHub worklfow action on my Laravel project, I get this error from all PHPUnit tests: Error: Call to a member function addContext() on null The addContext() function is not my ...
netdjw's user avatar
  • 5,905
2 votes
1 answer
95 views

Generate code coverage for a single test suite

I wish to determine which files are covered by each of my test suites separately. I am using PHPUnit 10.5 with Xdebug for code coverage on my PHP 8.1 project. Here is what my phpunit.xml configuration ...
Kolobo's user avatar
  • 59
1 vote
1 answer
60 views

Database locked in PHPUnit tests only

In my application SQLite works. But when I create tests in PHPUnit it's locked on the first write. I've hacked in some beginTranaction() and commit() but it still hangs on the commit() call. The test ...
Tac Tacelosky's user avatar
1 vote
1 answer
104 views

Strange behavior of symfony doctrine during phpunit test - field becomes null in database

I am using Symfony v6.4.8 doctrine/orm 2.19.5 phpunit/phpunit 9.6.19 I have build an REST API GET endpoint /api/contract/{$id} in Symfony. It performs an API request at another system, receiving ...
SvenW's user avatar
  • 27
3 votes
1 answer
247 views

How to mock/simulate Laravel JobQueued queue event in test?

I want to test multiple event listeners that listen for Laravel's built-in queue events (all the events that live in the Illuminate\Queue\Events namespace. The listeners are part of a package. ...
user25728292's user avatar
0 votes
2 answers
42 views

phpunit inject mocked object into another mocked object

I want to test the output of method checkCredentials(): Class BuildParticipant { public function __construct(DBConnectionWrapper $db, ?Logger $logger=null) { $this->participant = ...
Tim Morton's user avatar
  • 2,644
1 vote
0 answers
73 views

File Upload Validation test for Livewire component

I have a user creator Livewire component which has a profile picture uploader. Trying to write some the unit tests for the File field of that form, but it doesn't want to work. I'm sure that my ...
domjanzsoo's user avatar
0 votes
1 answer
38 views

Php Laravel PhpUnit Test Returns 404 error

My test result always return 404 but i define route for api. why like this? i cannot find any solution. my test function : public function test_can_update_integration() { $integrationArr = ['...
Mustafa UYSAL's user avatar
0 votes
1 answer
75 views

An error occurred, but no information is displayed

PS : I am new to StackOverflow and in computer science. My question may be blurry, so please be understanding and kindly tell me what I can improve :) I am currently testing my code with PhpUnit ...
Kolobo's user avatar
  • 59
1 vote
1 answer
118 views

laravel unit tests fail with Symfony\Component\Process\Exception\ProcessSignaledException 11

Trying to figure out what broke my development environment. It had been working well on my MacBook and then I updated something, and now most of my PHPUnit test files throw this error: Symfony\...
hanmari's user avatar
  • 1,414
0 votes
1 answer
33 views

How can I use a PHP-DI Container to pass mock objects while unit testing?

I have a controller that handles various cronjobs and I wanted to write unit tests for each function in the controller. The controller (lets call it TasksController) extends a base controller (let's ...
t_ramen's user avatar
0 votes
1 answer
56 views

Laravel can't find my table when testing using an alternate connection

I have an application in Laravel that requires the use of different connections. My model User requires a regular "mysql" connection, while the related model, let's call it "...
Gabriel Ontiveros's user avatar
2 votes
0 answers
54 views

How to write Laravel feature test for streamed content to browser?

I could use some help writing a feature test for a route that returns streamed content. Here's the details... I have a Laravel route: Route::get('/export/user/role/{role}', [Admin\ExportUserController:...
dfaltermier's user avatar
1 vote
0 answers
49 views

How to show full diff when assertEquals() fails?

I have a PHPUnit test that's failing but the test output is hiding important part of the failed data. How to make the whole data visible? To demonstrate the issue, here's a mock test UnitTest.php: <...
Mikko Rantalainen's user avatar
0 votes
1 answer
47 views

Laravel Model Mocking test with PHPUnit

I am trying to mock an update method in PHPUnit but so far shouldReceive('update') is not called. PostServiceTest.php public function test_can_update_a_post(): void { $mockedPostModel =...
Mr. Kenneth's user avatar
  • 1,408
0 votes
0 answers
55 views

Symfony's user login magic in WebTestCase not working

As described in the documentation, I try to log-in the user in a WebTestCase: class CreateStoreTest extends AbstractCrudTestCase { // ... protected function setUp(): void { ...
Anton's user avatar
  • 131
0 votes
0 answers
54 views

UnexpectedResponseException when attempting to take screenshot with Selenium Web Driver in PHP

Error: Facebook\WebDriver\Exception\Internal\UnexpectedResponseException: Error taking screenshot, no data received from the remote end /path/to/app/vendor/php-webdriver/webdriver/lib/Exception/...
TechFanDan's user avatar
  • 3,442
0 votes
1 answer
70 views

Error: Call to undefined function CodeIgniter\Test\helper() in PHPUnit tests for CodeIgniter project

I am working on a CodeIgniter project and have installed PHPUnit to run unit tests. However, when I execute the tests, I encounter the following error for each test, including the example tests ...
Franco Gutierrez's user avatar
1 vote
0 answers
51 views

Confusion about mock reuse in phpunit

i'm writing some unit tests and became stuck at what i first thought was a bug, but after much frustration seems to be intended (but impossible to find documentation/mention of) behaviour/usage. The ...
Kristians's user avatar
  • 784
-1 votes
2 answers
39 views

PhpUnit test use Mockery - Bypass exception of method from another class

I have a laravel project and I got a problem with using PhpUnit test use Mockery. This is the fist time I use Mockery. Below, I have some pseudo code: class Mail { public static function send($pin){...
VolkswagenLov's user avatar
2 votes
1 answer
53 views

Why do my PHPUnit tests in NetBeans run but don't result in any code coverage?

I have Xdebug running and in mode xdebug.mode=develop,coverage. I checked this with phpinfo() and got: Xdebug: Development Helpers ✔ enabled Coverage ✔ enabled I can run my tests, they ...
rhavin's user avatar
  • 1,652
0 votes
0 answers
19 views

codecoverage with phpunit on netbeans cant find its log

I'm trying to get code-coverage running in netbeans with phpunit 11. My tests are running but I constantly get this output: Full output can be found in Output window. Coverage log not found! Perhaps ...
rhavin's user avatar
  • 1,652
1 vote
1 answer
67 views

Validating argument at specific mocked method call index? PHPunit/Mockery

So a very simple test: a method persisting some objects gets an array of data. class A { public function __construct(private BucketRepository $repository){} public function saveObjects(array $...
Lehren's user avatar
  • 139
0 votes
1 answer
148 views

Laravel PHP Unit Tests With Postgres - SQLSTATE[23505]: Unique violation: 7 ERROR: duplicate key value violates unique constraint already exists

In the process of migrating from MySQL to Postgres we are running into this issue with our Laravel PHP Unit tests. We use seeders, factories, or models in our setUp() or seeding functions to insert ...
Drew Gallagher's user avatar
0 votes
1 answer
47 views

how to test a controller method echoing something?

I'm diving into a legacy symfony project with some controller methods echoing stuff (I know it's bad, ugly,... and I would change that eventually but for now I must not change any code, just add tests)...
Elianora's user avatar
0 votes
1 answer
32 views

PHPUnit test using mockery is failing to intercept a method call on a mocked class

Here is my PHPUnit test (PHPUnit 10.5.2 Mockery 1.6.11) public function testMergedDocumentsWithSuccessfulInit() { $params = new \Buan\Request\Parameters([], [], [], []); $...
Tom Arnautovic's user avatar
0 votes
0 answers
62 views

Unable to pass flags to artisan test command

I have started learning laravel for one of my projects and almost everything works in the test commands except passing the arguments line --drop-databases. ./artisan test --drop-databases Error ...
tbhaxor's user avatar
  • 1,853
0 votes
2 answers
247 views

How to unit test symfony dto with constraint attributes

I have a newly created Symfony 7 app and I have a DTO called: AuthCallbackDto <?php declare(strict_types=1); namespace App\Application\Model\Auth; use Symfony\Component\Validator\Constraints as ...
Matthew Fedak's user avatar
0 votes
2 answers
78 views

How do I deal with "The payload is invalid." in Gitlab CI/CD pipeline?

I am trying to run testJob in GitLab CI/CD for my (Laravel 11 + React Typescript with Inertiajs) and I keep ending up with the below error. I have ensured that the APP_KEY is set in the CI/CD ...
Klem Lloyd Mwenya's user avatar

1
2 3 4 5
201