Skip to main content
Filter by
Sorted by
Tagged with
2 votes
1 answer
76 views

I am doing some unit testing with PHP. I got stuck on an error that the fluent interface of PHPUnit requires an intermediate variable. What is the reason for this behavior? See MyTests::works vs. ...
Sven Eppler's user avatar
  • 1,796
1 vote
2 answers
148 views

I have a problem which I find awfully hard to debug: In my application, I currently have about 1000 tests, so not much. They are split across several directories (tests/someDir, tests/someOtherDir, ...
PhilippG's user avatar
0 votes
1 answer
92 views

I can't seem to find a definitive answer on how to test the following boot methods using PHPUnit tests in Laravel. I'm referring to the mthods in public static function boot() on a model. Survey model ...
Daniel Harper's user avatar
0 votes
0 answers
129 views

In my Laravel application, I have set up two databases in a single server. All specific migrations and model classes have $connection property set up to use blog instance. The app works fine, no ...
Gasimoff's user avatar
1 vote
0 answers
45 views

I have PHPUnit tests that use data providers as inputs, and by default these are outputted in a diff-like format (when running with php artisan test): 1) Tests\Feature\MyTest::test_feature with data ...
Hashim Aziz's user avatar
  • 6,576
2 votes
1 answer
53 views

I have following server variable in phpunit.xml: <php> <server name="APP_DEBUG" value="false"/> </php> Sometimes while developing, I want have APP_DEBUG ...
Justinas's user avatar
  • 43.9k
0 votes
0 answers
98 views

I'm currently building a multi-tenant application using stancl/tenancy (every tenant uses their own database) in my Laravel application. Whenever I'm writing tests, tests fail a lot due to the error ...
FryingPan's user avatar
  • 123
1 vote
0 answers
191 views

I have a contrived test case showcasing how multiple test cases can slow the entire execution time down, as even though each is quick on its own, they add up if waited for before executing the next. I ...
k0pernikus's user avatar
  • 67.6k
1 vote
1 answer
61 views

I'm trying to set up testing for a Wordpress child theme. I've use the wp-cliwp scaffold theme-tests command to scaffold some tests. Inside of my child theme's functions.php file, I load some ...
jloosli's user avatar
  • 2,595
1 vote
0 answers
65 views

I have a bit of trouble figuring out of how to test import book route of my controller in PHPUnit Testing. I'm Using MaatWebsite Package for the excel. So, I have real excel file in test/Files/...
Kholid Syaifullah's user avatar
0 votes
1 answer
41 views

I want to test MarkAsRead function via routing, my route was Route::post('notifications/{id}', [NotificationController::class, 'markAsRead']); and it was in API routing of auth:sanctum api route Route:...
TheBetweener's user avatar
3 votes
1 answer
147 views

I have API for books that I want to test using phpunit, but the structure of nested json somehow make index and show test function making one of them fail. If I wrote this code for both index and show ...
TheBetweener's user avatar
2 votes
2 answers
61 views

I have a piece of code that does the following: Create a database row (spatie media library) Create a job that adds something to column A and saves the object (also spatie media library) Adds ...
Veda's user avatar
  • 2,113
0 votes
1 answer
54 views

PHPUnit test suites not showing in Test Explorer, despite correct configuration in VS-Code it looks like this: TESTING [Filters fiel] 6/6 (6 from 6 succesful) └─ {} SL5 └─ PregContentFinder └─ {} ...
SL5net's user avatar
  • 2,630
0 votes
2 answers
63 views

I am setting up a golden master test case, yet the result may be off at certain points due to side-effects changing some strings at known places. Getting rid of those side-effects would be best, yet ...
k0pernikus's user avatar
  • 67.6k
1 vote
0 answers
154 views

I'm trying to run tests on my Laravel application. here is my phpunit config: <php> <env name="APP_ENV" value="testing"/> <env name="...
Mehrab's user avatar
  • 11
0 votes
1 answer
69 views

I'm implementing the server API (for geni.com) in PHP. The server requires OAuth authentication, so I need a browser because this requires user input (to permit access to their account). THIS all ...
Shmuel A. Kam's user avatar
1 vote
2 answers
197 views

