1. Go to this page and download the library: Download facile-it/moka 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/ */
facile-it / moka example snippets
namespace Foo\Tests;
use Moka\Moka;
use function Moka\Plugin\PHPUnit\moka;
class FooTest extends \AnyTestCase
{
private $foo;
protected function setUp(): void
{
Moka::clean();
// The subject of the test.
$this->foo = new Foo(
moka(BarInterface::class)->stub([
// Property name => value.
'$property' => 3,
// Method name => return value.
'method1' => moka(AcmeInterface::class),
'method2' => true
])
);
}
//...
}
namespace Foo\Tests;
use Moka\Traits\MokaCleanerTrait;
use PHPUnit\Framework\TestCase;
use function Moka\Plugin\PHPUnit\moka;
class FooTest extends TestCase
{
use MokaCleanerTrait;
protected function setUp(): void
{
// No call to Moka::clean() needed.
// ...
}
// ...
}
namespace Moka\Plugin\YourOwn;
use Moka\Plugin\PluginInterface;
use Moka\Strategy\MockingStrategyInterface;
class YourOwnPlugin implements PluginInterface
{
public static function getStrategy(): MockingStrategyInterface
{
return new YourOwnMockingStrategy();
}
}
namespace Moka\Plugin\YourOwn;
use Moka\Strategy\AbstractMockingStrategy;
use Moka\Stub\MethodStub;
class YourOwnMockingStrategy extends AbstractMockingStrategy
{
public function __construct()
{
// TODO: Implement __construct() method.
}
protected function doBuild(string $fqcn)
{
// TODO: Implement doBuild() method.
}
protected function doDecorateWithMethod($mock, MethodStub $stub)
{
// TODO: Implement doDecorateWithMethod() method.
}
protected function doGet($mock)
{
// TODO: Implement doGet() method.
}
protected function doCall($mock, string $methodName)
{
// Override doCall() if you need special behavior.
// See ProphecyMockingStrategy::doCall().
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.