public function generateFilename(CodeGuy $I) { $I->haveFakeClass($stub = Stub::make($this->class, array('test' => Stub::makeEmpty('\\Codeception\\TestCase\\Cept', array('getFileName' => function () { return 'testtest'; }))))); $I->executeTestedMethod($stub); $I->seeResultEquals(\Codeception\Configuration::logDir() . 'debug' . DIRECTORY_SEPARATOR . 'testtest - 1'); $I->executeTestedMethod($stub, 'mytest'); $I->seeResultEquals(\Codeception\Configuration::logDir() . 'debug' . DIRECTORY_SEPARATOR . 'testtest - 2 - mytest'); }
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(); }
public function shouldUseCest(CodeGuy $I) { $I->haveFakeClass($scenario = \Codeception\Util\Stub::makeEmptyExcept('Codeception\\Scenario', 'comment')); $I->executeMethod($scenario, 'comment', 'cool, that works!'); $I->seeMethodInvoked($scenario, 'addStep'); }