PHP code example of ondrejmirtes / mocktainer
1. Go to this page and download the library: Download ondrejmirtes/mocktainer 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/ */
ondrejmirtes / mocktainer example snippets
$foo1 = $this->getMockBuilder(Foo1::class)
->disableOriginalConstructor()
->getMock();
$foo2 = $this->getMockBuilder(Foo2::class)
->disableOriginalConstructor()
->getMock();
$foo3 = $this->getMockBuilder(Foo3::class)
->disableOriginalConstructor()
->getMock();
$foo4 = $this->getMockBuilder(Foo4::class)
->disableOriginalConstructor()
->getMock();
$interestingDependency = $this->getMock(Foo5::class);
$interestingDependency->expects($this->once())
->method('getAwesome')
->getMock();
// public function __construct(Foo1 $foo1, Foo2 $foo2, Foo3 $foo3, Foo4 $foo4, Foo5 $foo5)
$bar = new Bar($foo1, $foo2, $foo3, $foo4, $interestingDependency);
$interestingDependency = $this->getMock(Foo5::class);
$interestingDependency->expects($this->once())
->method('getAwesome')
->getMock();
$bar = $this->getMocktainer()->create(Bar::class, ['foo5' => $interestingDependency]);