1. Go to this page and download the library: Download badoo/soft-mocks 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/ */
badoo / soft-mocks example snippets
class A {const NAME = 'A';}
class B {}
echo A::NAME . "\n"; // A
echo B::NAME . "\n"; // A
\Badoo\SoftMocks::redefineConstant(A::class . '::NAME', 'B');
echo A::NAME . "\n"; // B
echo B::NAME . "\n"; // B
class A {const NAME = 'A';}
class B {}
class C {}
echo A::NAME . "\n"; // A
echo B::NAME . "\n"; // A
echo C::NAME . "\n"; // A
\Badoo\SoftMocks::redefineConstant(B::class . '::NAME', 'B');
echo A::NAME . "\n"; // A
echo B::NAME . "\n"; // B
echo C::NAME . "\n"; // B
class A {const NAME = 'A';}
class B {}
echo A::NAME . "\n"; // Undefined class constant 'NAME'
echo B::NAME . "\n"; // Undefined class constant 'NAME'
\Badoo\SoftMocks::redefineConstant(A::class . '::NAME', 'A');
echo A::NAME . "\n"; // A
echo B::NAME . "\n"; // A
class A {const NAME = 'A';}
class B {const NAME = 'B';}
class C {}
echo A::NAME . "\n"; // A
echo B::NAME . "\n"; // B
echo C::NAME . "\n"; // B
\Badoo\SoftMocks::removeConstant(B::class . '::NAME');
echo A::NAME . "\n"; // A
echo B::NAME . "\n"; // A
echo C::NAME . "\n"; // A