24 trait PHPUnit4And6Compat {
31 public function setExpectedException(
$name, $message =
'',
$code =
null ) {
32 if ( is_callable( [ $this,
'expectException' ] ) ) {
33 if (
$name !==
null ) {
34 $this->expectException(
$name );
36 if ( $message !==
'' ) {
37 $this->expectExceptionMessage( $message );
39 if (
$code !==
null ) {
40 $this->expectExceptionCode(
$code );
43 parent::setExpectedException(
$name, $message,
$code );
52 public function getMock( $originalClassName, $methods = [],
array $arguments = [],
53 $mockClassName =
'', $callOriginalConstructor =
true, $callOriginalClone =
true,
54 $callAutoload =
true, $cloneArguments =
false, $callOriginalMethods =
false,
57 if ( is_callable(
'parent::getMock' ) ) {
58 return parent::getMock(
59 $originalClassName, $methods, $arguments, $mockClassName,
60 $callOriginalConstructor, $callOriginalClone, $callAutoload,
61 $cloneArguments, $callOriginalMethods, $proxyTarget
64 $builder = $this->getMockBuilder( $originalClassName )
65 ->setMethods( $methods )
66 ->setConstructorArgs( $arguments )
67 ->setMockClassName( $mockClassName )
68 ->setProxyTarget( $proxyTarget );
69 if ( $callOriginalConstructor ) {
70 $builder->enableOriginalConstructor();
72 $builder->disableOriginalConstructor();
74 if ( $callOriginalClone ) {
75 $builder->enableOriginalClone();
77 $builder->disableOriginalClone();
79 if ( $callAutoload ) {
80 $builder->enableAutoload();
82 $builder->disableAutoload();
84 if ( $cloneArguments ) {
85 $builder->enableArgumentCloning();
87 $builder->disableArgumentCloning();
89 if ( $callOriginalMethods ) {
90 $builder->enableProxyingToOriginalMethods();
92 $builder->disableProxyingToOriginalMethods();
95 return $builder->getMock();
108 public function createMock( $originalClassName ) {
109 if ( is_callable(
'parent::createMock' ) ) {
110 return parent::createMock( $originalClassName );
113 return $this->getMockBuilder( $originalClassName )
114 ->disableOriginalConstructor()
115 ->disableOriginalClone()
116 ->disableArgumentCloning()