Skip to content
Advertisement

Tag: unit-testing

PHPUnit Stalling in CI

We’re having an issue with PHPUnit sometimes failing to correctly run our test suite in CI. The behaviour manifests as roughly 1/3 tests failing to start and the CI step timing out. Interestingly enough, we don’t see this behaviour: Locally on our machines Every time we run the tests Occur with the dusk tests Our setup is to run the

WP_Ajax_UnitTestCase does not throw WPAjaxDieStopException

Ok so I am testing my ajax callbacks for my wordpress plugin. So I basically followed instructions here https://codesymphony.co/wp-ajax-plugin-unit-testing/ Here is my ajax callback function Here is my test Now here are the issues It doesn’t throw WPAjaxDieStopException exception like its suppose to when I do this code $this->setExpectedException( ‘WPAjaxDieStopException’ ); it fails the test https://snag.gy/JSTqHV.jpg It prints out that

PHP Mocking Final Class

I am attempting to mock a php final class but since it is declared final I keep receiving this error: PHPUnit_Framework_Exception: Class “DoctrineORMQuery” is declared “final” and cannot be mocked. Is there anyway to get around this final behavior just for my unit tests without introducing any new frameworks? Answer Since you mentioned you don’t want to use any other

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():

Advertisement