mockery Questions
2
Solved
I need to test how some code I wrote will behave when it calls a method on another class multiple times, where one of the calls will cause an exception to be thrown.
I am using Mockery to mock the...
Cymbal asked 17/6, 2018 at 22:5
6
Solved
I have an application that makes use of socialite, I want to create test for Github authentication, So I used Socialite Facade to mock call to the Socialite driver method, but when I run my test it...
3
Solved
I am using laravel 5 with php unit to create a laravel package. I have a Repository..
namespace Myname\Myapp\Repositories;
use Myname\Myapp\Models\PersonModel;
class PersonRepository
{
protecte...
4
I have a class that uses Str::random() which I would like to test.
But when I use Str::shouldReceive('random') in my test, I get a BadMethodCallException saying the method shouldReceive does not e...
Specialistic asked 28/6, 2014 at 21:39
5
Solved
I'm trying to properly mock a chained call to an Eloquent model in a controller. In my controller I'm using dependancy injection to access the model so that it should be easy to mock, however I'm n...
3
I need to test, that the code creates a new instance of a class with certain parameters:
$bar = new ProgressBar($output, $size);
I tried to create an alias mock and set an expectation for the __...
Undershoot asked 1/6, 2015 at 13:42
2
Solved
I'm writing my unit tests and by default they should not hit the database.
by general rule I always use eloquent to get the results, but some more complex queries I have to use the raw DB
I have ...
Condemn asked 25/1, 2016 at 20:37
3
Solved
I am new to using Mockery and confused with the terminology alias and overload. Can anyone please explain to me when to use which?
9
I want to use a mock object (Mockery) in my PHPUnit test. The mock object needs to have both some public methods and some public properties set. The class is a Laravel Eloquent model. I tried this:...
3
Solved
I'm trying to get Mockery to assert that a given method is called at least once.
My test class is:
use \Mockery as m;
class MyTest extends \PHPUnit_Framework_TestCase
{
public function testSet...
2
Solved
Consider the example classes (apologies for it being so convoluted, but it's as slim as possible):
class RecordLookup
{
private $records = [
13 => 'foo',
42 => 'bar',
];
function __con...
2
Solved
I'm looking for a way to mock an object and populate its properties.
Here's an example of a method who uses a property of another object:
class MyClass {
private $_object;
public function meth...
Bozovich asked 15/6, 2017 at 15:7
4
Solved
I have the following code in one of my routes:
return Response::download('cv.pdf');
Any idea how to test this? I've tried to use shouldReceive() but that doesn't seem to work ('shouldReceive() un...
Millepore asked 13/1, 2014 at 12:19
1
This should be incredibly simple but it is driving me mad this afternoon, what is the correct way to unit test a custom symfony validator? All the articles I can find have exactly the same way as I...
Rusert asked 18/8, 2020 at 16:55
1
Solved
So I'm making unit test in golang using mockery and testify
The test code goes like this:
const bufSize = 1024 * 1024
var lis *bufconn.Listener
var mockAccountService = &mocks.AccountService{...
Antabuse asked 2/7, 2020 at 11:52
2
Solved
I'm using PHPUnit 6.5.13 and Laravel 5.5 on PHP 7.4. I recently upgraded from PHP 7.2 to 7.4. and it seems like that triggered the error.
In my test I use $this->expectsEvents in order to test...
2
Solved
I can't figure out why I'm getting this error during this test. My test appears to be matching the rest of the code exactly. What am I overlooking?
In my test I have:
$passwordBroker = m::mock('...
2
Solved
I've been successfully using Mockery with PHPUnit tests lately. Yet, there is a dependency in a project I'm currently working that uses static method calls to interact with an API. I'm struggling t...
1
Solved
I have this Service class and use repository class in my Service :
class VisitorStatisticAction
{
protected $repository;
public function __construct(VisitorStatisticRepository $repository)
{
...
Longdrawnout asked 12/3, 2019 at 8:29
2
Solved
TLDR;
How do I get value1 first time and value2 the second time when calling the mockery shouldReceive('method)` with same parameter?
Lets say I have an $order object that implements this signatur...
1
Trying to write a test for laravel php artisan command with ask() function. I have never used mockery before, but when i try to run test, it freezes, so i guess, i'm doing something wrong.
MyComman...
1
Solved
I have appplication which responsible to fetch various api's to collect data. I'm using Codeception As my testing framework and I need to mock API client class in my functional tests like this:
p...
Lei asked 5/11, 2018 at 19:24
1
In my application code, I've got a method_exists check to authorize some hooking in a create process:
// Note: $myClass is implementing a ListItemFactory interface.
if ($isCreate) {
$methodName ...
Thumbscrew asked 22/11, 2015 at 15:3
1
Solved
I have situation like this. I have some 3rd party trait (I don't want to test) and I have my trait that uses this trait and in some case runs 3rd party trait method (in below example I always run i...
Vietcong asked 4/8, 2018 at 8:45
3
Solved
Is there a way to test Mail in Laravel 5? tried the only legit Mock example I see on the internet but it seems it only works on Laravel 4. current code below.
$mock = Mockery::mock('Swift_Mailer...
Burthen asked 29/6, 2015 at 16:12
1 Next >
© 2022 - 2024 — McMap. All rights reserved.