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

I'm using Laravel 12 along with Pest (using Mockery), and I have this method : public function destroy(array $ids): array { $data= Item::findAllByFieldIn('id', $ids)->get(); // ...
naspy971's user avatar
  • 1,411
1 vote
1 answer
74 views

I have two classes, Foo and Bar: class Foo { private Bar $bar; public function __construct(Bar $bar) { $this->bar = $bar; } public function foo() { return $...
Enno's user avatar
  • 1,931
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
73 views

For example I have classes: class ServiceOne{ public function testOne($name){ app(ServiceTwo::class, ['name' => $name])->testTwo(); } } class ServiceTwo{ __construct(private string $...
fico7489's user avatar
  • 8,650
0 votes
1 answer
96 views

I am trying to test a factory that it returns the correct instance. But ApiAuthRequest class has to implement a specific interface in order for the test to succeed. How I can do it? I have tried to ...
csandreas1's user avatar
  • 2,420
0 votes
1 answer
46 views

I'm writing a unit test to filter out invalid relations from a model. The goal is to only keep relations that actually exist in the model. However, my test is failing because the filtered relations ...
csandreas1's user avatar
  • 2,420
0 votes
1 answer
65 views

I am mocking the laravel request object and I need to modify the mocked object name from Mockery_3_API_V2_Custom_Requests_DestroyRequest to DestroyRequest. How is it possible? protected function ...
csandreas1's user avatar
  • 2,420
2 votes
1 answer
345 views

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
261 views

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
0 answers
86 views

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
  • 792
-1 votes
2 answers
78 views

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
1 vote
1 answer
102 views

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
  • 149
0 votes
1 answer
71 views

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
2 votes
0 answers
570 views

I have a Livewire component where i instantiate a new class called new Connector(). I want to mock this Connector with Mockery. As i understand, if you want to mock hard dependencies you can use '...
jadsghx's user avatar
  • 23
0 votes
1 answer
87 views

I am not able to mock a public method 'substract' of a class who is called internally inside another method 'remove' (This is an example code but with same issue). public class Inventory { public ...
albaokilml's user avatar
2 votes
0 answers
141 views

In my API I am getting the checkout url from Stripe using Laravel 11 Cashier 15 and returning it to the front end to redirect the user. $response = $user->newSubscription($name, $price) ->...
whoacowboy's user avatar
  • 7,507
1 vote
1 answer
109 views

Sorry for the messy title, I am trying to add Unit Tests to my (probably) smelly codebase. I have the something like the following class: namespace App\Service; use App\Messages\ItemMessage; use App\...
Fliwatt's user avatar
  • 19
0 votes
0 answers
116 views

I have the following table-driven test in go: func Test_funcTest(t *testing.T) { mockStr := "str" type args struct { arg1 String ...
Mihika's user avatar
  • 555
1 vote
0 answers
532 views

I'm encountering an error in my Symfony application related to accessing the $container property of Symfony\Bundle\FrameworkBundle\Controller\AbstractController. The error message I'm receiving is: ...
Kaveh Mohammadi's user avatar
1 vote
1 answer
80 views

I am using Laravel 9 together with mockery/mockery version 1.6.6 I have some strange behavior when I mock an Eloquent model. The eloquent Model has a __get() method defined as : public function ...
Adam's user avatar
  • 29.6k
2 votes
1 answer
298 views

I have a command and some methods related to Redis connection are running in it. I want to test some of these methods and for this I want to mock the Redis connection. I approached it like this: ...
cengsemihsahin's user avatar
0 votes
1 answer
185 views

🗺️ My Environment PHP 7.4 WordPress 6.2 WP_Mock 1.0 PHPUnit 9.6.11 Mockery 1.6.6 🖥️ Code: TestCase use PHPUnit\Framework\TestCase; use WP_Mock; use Mockery; class WPAB_Database_Service_Test extends ...
Adrien Villalonga's user avatar
1 vote
0 answers
38 views

I attempted to mock the StripeClient class in Laravel using Mockery and the app() helper. While I managed to mock the balance->retrieve method and simulate responses successfully, I encountered ...
Gaurav Deshpande's user avatar
0 votes
0 answers
100 views

User model class User extends Authenticatable { use HasApiTokens, HasFactory, Notifiable; const TYPE_MERCHANT = 'merchant'; const TYPE_AFFILIATE = 'affiliate'; /** * The ...
Wasim Rasheed's user avatar
3 votes
1 answer
374 views

I'm having some issues implementing interface substitution for the Go code. Previously the code was not written with unit tests in mind and I am going back and adding support for testing (Testify and ...
GregariousGainz's user avatar
1 vote
1 answer
210 views

I have a class called ModuleManifest with this constructor: /** * Create a new instance of the ModuleManifest class. * * @param string $vendor The vendor of the module. * @param string $package ...
madman2819's user avatar
0 votes
1 answer
1k views

I am a beginner in testing in laravel. I tried for the first time mocking today and i am a bit lost. English is not my native language too ^^: Does someone know how to solve my problem ? Thank you ! ...
Bubble Initiative's user avatar
0 votes
1 answer
443 views

This feels simple but the answer is eluding me behind internet pages and questions/answers, some of which I'm not confident enough to consider definitive. My requirement is simple. I have a PHP class ...
Program.X's user avatar
  • 7,412
1 vote
0 answers
65 views

In a Controller I have code that relies on the user id public function getMyStuff(Request $request) { $user = Auth::user(); var_dump($user->getId()); // Debug code, yields 'string(0) "...
Letharion's user avatar
  • 4,261
1 vote
1 answer
717 views

Working a Laravel project that uses PHPUnit\Framework\TestCase class to run unit tests. In order to create mocks it sometimes uses the built in PHPUnit Api. e.g. $this->mock = $this->...
Meyer Auslander - Tst's user avatar
1 vote
0 answers
86 views

I'm trying to write a test that checks if a user is redirected if the form is valid. In order to do this, I mock my form and make it return true when isValid is called. But I get the following errors: ...
Răzvan Birișan's user avatar
3 votes
2 answers
3k views

I am writing a unittest for a Laravel project. I would like to test the public method testMethod() in the following class. class Foo extends Model { public static function staticMethod($arg) { ...
anko's user avatar
  • 33
1 vote
0 answers
568 views

I am writing some tests that require me to use class aliased mocks. As a result, I need the app to revert back to the use of the class I am mocking once I am done with the mock (after running each of ...
Radu Raileanu's user avatar
1 vote
0 answers
360 views

I am trying to write tests for a Laravel application and I can't seem to figure out how to test static methods that call other static methods from the same class. Say I have this class: class Foo { ...
Radu Raileanu's user avatar
0 votes
1 answer
1k views

In working on a table-driven test where I'm using some mocks generated by mockery and set some method-call expectations that depend on the data provided in the data set for each test case. I'm facing ...
beni0888's user avatar
  • 1,264
0 votes
0 answers
135 views

I'm using Laravel, Pest for my tests and Mockery for mocking. I have a simple action that looks like so: public function handle(): array { $sites = []; $envDir = dirname(__FILE__, 3).'/env'; ...
LeonardChallis's user avatar
0 votes
0 answers
56 views

I have a very simple Laravel Component which sets a public property of $categories: public function __construct(Category $category) { $this->categories = $category->children; } What I would ...
Zakalwe's user avatar
  • 1,662
0 votes
1 answer
899 views

I am writing a test case to send a sms using twilio sdk in php in a laravel application. I created a mock of the Client class, and I expect that the client will receive the messages then create ...
naghal's user avatar
  • 726
0 votes
1 answer
224 views

Is extending Mockery for commonly used assertions possible? Asserting that a mocked function receives an instance of a class AND matching an identifier is cumbersome. Mockery::on( fn ($arg) => $...
Tyler Wall's user avatar
  • 3,798
2 votes
0 answers
564 views

I am trying to test a gRPC service locally. Here is the sample code type TestGrpcServer struct { t *testing.T Server *grpc.Server Lis *bufconn.Listener Conn *grpc.ClientConn }...
Sanath Manavarte's user avatar
0 votes
0 answers
165 views

i am not being able to mock cashier's defaultPaymentMethod method while testing. i have a controller named PaymentController and there is method called exec() as below: public function exec() { $...
Sau Rai's user avatar
-1 votes
1 answer
74 views

I have made a simple class named MyService namespace App\Services; class MyService { private $anotherService; public function setService(AnotherService $anotherService) { $this-&...
Dimitrios Desyllas's user avatar
0 votes
1 answer
896 views

I have a situation like the example classes below where I have a child class that overrides a parent method. In certain situations it will return the original result from the parent class. How do I go ...
Jimmyb_1991's user avatar
0 votes
0 answers
344 views

When running phpunit I get the following error: Mockery\Exception\BadMethodCallException: Method Mockery_0__Tests_Unit_App_Utils_Blueprints_BlueprintRuleUtil::executeActiveBlueprintRules() does not ...
Drew Gallagher's user avatar
1 vote
1 answer
339 views

I have a question regarding mockery in combination with Laravel. I have sucessfully created a mockery object to mock all the public static methods such as where and find on the elequent model instance....
vonBerg's user avatar
  • 154
1 vote
1 answer
601 views

I am trying to generate mocks in Golang using mockery, and the repo requires v0.0.0-dev. I ran brew install mockery but that only installs v2.15.0, and thus cannot generate mocks with v0.0.0-dev. How ...
alameda1232's user avatar
2 votes
1 answer
3k views

I have run into a problem when mocking Enums using Mockery + PHPUnit in PHP 8.1 (im using the laravel framework but I'm not sure this is relevant). I have defined an enum: <?php namespace ...
Arthur Tavares's user avatar
-1 votes
1 answer
571 views

Say i have this function. In this function i create a Mollie payment using the Mollie Laravel API Wrapper. The function $molliePayment needs to be mocked as i don't want to call the API during testing....
jadsghx's user avatar
  • 23
0 votes
1 answer
587 views

I'm trying to the the following piece of code: public function remember(string $key, \Closure $callback, int $ttl = null): mixed { return \Cache::remember($key, $ttl, $callback); } with: public ...
Majesty's user avatar
  • 2,089
0 votes
1 answer
362 views

I'm trying to implement a unit test in Laravel 5.7 I want to mock APP_ENV testing to production or any else as I want. Unit test code: App::shouldReceive('environment')->with('APP_ENV')->once()-&...
Dake's user avatar
  • 81

1
2 3 4 5
11