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); } }
function testExceptions() { $I = new CodeGuy($this->scenario); $I->testMethod('UserModel.get'); $user = new UserModel(); $I->executeTestedMethodOn($user, 'name'); $I->seeExceptionThrown('Exception'); $this->runSteps(); }