예제 #1
0
 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');
 }
예제 #2
0
 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();
 }
예제 #3
0
 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');
 }