public function makeAScreenshot(CodeGuy $I) { $I->wantTo('save screenshot'); $I->haveStub($selenium = Stub::makeEmpty('\\Codeception\\Module\\Selenium')); $I->haveFakeClass($stub = Stub::make($this->class, array('test' => Stub::makeEmpty('\\Codeception\\TestCase\\Cept', array('getFileName' => function () { return 'testtest'; })), 'module' => $selenium))); $I->executeTestedMethodOn($stub); $I->seeMethodInvoked($selenium, '_saveScreenshot'); $I->seeMethodNotInvoked($stub, 'debug'); }
function testMocks() { $I = new CodeGuy($this->scenario); $I->testMethod('UserService.create'); $I->haveFakeClass($user = Stub::makeEmpty('UserModel')); $service = new UserService($user); $I->executeTestedMethodOn($service, 'davert'); $I->seeMethodInvoked($user, 'save'); $I->seeMethodInvokedOnce($user, 'save'); $I->seeMethodInvokedMultipleTimes($user, 'set', 2); $I->seeMethodNotInvoked($user, 'get'); $this->runSteps(); }