Questions tagged [php-pest]

Pest is a PHP Testing Framework with a focus on simplicity

Pest is a Testing Framework with a focus on simplicity. It was carefully crafted to bring the joy of testing to PHP.

Here is the official framework website

You can also view the framework documentation

13 questions
4
votes
2 answers

Argument #1 must be of type Model, Pest\Mock\Mock given

I'm trying to write some tests using Pest and mocking my model. I have a Repository that accepts two models, this is the definition: class MyRepo { public function __construct(private ModelA $modelA, private ModelB $modelB) { // …
Mistre83
  • 2,677
  • 6
  • 40
  • 77
3
votes
0 answers

Pestphp Error : Call to undefined function mock()

File Pest.php in('Feature', 'Unit'); File Unit/Repositories/PersonalDataRepository File…
2
votes
0 answers

PHP Pest (with Laravel) tests running very slow in OSX Docker

I was developing an app locally using Laravel. For testing I was using Pest and tests were running fast, really fast. That was until I decided to Dockerize my app, now tests are running pretty slow. What it used to run in 3 seconds now it's running…
MrCujo
  • 1,218
  • 3
  • 31
  • 56
2
votes
2 answers

Laravel remembers original response during http tests

Given the following pest test: it('allows admins to create courses', function () { $admin = User::factory()->admin()->create(); actingAs($admin); $this->get('/courses')->assertDontSee('WebTechnologies'); …
Jazerix
  • 4,729
  • 10
  • 39
  • 71
1
vote
1 answer

How may I test in CakePHP with Pest

My problem: How my I test some MVC part with Pest in CakePHP, for example: When I´m use PHPUnit, I´ll type: public class ItemTest extends TestCase And it will show what thing that I wanna test, but how do that with Pest? (Obs.: I´m really new on…
1
vote
0 answers

Pest PHP / PHPUnit : run test with role

I'm using Pest PHP (with Laravel) and i'm trying to run test with a given role but i already have 403 status (Forbidden). I'm using spatie/laravel-permission to manage roles. This is my route : Route::get('liste',…
julian
  • 95
  • 8
0
votes
2 answers

How can I run a specific example using PEST (PHP)

Now I use ./vendor/bin/pest as explained in the docs. But that makes me run all tests. What if I only want to run one specific example? Do I need to use groups or can it be done in an easier way?
Brainmaniac
  • 2,203
  • 4
  • 29
  • 53
0
votes
0 answers

Difference assertions and expectations in PEST (PHP)

I am starting to use PEST in my Laravel-project. I started to read the documentation and saw that both assert and expect exists but I see no real explanation on their difference. Can someone please tell me the difference and when to use what?
Brainmaniac
  • 2,203
  • 4
  • 29
  • 53
0
votes
1 answer

Pestphp fails to run tests

I just installed the version 1.21 of pestphp/pest for a small php library. Installations works until I try running ./vendor/bin/pest I keep getting this error: Exclusive locks are not supported for this stream Research on this error has proven…
Willower
  • 1,099
  • 8
  • 22
0
votes
1 answer

Laravel factories slowing down testing due to nested relationships

For context, I'm working on a RNG-based motorsport simulator, for lack of a better term. Users can create universes (think FIA in real life terms), in a universe they can create series (think F1, F2, F3 etc) and in each series they can create…
Alex
  • 778
  • 3
  • 12
  • 27
0
votes
0 answers

Laravel - Mock function in model

In my application, I have a service that uses a function related to a model. This function has already been tested (on its Unit Test), and in my Feature test, I just need to "use" its output value. Because this function is "complicated", I would…
Mistre83
  • 2,677
  • 6
  • 40
  • 77
0
votes
1 answer

Laravel mock multiple dependency

I have a Controller that has a dependency with BillingService, and BillingService has another dependency on UserService. I need to call the Controller method getPlans and in this call I need to mock two functions: loadPlans that is inside…
Mistre83
  • 2,677
  • 6
  • 40
  • 77
0
votes
2 answers

Pest: Sequential Tests in Laravel

I want to create a series of tests that can run sequentially, the idea is that if the test before the one running does not pass, then all the suite shall not pass. It sounds as anti pattern, but I need to test that user flow. I tried with datasets…