MediaWiki  1.33.0
PHPUnit4And6Compat.php
Go to the documentation of this file.
1 <?php
24 trait PHPUnit4And6Compat {
31  public function setExpectedException( $name, $message = '', $code = null ) {
32  if ( is_callable( 'parent::expectException' ) ) {
33  if ( $name !== null ) {
34  parent::expectException( $name );
35  }
36  if ( $message !== '' ) {
37  $this->expectExceptionMessage( $message );
38  }
39  if ( $code !== null ) {
40  $this->expectExceptionCode( $code );
41  }
42  } else {
43  parent::setExpectedException( $name, $message, $code );
44  }
45  }
46 
50  public function expectException( $exception ) {
51  if ( is_callable( 'parent::expectException' ) ) {
52  parent::expectException( $exception );
53  return;
54  }
55 
56  parent::setExpectedException( $exception );
57  }
58 
64  public function getMock( $originalClassName, $methods = [], array $arguments = [],
65  $mockClassName = '', $callOriginalConstructor = true, $callOriginalClone = true,
66  $callAutoload = true, $cloneArguments = false, $callOriginalMethods = false,
67  $proxyTarget = null
68  ) {
69  if ( is_callable( 'parent::getMock' ) ) {
70  return parent::getMock(
71  $originalClassName, $methods, $arguments, $mockClassName,
72  $callOriginalConstructor, $callOriginalClone, $callAutoload,
73  $cloneArguments, $callOriginalMethods, $proxyTarget
74  );
75  } else {
76  $builder = $this->getMockBuilder( $originalClassName )
77  ->setMethods( $methods )
78  ->setConstructorArgs( $arguments )
79  ->setMockClassName( $mockClassName )
80  ->setProxyTarget( $proxyTarget );
81  if ( $callOriginalConstructor ) {
82  $builder->enableOriginalConstructor();
83  } else {
84  $builder->disableOriginalConstructor();
85  }
86  if ( $callOriginalClone ) {
87  $builder->enableOriginalClone();
88  } else {
89  $builder->disableOriginalClone();
90  }
91  if ( $callAutoload ) {
92  $builder->enableAutoload();
93  } else {
94  $builder->disableAutoload();
95  }
96  if ( $cloneArguments ) {
97  $builder->enableArgumentCloning();
98  } else {
99  $builder->disableArgumentCloning();
100  }
101  if ( $callOriginalMethods ) {
102  $builder->enableProxyingToOriginalMethods();
103  } else {
104  $builder->disableProxyingToOriginalMethods();
105  }
106 
107  return $builder->getMock();
108  }
109  }
110 
120  public function createMock( $originalClassName ) {
121  if ( is_callable( 'parent::createMock' ) ) {
122  return parent::createMock( $originalClassName );
123  }
124  // Compat for PHPUnit <= 5.4
125  return $this->getMockBuilder( $originalClassName )
126  ->disableOriginalConstructor()
127  ->disableOriginalClone()
128  ->disableArgumentCloning()
129  // New in phpunit-mock-objects 3.2 (phpunit 5.4.0)
130  // ->disallowMockingUnknownTypes()
131  ->getMock();
132  }
133 
139  public function markAsRisky() {
140  if ( is_callable( 'parent::markAsRisky' ) ) {
141  return parent::markAsRisky();
142  }
143 
144  // "risky" tests are not supported in phpunit 4, so just ignore
145  }
146 
147 }
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
$code
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
Definition: hooks.txt:780
array
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:271