I'm trying to use PHPUnit 12 dataProviders to provide data to a function to test but I can't get it working. Here's my unit test (that lives at tests/TestTest.php): <?php declare(strict_types=1); ...
neubert's user avatar
  • 17k
1 vote
1 answer
59 views

I have a simple test where I mock a dependency of the code under test: <?php use PHPUnit\Framework\TestCase; class Dependency { public function someFunction(int $first, int $second): int { ...
Robert's user avatar
  • 9,056
0 votes
1 answer
39 views

PHPUnit version : 11.5.6 Given a class Foo with bar method with variadic params: class Foo { public function bar(int ...$params): void {} } I mock a Foo instance in a test and want to assert bar ...
ERO's user avatar
  • 55
2 votes
1 answer
63 views

The method function at() has been removed from phpunit 10 later. I changed from at() to once() but my tests still don't pass The test fails because you cannot order the condition() calls. php code: ......
bindi_m's user avatar
  • 150
1 vote
1 answer
140 views

I'm writing tests with phpunit to test some chained jobs are dispatched. I know how to use Bus::assertChained() to verify that the expected jobs are chained. What I'm struggling with is testing the ...
Dan Breakwell's user avatar
1 vote
0 answers
49 views

I'm developing a Wordpress plugin and wanted to use a test-driven approach so I installed PHPUnit and the WP CLI tool. I did wp scaffold plugin-tests my-plugin and it generated the scaffolding files ...
Phl3tch's user avatar
  • 155
2 votes
1 answer
198 views

this is my first post so don't hesitate to tell me if something is wrongly said. I'm working on a projet in Symfony 7.*. I try to implement unit test in my project but I'm facing some issues. I use ...
Dev Th's user avatar
  • 29
-1 votes
1 answer
44 views

Problem While running tests using PHPUnit and Orchestra Testbench, I encountered the following error: ErrorException: Undefined variable $original at /vendor/laravel/framework/src/Illuminate/Database/...
sergio0983's user avatar
  • 1,298
2 votes
2 answers
210 views

I am running phpUnit tests using Laravel Framework Version 9.52.20. The tests work just fine in my local environment and in my CI/CD pipeline. But when I try to run the same tests in my dev ...
hanmari's user avatar
  • 1,504
0 votes
1 answer
29 views

I installed phpunit on my laptop and all works fine, but on installation on my PC, when I type phpunit . or phpunit xyzTest.php I get: PHPUnit 12.0.8` by Sebastian Bergmann and contributors. Test ...
Aldo Cauchi Savona's user avatar
0 votes
1 answer
89 views

I have a Trait called HasDefault its main purpose is to ensure that the class has a static field $default which is callable and returns the default instance of the class using the Trait This is what ...
LordF's user avatar
  • 536
1 vote
1 answer
67 views

I'm trying to write tests to assert that methods called in my AppServiceProvider boot method are present & enforced logic. So far I'm using mocks & reflection, however I am having an issue ...
Cam's user avatar
  • 71
0 votes
0 answers
45 views

I am attempting to make a custom upgrade of a project which is based on an old version of Laravel. Part of this upgrade will be updating it to the current version of Laravel. This project has no unit ...
Sam Coppock's user avatar
1 vote
2 answers
63 views

I know I can use dataProvider like so: use PHPUnit\Framework\TestCase; class DataProviderSetupTest extends TestCase { /** * @dataProvider basicDataProvider */ public function ...
k0pernikus's user avatar
  • 67.6k
0 votes
0 answers
26 views

I TRIED the answer suggested in the question this is a "duplicate" of (I didn't get the printer error). The solution there (to downgrade) did NOT work for ME. I mentioned trying it. I'm ...
Shmuel A. Kam's user avatar
0 votes
1 answer
83 views

I'm currently playing around with Laravel HTTP Feature Tests and I noticed when executing this code below: Test.php $this->actingUser($user) ->withHeaders([..]) ->post(uri: '/api/foo/bar', ...
afkka's user avatar
  • 3
0 votes
1 answer
33 views

I am writing tests that execute some of WordPress hooks / actions My hook example add_filter("asdasd", static function() { echo 'asdf'; }); It's complaining: This test executed code ...
Ruslan's user avatar
  • 86
0 votes
1 answer
71 views

I've been working on my tests for an hour and it works on my machine but when I try to put it in github actions, it stops and it can't create any files for mocking. I've no idea how to allow my action ...
Ugo Brocard's user avatar
1 vote
0 answers
71 views

Context I have a Laravel 9 (9.52.16) project (also tested on newer versions) with a custom api authentication flow. To make a request you need to receive an init_token first. This can be acquired by ...
Alex's user avatar
  • 11
0 votes
0 answers
187 views

After updating from Laravel 10 to 11, the --parallel tag does not work when testing. Testing normally still works. # php artisan test --parallel ParaTest v7.7.0 upon PHPUnit 11.5.2 by Sebastian ...
Judy Dick's user avatar
0 votes
2 answers
81 views

I am aware that one can add custom assertion by extending the default TestCase, e.g. I added assertions to check that an array may only contain one specific value: <?php namespace Kopernikus\...
k0pernikus's user avatar
  • 67.6k
0 votes
1 answer
156 views

Question: How to start symfony server within test env? The command takes no --env parameter and it does not recognize the option configured in .env.local. Prefixing the command with environment ...
rubberchicken's user avatar
2 votes
1 answer
214 views

ClockMock is a very useful tool for creating time sensitive tests e.g. if a date is in past A should happen, if it is in the future B should happen. ClockMock is a part of the phunit-bridge, which ...
Calamity Jane's user avatar
-1 votes
1 answer
168 views

I am trying to test Laravel API by using Laravel PHP unit test, I want to refresh and seeding of my test database once for all tests. what should i need to do in Testcase Laravel class for get this ...
shazim ali's user avatar
0 votes
2 answers
166 views

I'm trying to write a PHPUnit test using Mockery, and I keep running into issues when using the null coalescing operator (??) with mocked properties. Specifically, ?? seems to always return null, ...
Waqleh's user avatar
  • 10.2k
1 vote
1 answer
119 views

Stack versions: ApiPlatform 3.2 Symfony 6.4 PhpUnit 9.5 PHP 8.0 Writing a test for the DELETE endpoint of the User resource. When the endpoint is called, the user must be soft deleted and several ...
fombo's user avatar
  • 95
1 vote
4 answers
313 views

I've got a Dockerized Laravel app, here's the docker compose file: version: "3.9" services: app: build: context: ./ dockerfile: Dockerfile image: dmc container_name:...
MrCujo's user avatar
  • 1,393
0 votes
1 answer
60 views

The route defined in web.php is Route::get('about-us', [PageController::class, 'renderAboutUsPage'])->name('pages.about-us'); In my controller, I have methods class PageController extends ...
Nishant's user avatar
  • 167
0 votes
1 answer
98 views

I am developing a modular project in Laravel 11, where each module defines its routes inside itself. The routes are working perfectly in the browser and Postman, but when testing the same routes using ...
Mehran Magic's user avatar
0 votes
1 answer
84 views

I am trying to add a new Command to a set of existing Commands around an existing Model. The other tests for the other Commands around this all work just fine as expected. However, this new test + ...
Peter DeMarco's user avatar
1 vote
1 answer
110 views

Considering that there are 2 cases which would have the same result, is there an annotation or anything I can add to make sure that my test covers a specific line in a function? Given that code, I ...
RDelorier's user avatar
  • 787
0 votes
0 answers
71 views

We are working on a legacy php solution developed in Symfony. The solution consist of around 1000 actions. We have now introduced a test automation team to automate the testing using Selenium. But we ...
Nandakumar V's user avatar
  • 4,725
1 vote
0 answers
29 views

I am new to php and experimenting with unit_testing and wp_mock. I have an issue which I am unable to resolve. Please could somebody point me in the right direction. I have a basic class Plugin, ...
Phil Davies's user avatar

1
2 3 4 5
202