mockery Questions
2
Solved
Within a unit test method, I tried to mock a Cache::remember response like this:
Cache::shouldReceive('remember')
->once()
->with('my_key', 120, function() {}) // There are 3 args in remem...
Thoroughwort asked 30/12, 2015 at 10:10
1
Solved
I'm learning phpunit since week. I don't have idea how to mock only one method from tested class. (it's example only so I didn't write namespaces). Maybe you can help me
class SomeService
{
publi...
Whoops asked 12/12, 2017 at 11:23
1
Solved
I would like to mock Config::get('specific_key') to return a 'specific_value' in my test. So I wrote the following code:
Config::shouldReceive('get')
->with('specific_key')
->andReturn('sp...
1
Solved
I saw in the Laravel docs that it's possible to set a test expectation like this:
Cache::shouldReceive('get')
->once()
->with('key')
->andReturn('value');
Then I saw in the PHPunit d...
1
Solved
According to the Laravel Documentation, I can use Queue::fake(); prevent jobs from being queued.
What is not clear how to test (PHPUnit) a few methods in the Job Class while it is not being queued...
Mortification asked 30/9, 2017 at 13:54
2
I'm implementing unit tests into my Laravel 4 application but I'm stuck on mocking accessor attributes.
I have an Eloquent model that has an Accessor attribute in it. I'm trying to mock this mode...
6
I'm having trouble unit testing a class that has a method called within the constructor. I don't understand how to mock this. Perhaps I should use the 'setUp' method of phpUnit?
I'm using the Mock...
Burkes asked 15/4, 2014 at 8:55
2
Solved
I am trying to set up the simplest of tests in my controller but, as with most things Laravel, there are no decent tutorials to demonstrate the simple stuff.
I can run a simple test (in a file cal...
Declarant asked 8/9, 2014 at 12:33
2
Is it possible to mock a protected property with PHP Mockery?
I got a class with a method, I will call it `a, that does some magic on an array that is retrieved from a protected property from the ...
2
I have run into a problem when mocking Interfaces using Mockery in PHP (im using the laravel framework but I'm not sure this is relevant.
I have defined an interface
<?php namespace MyNamespa...
1
Solved
having this code
<?php
public function trueOrFalse($handler) {
if (method_exists($handler, 'isTrueOrFalse')) {
$result= $handler::isTrueOrFalse;
return $result;
} else {
return FALSE;
}
}...
Ker asked 20/6, 2016 at 16:16
1
I'm a novice developer trying to get a test suite started for an existing laravel app but I have not experience in testing. Right now I'm just trying to get some tests built out to get some confide...
1
I have in my code a line like this:
ModelName::create($data);
where ModelName is just an Eloquent model. Is there a way to mock this call inside a unit test? I tried with:
$client_mock = \Mocke...
Sixtynine asked 26/5, 2016 at 9:15
1
Solved
Can you tell me where's the problem? I have a file GeneratorTest.php with the following tests:
<?php
namespace stats\Test;
use stats\jway\File;
use stats\jway\Generator;
class GeneratorTest ...
Bonus asked 20/5, 2016 at 14:12
1
Solved
I am trying to wrap my head around Unit testing with PhpUnit / Mockery / Laravel.
It's not coming easy. I've been reading dozens of tutorials and still can't apply it in real life scenarios.
I wil...
Produce asked 12/4, 2016 at 13:56
1
I want to mock a static method which has been used in another method using Mokcery,Just as follows:
Class SomeClass
{
public static function methodA()
{
.....;
self::B();
}
public static fu...
1
I'm trying to use Mockery to create a mock object that mimics PHP's internal ZipArchive class.
I have something like the following PHP code:
$zipMock = Mockery::mock('ZipArchive');
$zipMock->n...
Nicki asked 1/6, 2015 at 9:17
3
Solved
I am learning unit testing in laravel using phpunit and mockery. I am currently trying to test UsersController::store().
I am mocking User Model and using it to test the index method and that see...
1
Solved
I want use Mockery and change this:
$mockFoo = $this->getMockBuilder('Foo')
->disableOriginalConstructor()
->getMock();
to this:
$mockFoo = m::mock('Foo');
But I don't know how dis...
Nipper asked 12/11, 2015 at 13:9
2
Solved
I have weird problem with Laravel 5 and PHPUnit. When I try to mock Laravel's facades (e.g. Auth, View, Mail) I always get this exception:
Mockery\Exception\InvalidCountException: Method send(&quo...
Fruitage asked 11/10, 2015 at 21:39
2
How can I use mockery and hamcrest to assert that when a method of a mock object is called, one of the arguments passed to it is an array containing a key/value pair?
For example, my test code mig...
Reactivate asked 19/8, 2015 at 13:47
2
Solved
i'm trying to test a simple class. I'm following this tutorial( http://code.tutsplus.com/tutorials/testing-laravel-controllers--net-31456 ).
I have this error, while running tests:
Method Mockery...
Nez asked 2/1, 2015 at 18:46
2
I'm running phpunit with mockery (without DB/fixtures), but I have a trouble with mocking a model.
$customer = Mockery::mock(CustomerModel::class);
echo $customer->id;
Produces error:
BadMet...
Pitsaw asked 3/7, 2015 at 11:28
1
Solved
Most of the answers I have seen on StackOverflow are without using the DateTime object, and are instead using the date() function. This makes them very dirty solutions (overriding date(), mocking a...
Undis asked 9/5, 2015 at 6:52
1
Solved
I'm starting with TDD and Laravel. Specifically, I'm starting with routes. I defined some and I defined it badly, so excited as I was with the "new" concept of TDD I wanted to write some test for t...
Brinn asked 2/4, 2015 at 21:4
© 2022 - 2024 — McMap. All rights reserved.