PHP code example of usox / hackmock
1. Go to this page and download the library: Download usox/hackmock library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
usox / hackmock example snippets
use function Usox\HackMock\{mock, prospect};
class SomethingTest extends \Usox\HackMock\HackMock {
public function testSomething() {
$my_fine_class = mock(SomeInterface::class);
prospect($my_fine_class, 'someMethodName')
->once()
->andReturn('some-fine-value');
prospect($my_fine_class, 'someOtherMethodName')
->andThrow(new \Exception('foobar'));
}
}