PHP code example of granam / test-with-mockery
1. Go to this page and download the library: Download granam/test-with-mockery 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/ */
granam / test-with-mockery example snippets
class MyTest extends \Granam\Tests\TestWithMockery {
public function testMyClass() {
$myClassMock = $this->mockery(Sos::class);
$myClassMock->expects('saveMe') // saveMe() no more exists and \Granam\Tests\Exceptions\MockingOfNonExistingMethod is thrown
->andReturn(true);
}
}
class Sos {
// renamed previous saveMe()
public function saveUs(): bool {
return false;
}
}