Skip to content
Advertisement

Tag: phpunit

Mocking classes that created with app()->make

I have this code in my __construrct: Now, when i’m unit testing i know that i can mock Guard and pass it’s mock to $auth, but how can i mock dbUserService ? it’s instantiated trough the IoC container. Answer You can use the instance() method of the IoC container to mock any class instanciated with make():

Laravel – Testing what happens after a redirect

I have a controller that after submitting a email, performs a redirect to the home, like this: I am writing the tests for it, and I am not sure how to make phpunit to follow the redirect, to test the success message: If I substitute the code on the controller for this, and I remove the first 2 asserts, it

Run test in phpunit with specific php version

I have installed multiple PHP versions on my Mac and want to run unit-tests against a specific PHP version (or against multipls versions) Here’s the php versions I have: My test case looks like this: When I run the test I get this response: How can I run the tests with the php version 5.2.17? Update: I discover that PHPUnit

Fatal Error – Too many open files

I try to run PHPUnit Tests in my new machine and I get this error: PHP Fatal error: Uncaught exception ‘UnexpectedValueException’ with message ‘RecursiveDirectoryIterator::__construct(/usr/lib/php/pear/File/Iterator): failed to open dir: Too many open files’ in /usr/lib/php/pear/File/Iterator/Factory.php:114 The same code on the old machine run well… New machine environment: PHP Version: PHP 5.3.21 (cli) Older: PHP 5.3.14 PHPUnit output every time: Answer This

How to output in CLI during execution of PHP Unit tests?

When running a PHPUnit test, I would like to be able to dump output so I can debug one or two things. I have tried the following (similar to the PHPUnit Manual example); With the following result: Notice there is none of the expected output. I’m using the HEAD versions of the git repos as of September 19th, 2011. Output

PHPUnit: expects method meaning

When I create a new mock I need to call the expects method. What exactly it does? What about its arguments? I can’t find the reason anywhere (I’ve tried docs). I’ve read the sources but I can’t understand it. Answer expects() – Sets how many times you expect a method to be called: If you know, that method is called

Advertisement