Ejemplo n.º 1
0
 function testSetReturnArray_should_throw_an_exception_when_the_second_parameter_is_not_an_array()
 {
     $rvm = new ReturnValuesManager('foo');
     $this->expectException('Exception');
     // E' giusto così????
     $rvm->setReturnValuesArray('bar', 1);
 }
Ejemplo n.º 2
0
 function test_returnJustGeneratedClass_return_array_at()
 {
     $rvm = new ReturnValuesManager('test_10');
     $rvm->setReturnValuesArray('prova_metodo', array(1, 2, 3, 'prova' => 'provolone', false, true), 1)->setReturnValuesArray('prova_metodo', array(1, 'pippo'), 2)->setReturnValuesArray('prova_metodo', array('prova' => 'provolone', true), 3);
     FakeObjectGenerator::generate($rvm, new CodeGenerator(dirname(__FILE__) . '/list.php'));
     $classe = "class test_10{\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        return array('0'=>1,'1'=>2,'2'=>3,'prova'=>'provolone','3'=>false,'4'=>true);\n        break;\n        case 2:\n        return array('0'=>1,'1'=>'pippo');\n        break;\n        case 3:\n        return array('prova'=>'provolone','0'=>true);\n        break;\n        default: return null;\n        }\n    }\n}";
     $this->assertEqual($classe, FakeObjectGenerator::returnedCode());
     $oggetto = new test_10();
     $this->assertEqual(array(1, 2, 3, 'prova' => 'provolone', false, true), $oggetto->prova_metodo());
     $this->assertEqual(array(1, 'pippo'), $oggetto->prova_metodo());
     $this->assertEqual(array('prova' => 'provolone', true), $oggetto->prova_metodo());
 }