function test_returnJustGeneratedClass_return_exception_at() { $rvm = new ReturnValuesManager('test_11'); $rvm->setReturnException('prova_metodo', 'Exception', 'eccezione sollevata 1', 1)->setReturnException('prova_metodo', 'Exception', 'eccezione sollevata 2', 2); FakeObjectGenerator::generate($rvm, new CodeGenerator(dirname(__FILE__) . '/list.php')); $classe = "class test_11{\n//timing\n private static \$times = array();\n//Costants\n//Magic methods\n public function __call(\$name, \$arguments) {\n return null;\n }\n public function __callStatic(\$name, \$arguments) {\n return null;\n }\n//Methods\n function prova_metodo(){\n if(isset(self::\$times['prova_metodo'])){\n self::\$times['prova_metodo']++;\n }\n else{\n self::\$times['prova_metodo'] = 1;\n }\nswitch (self::\$times['prova_metodo']){\n case 1:\n throw new Exception('eccezione sollevata 1');\n break;\n case 2:\n throw new Exception('eccezione sollevata 2');\n break;\n default: return null;\n }\n }\n}"; $this->assertEqual(FakeObjectGenerator::returnedCode(), $classe); $this->expectException('Exception'); $oggetto = new test_4(); $oggetto->prova_metodo(); }
function testIsSetReturnParameter_should_return_true_when_at_least_one_exception_is_set() { $rvm = new ReturnValuesManager('foo'); $rvm->setReturnException('bar', 'foo', 'message'); $this->assertTrue($rvm->hasReturnValues('bar')); }