1. Go to this page and download the library: Download robvanaarle/php-object-seam library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?phprequire_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
robvanaarle / php-object-seam example snippets
classFooTest{
usePHPObjectSeam\CreatesObjectSeams;
publicfunctiontestBar(): void{
$foo = $this->createObjectSeam(Foo::class);
// $foo has type Foo&PHPObjectSeam\ObjectSeam// Access seam through seam() to alter the behaviour of the object
$foo->seam()
->override('connect', fn ($username, $password) => 'dummy_token')
->customConstruct(function($arg1){
$this->url = 'http://www.dummy.url/' . $arg1;
}, 'api/v1/');
// do something with $foo and perform an assertion
}
}
// i.e. in the setup of your test$this->foo = $this->createObjectSeam(Foo::class);
$this->foo->seam()->setCustomConstructor(function($arg1){
$this->url = 'http://www.dummy.url/' . $arg1;
});
// in a specific test case$this->foo->callCustomConstructor('api/v1/');
$foo = $this->createObjectSeam(Foo::class);
$foo->seam()->captureCalls('publicOrProtectedMethod');
// do something with $foo
$foo->publicMethod();
$calls = $foo->seam()->getCapturedCalls('publicOrProtectedMethod');
// assert that $calls contains a certain combination of arguments.
$foo = $this->createObjectSeam(Foo::class);
$foo->seam()->captureStaticCalls('publicOrProtectedStaticMethod');
// do something with $foo
$foo::publicMethod();
$calls = $foo->seam()->getCapturedStaticCalls('publicOrProtectedMethod');
// assert that $calls contains a certain combination of arguments.
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.