MediaWiki REL1_33
MaintenanceBaseTestCase.php
Go to the documentation of this file.
1<?php
2
4
8
10
16 protected $maintenance;
17
18 protected function setUp() {
19 parent::setUp();
20
21 $this->maintenance = $this->createMaintenance();
22 }
23
28 protected function tearDown() {
29 if ( $this->maintenance ) {
30 $this->maintenance->cleanupChanneled();
31 }
32
33 // This is smelly, but maintenance scripts usually produce output, so
34 // we anticipate and ignore with a regex that will catch everything.
35 //
36 // If you call $this->expectOutputRegex in your subclass, this guard
37 // won't be triggered, and your specific pattern will be respected.
38 if ( !$this->hasExpectationOnOutput() ) {
39 $this->expectOutputRegex( '/.*/' );
40 }
41
42 parent::tearDown();
43 }
44
55 abstract protected function getMaintenanceClass();
56
62 protected function createMaintenance() {
63 $className = $this->getMaintenanceClass();
64 $obj = new $className();
65
66 // We use TestingAccessWrapper in order to access protected internals
67 // such as `output()`.
68 return TestingAccessWrapper::newFromObject( $obj );
69 }
70
83 protected function assertOutputPrePostShutdown( $preShutdownOutput, $expectNLAppending ) {
84 $this->assertEquals( $preShutdownOutput, $this->getActualOutput(),
85 "Output before shutdown simulation" );
86
87 $this->maintenance->cleanupChanneled();
88
89 $postShutdownOutput = $preShutdownOutput . ( $expectNLAppending ? "\n" : "" );
90 $this->expectOutputString( $postShutdownOutput );
91 }
92
93}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
createMaintenance()
Called by setUp to initialize $this->maintenance.
assertOutputPrePostShutdown( $preShutdownOutput, $expectNLAppending)
Asserts the output before and after simulating shutdown.
Maintenance $maintenance
The main Maintenance instance that is used for testing, wrapped and mockable.
tearDown()
Do a little stream cleanup to prevent output in case the child class hasn't tested the capture buffer...