PHP code example of qratorlabs / smocky
1. Go to this page and download the library: Download qratorlabs/smocky 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/ */
qratorlabs / smocky example snippets
class Base
{
public static function methodName()
{
return 'something';
}
}
class Child extends Base
{
}
// simulating PHPUnit test case
(new class('test') extends \PHPUnit\Framework\TestCase {
public function test(): void
{
// child should instanced (or loaded any other way)
$child = new Child();
// mocking method of base class
$method = new MockedClassMethod(Base::class, 'methodName');
// at least one call should be made
Base::methodName();
}
})->run();