-
Notifications
You must be signed in to change notification settings - Fork 12
/
TestCasePHPUnitLte7.php
172 lines (156 loc) · 4.54 KB
/
TestCasePHPUnitLte7.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<?php
namespace Yoast\PHPUnitPolyfills\TestCases;
use PHPUnit\Framework\TestCase as PHPUnit_TestCase;
use Yoast\PHPUnitPolyfills\Helpers\AssertAttributeHelper;
use Yoast\PHPUnitPolyfills\Polyfills\AssertClosedResource;
use Yoast\PHPUnitPolyfills\Polyfills\AssertEqualsSpecializations;
use Yoast\PHPUnitPolyfills\Polyfills\AssertFileDirectory;
use Yoast\PHPUnitPolyfills\Polyfills\AssertFileEqualsSpecializations;
use Yoast\PHPUnitPolyfills\Polyfills\AssertionRenames;
use Yoast\PHPUnitPolyfills\Polyfills\AssertIsType;
use Yoast\PHPUnitPolyfills\Polyfills\AssertNumericType;
use Yoast\PHPUnitPolyfills\Polyfills\AssertObjectEquals;
use Yoast\PHPUnitPolyfills\Polyfills\AssertObjectProperty;
use Yoast\PHPUnitPolyfills\Polyfills\AssertStringContains;
use Yoast\PHPUnitPolyfills\Polyfills\EqualToSpecializations;
use Yoast\PHPUnitPolyfills\Polyfills\ExpectException;
use Yoast\PHPUnitPolyfills\Polyfills\ExpectExceptionMessageMatches;
use Yoast\PHPUnitPolyfills\Polyfills\ExpectExceptionObject;
use Yoast\PHPUnitPolyfills\Polyfills\ExpectPHPException;
/**
* Basic test case for use with PHPUnit <= 7.
*
* This test case uses renamed (snakecase) methods for the `setUpBeforeClass()`, `setUp()`,
* `assertPreConditions()`, `assertPostConditions()`, `tearDown()` and `tearDownAfterClass()`
* methods to get round the signature change in PHPUnit 8.
*
* When using this TestCase, the snakecase method names need to be used to overload a fixture method.
*/
abstract class TestCase extends PHPUnit_TestCase {
use AssertAttributeHelper;
use AssertClosedResource;
use AssertEqualsSpecializations;
use AssertFileDirectory;
use AssertFileEqualsSpecializations;
use AssertionRenames;
use AssertIsType;
use AssertNumericType;
use AssertObjectEquals;
use AssertObjectProperty;
use AssertStringContains;
use EqualToSpecializations;
use ExpectException;
use ExpectExceptionMessageMatches;
use ExpectExceptionObject;
use ExpectPHPException;
/**
* This method is called before the first test of this test class is run.
*
* @codeCoverageIgnore
*
* @return void
*/
public static function setUpBeforeClass() {
parent::setUpBeforeClass();
static::set_up_before_class();
}
/**
* Sets up the fixture, for example, open a network connection.
*
* This method is called before each test.
*
* @return void
*/
protected function setUp() {
parent::setUp();
$this->set_up();
}
/**
* Performs assertions shared by all tests of a test case.
*
* This method is called before the execution of a test starts and after setUp() is called.
*
* @return void
*/
protected function assertPreConditions() {
parent::assertPreConditions();
$this->assert_pre_conditions();
}
/**
* Performs assertions shared by all tests of a test case.
*
* This method is called before the execution of a test ends and before tearDown() is called.
*
* @return void
*/
protected function assertPostConditions() {
parent::assertPostConditions();
$this->assert_post_conditions();
}
/**
* Tears down the fixture, for example, close a network connection.
*
* This method is called after each test.
*
* @return void
*/
protected function tearDown() {
$this->tear_down();
parent::tearDown();
}
/**
* This method is called after the last test of this test class is run.
*
* @codeCoverageIgnore
*
* @return void
*/
public static function tearDownAfterClass() {
static::tear_down_after_class();
parent::tearDownAfterClass();
}
/**
* This method is called before the first test of this test class is run.
*
* @return void
*/
public static function set_up_before_class() {}
/**
* Sets up the fixture, for example, open a network connection.
*
* This method is called before each test.
*
* @return void
*/
protected function set_up() {}
/**
* Performs assertions shared by all tests of a test case.
*
* This method is called before the execution of a test starts and after set_up() is called.
*
* @return void
*/
protected function assert_pre_conditions() {}
/**
* Performs assertions shared by all tests of a test case.
*
* This method is called before the execution of a test ends and before tear_down() is called.
*
* @return void
*/
protected function assert_post_conditions() {}
/**
* Tears down the fixture, for example, close a network connection.
*
* This method is called after each test.
*
* @return void
*/
protected function tear_down() {}
/**
* This method is called after the last test of this test class is run.
*
* @return void
*/
public static function tear_down_after_class() {}
}