PHP 클래스 Qa\SoftMocks

파일 보기 프로젝트 열기: badoo/soft-mocks 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$internal_functions

공개 메소드들

메소드 설명
call ( $callable, $args ) : mixed Generic method to call a callable, useful for proxying call_user_func* calls
callFunction ( $namespace, $func, $params )
callMethod ( $obj, $class, $method, $args, $check_mock = false )
callNew ( $class, $args )
callOriginal ( $callable, $args, $class = null )
callStaticMethod ( $class, $method, $args, $check_mock = false )
constDefined ( $const )
errorHandler ( $errno, $errstr, $errfile, $errline )
generateCode ( $args, ReflectionMethod | null $Rm ) : string Generate code that parses function parameters that are specified as string $args
getClassConst ( $class, $const )
getConst ( $namespace, $const )
getMockCode ( $self, $static, $method )
getMockForGenerator ( $class, $method )
ignoreClass ( string $class )
ignoreConstant ( string $constant )
ignoreFiles ( $files )
ignoreFunction ( string $function )
init ( )
isCallable ( $callable )
isGeneratorMocked ( $class, $method )
isMocked ( $self, $static, $method )
printBackTrace ( Exception $e = null )
redefineConstant ( $constantName, $value )
redefineFunction ( $func, $functionArgs, $fakeCode )
redefineGenerator ( $class, $method, Generator $replacement )
redefineMethod ( string $class, string $method, string $functionArgs, string $fakeCode, boolean $strict = true ) Redefine method $class::$method with args list specified by $functionArgs (args list must be compatible with original function, you can specify only variable names) by using code $fakeCode instead of original function code.
redefineNew ( $class, callable $constructorFunc )
removeConstant ( $constantName )
replaceFilename ( $file, $raw = false )
restoreAll ( )
restoreAllConstants ( )
restoreAllNew ( )
restoreConstant ( $constantName )
restoreFunction ( $func )
restoreGenerator ( $class, $method )
restoreMethod ( $class, $method )
restoreNew ( $class )
rewrite ( $file )
setLockFilePath ( $lock_file_path )
setMocksCachePath ( string $mocks_cache_path )
setPhpParserPath ( $php_parser_path )
setPhpunitPath ( string $phpunit_path )
setRewriteInternal ( boolean $rewrite_internal )

보호된 메소드들

메소드 설명
debug ( $message )

비공개 메소드들

메소드 설명
createRewrittenFile ( $file, $target_file )
doRewrite ( $file )
getDeclaringTrait ( $class, $method )
getVersion ( )
injectIntoPhpunit ( )
recursiveGetTraits ( ReflectionClass $Rc ) : ReflectionClass[]
rewriteContents ( $orig_file, $target_file, $contents )
staticContextIsOk ( $self, $static, $method ) see \QA\SoftMocks\SoftMocksTest::testParentMismatch to see when getDeclaringClass check is needed

메소드 상세

call() 공개 정적인 메소드

Generic method to call a callable, useful for proxying call_user_func* calls
public static call ( $callable, $args ) : mixed
$callable
$args
리턴 mixed

callFunction() 공개 정적인 메소드

public static callFunction ( $namespace, $func, $params )

callMethod() 공개 정적인 메소드

public static callMethod ( $obj, $class, $method, $args, $check_mock = false )

callNew() 공개 정적인 메소드

public static callNew ( $class, $args )

callOriginal() 공개 정적인 메소드

public static callOriginal ( $callable, $args, $class = null )

callStaticMethod() 공개 정적인 메소드

public static callStaticMethod ( $class, $method, $args, $check_mock = false )

constDefined() 공개 정적인 메소드

public static constDefined ( $const )

debug() 보호된 정적인 메소드

protected static debug ( $message )

errorHandler() 공개 정적인 메소드

public static errorHandler ( $errno, $errstr, $errfile, $errline )

generateCode() 공개 정적인 메소드

Generate code that parses function parameters that are specified as string $args
public static generateCode ( $args, ReflectionMethod | null $Rm ) : string
$args
$Rm ReflectionMethod | null
리턴 string

getClassConst() 공개 정적인 메소드

public static getClassConst ( $class, $const )

getConst() 공개 정적인 메소드

public static getConst ( $namespace, $const )

getMockCode() 공개 정적인 메소드

