예제 #1
0
 public function run(CodeGuy $I)
 {
     $I->wantTo('run steps from scenario');
     $I->haveStub($test = Stub::makeEmpty('\\Codeception\\TestCase\\Cept'));
     $I->haveStub($scenario = Stub::make('\\Codeception\\Scenario', array('test' => $test, 'steps' => Stub::factory('\\Codeception\\Step', 2))));
     $I->executeTestedMethodOn($scenario)->seeMethodInvoked($test, 'runStep')->seePropertyEquals($scenario, 'currentStep', 1);
 }
예제 #2
0
 public function loadScenario()
 {
     if (file_exists($this->bootstrap)) {
         require $this->bootstrap;
     }
     $unit = $this->testClass;
     if (isset($this->testClass->class)) {
         if (!class_exists($this->testClass->class, true)) {
             throw new \Exception("Tested class '{$unit->class}' can't be loaded.");
         }
     }
     // executing test
     $I = new \CodeGuy($this->scenario);
     if ($this->getCoveredMethod()) {
         $I->testMethod($this->signature);
     }
     if ($spec = $this->getSpecFromMethod()) {
         $I->wantTo($spec);
     }
     if ($this->static) {
         $class = $unit->class;
         if (!is_callable(array($class, $this->testMethod))) {
             throw new \Exception("Method {$this->specName} can't be found in tested class");
         }
         call_user_func(array(get_class($unit), $this->testMethod), $I);
     } else {
         if (!is_callable(array($unit, $this->testMethod))) {
             throw new \Exception("Method {$this->specName} can't be found in tested class");
         }
         call_user_func(array($this->testClass, $this->testMethod), $I);
     }
 }
예제 #3
0
 public function convertWithException(\CodeGuy $I)
 {
     $I->wantTo("test if converting of different measure types fails.");
     $I->haveStub($converter = Stub::make($this->class));
     $I->amTestingMethod('\\Measure\\Converter.convert');
     $I->executeTestedMethodOn($converter, 1, 'liter', 'kg');
     $I->seeExceptionThrown('\\ErrorException');
 }
예제 #4
0
 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');
 }
예제 #5
0
<?php

$I = new CodeGuy($scenario);
$I->wantTo('drink beer, actually...');