PHP code example of timesplinter / proxy-mock

1. Go to this page and download the library: Download timesplinter/proxy-mock 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/ */

    

timesplinter / proxy-mock example snippets


use My\Service;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;

final class ConsumeUserMessagesFromCoreTest extends KernelTestCase
{
    public function testSomething(): void
    {
        // Access the service over the public alias defined in "services_test.yaml"
        self::$container->set('my.service.test', $this->getMockBuilder(Service::class)->getMock());
    }
}

class Foo { ... }

$factory = new ProxyMockFactory();
$proxyMock = $factory->create(Foo::class);

// In a PHPUnit test case
$mock = $this->getMockBuilder(Foo::class)
    ->disableOriginalConstructor()
    ->getMock();

$proxyMock->setMock($mock);