public static getMockCode ( $self, $static, $method )

getMockForGenerator() 공개 정적인 메소드

public static getMockForGenerator ( $class, $method )

ignoreClass() 공개 정적인 메소드

public static ignoreClass ( string $class )
$class string - Do not allow to mock $class

ignoreConstant() 공개 정적인 메소드

public static ignoreConstant ( string $constant )
$constant string - Do not allow to mock $constant

ignoreFiles() 공개 정적인 메소드

public static ignoreFiles ( $files )

ignoreFunction() 공개 정적인 메소드

public static ignoreFunction ( string $function )
$function string - Do not allow to mock $function

init() 공개 정적인 메소드

public static init ( )

isCallable() 공개 정적인 메소드

public static isCallable ( $callable )

isGeneratorMocked() 공개 정적인 메소드

public static isGeneratorMocked ( $class, $method )

isMocked() 공개 정적인 메소드

public static isMocked ( $self, $static, $method )

printBackTrace() 공개 정적인 메소드

public static printBackTrace ( Exception $e = null )
$e Exception

redefineConstant() 공개 정적인 메소드

public static redefineConstant ( $constantName, $value )

redefineFunction() 공개 정적인 메소드

public static redefineFunction ( $func, $functionArgs, $fakeCode )

redefineGenerator() 공개 정적인 메소드

public static redefineGenerator ( $class, $method, Generator $replacement )
$replacement Generator

redefineMethod() 공개 정적인 메소드

There are two already defined variables that you can use in fake code: $mm_func_args = func_get_args(); $params is array of references to supplied arguments (func_get_args() does not contain refs in PHP5) You can use SoftMocks::callOriginal(...) for accessing original function/method as well Example: class A { public function b($c, &$d) { var_dump($c, $d); } } SoftMocks::redefineMethod(A::class, 'b', '$e, &$f', '$f = "hello";'); $a = 2; (new A())->b(1, $a); // nothing is printed here, so we intercepted the call var_dump($a); // string(5) "hello"
public static redefineMethod ( string $class, string $method, string $functionArgs, string $fakeCode, boolean $strict = true )
$class string
$method string Method of class to be intercepted
$functionArgs string List of argument names
$fakeCode string Code that will be eval'ed instead of function code
$strict boolean If strict=false then method of declaring class will also be mocked

redefineNew() 공개 정적인 메소드

public static redefineNew ( $class, callable $constructorFunc )
$constructorFunc callable

removeConstant() 공개 정적인 메소드

public static removeConstant ( $constantName )

replaceFilename() 공개 정적인 메소드

public static replaceFilename ( $file, $raw = false )

restoreAll() 공개 정적인 메소드

public static restoreAll ( )

restoreAllConstants() 공개 정적인 메소드

public static restoreAllConstants ( )

restoreAllNew() 공개 정적인 메소드

public static restoreAllNew ( )

restoreConstant() 공개 정적인 메소드

public static restoreConstant ( $constantName )

restoreFunction() 공개 정적인 메소드

public static restoreFunction ( $func )

restoreGenerator() 공개 정적인 메소드

public static restoreGenerator ( $class, $method )

restoreMethod() 공개 정적인 메소드

public static restoreMethod ( $class, $method )

restoreNew() 공개 정적인 메소드

public static restoreNew ( $class )

rewrite() 공개 정적인 메소드

public static rewrite ( $file )

setLockFilePath() 공개 정적인 메소드

public static setLockFilePath ( $lock_file_path )
$lock_file_path - Path to lock file that is used when file is rewritten

setMocksCachePath() 공개 정적인 메소드

public static setMocksCachePath ( string $mocks_cache_path )
$mocks_cache_path string - Path to cache of rewritten files

setPhpParserPath() 공개 정적인 메소드

public static setPhpParserPath ( $php_parser_path )
$php_parser_path - Part of path to PHP Parser so that it can be ignored when rewriting files

setPhpunitPath() 공개 정적인 메소드

public static setPhpunitPath ( string $phpunit_path )
$phpunit_path string - Part of path to phpunit so that it can be ignored when rewriting files

setRewriteInternal() 공개 정적인 메소드

public static setRewriteInternal ( boolean $rewrite_internal )
$rewrite_internal boolean

프로퍼티 상세

$internal_functions 공개적으로 정적으로 프로퍼티

public static $internal_functions