コード例 #1
0
ファイル: MockBuilder.php プロジェクト: saimons/mockista
 private function createMock($class)
 {
     if ($class) {
         $classGenerator = new ClassGenerator();
         $classGenerator->setMethodFinder(new MethodFinder());
         $newName = str_replace("\\", "_", $class) . '_' . mt_rand();
         $code = $classGenerator->generate($class, $newName);
         eval($code);
         $mock = new $newName();
         $mock->mockista = new Mock();
         $mock->mockista->setName($class);
     } else {
         $mock = new Mock();
     }
     return $mock;
 }
コード例 #2
0
ファイル: MockController.php プロジェクト: redhead/mockyll
 private function createClassMock($class, $constructorArgs = null)
 {
     $newClass = str_replace("\\", "_", $class) . '_' . uniqid();
     $generator = new ClassGenerator();
     $generator->setMethodFinder(new MethodFinder());
     $code = $generator->generate($class, $newClass);
     eval($code);
     $mock = new $newClass(false);
     if ($constructorArgs !== null) {
         call_user_func_array(array($mock, '__construct'), array(true, $constructorArgs));
     }
     $mock->__mockController = $this;
     return $mock;
 }