Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2448fbc

Browse files
committed
deprecate the Legacy/testLegacy test name prefix
1 parent1099f6b commit2448fbc

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

‎src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php‎

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class SymfonyTestsListener extends \PHPUnit_Framework_BaseTestListener
2828
private$expectedDeprecations =array();
2929
private$gatheredDeprecations =array();
3030
private$previousErrorHandler;
31+
private$testsWithWarnings;
3132

3233
/**
3334
* @param array $mockedNamespaces List of namespaces, indexed by mocked features (time-sensitive or dns-sensitive)
@@ -75,6 +76,7 @@ public function __destruct()
7576
publicfunctionstartTestSuite(\PHPUnit_Framework_TestSuite$suite)
7677
{
7778
$suiteName =$suite->getName();
79+
$this->testsWithWarnings =array();
7880

7981
if (-1 ===$this->state) {
8082
echo"Testing$suiteName\n";
@@ -170,8 +172,19 @@ public function startTest(\PHPUnit_Framework_Test $test)
170172
}
171173
}
172174

175+
publicfunctionaddWarning(\PHPUnit_Framework_Test$test,\PHPUnit_Framework_Warning$e,$time)
176+
{
177+
if ($testinstanceof \PHPUnit_Framework_TestCase) {
178+
$this->testsWithWarnings[$test->getName()] =true;
179+
}
180+
}
181+
173182
publicfunctionendTest(\PHPUnit_Framework_Test$test,$time)
174183
{
184+
$className =get_class($test);
185+
$classGroups = \PHPUnit_Util_Test::getGroups($className);
186+
$groups = \PHPUnit_Util_Test::getGroups($className,$test->getName(false));
187+
175188
if ($this->expectedDeprecations) {
176189
restore_error_handler();
177190

@@ -188,15 +201,21 @@ public function endTest(\PHPUnit_Framework_Test $test, $time)
188201
$this->previousErrorHandler =null;
189202
}
190203
if (-2 <$this->state &&$testinstanceof \PHPUnit_Framework_TestCase) {
191-
$groups = \PHPUnit_Util_Test::getGroups(get_class($test),$test->getName(false));
192-
193204
if (in_array('time-sensitive',$groups,true)) {
194205
ClockMock::withClockMock(false);
195206
}
196207
if (in_array('dns-sensitive',$groups,true)) {
197208
DnsMock::withMockedHosts(array());
198209
}
199210
}
211+
212+
if ($testinstanceof \PHPUnit_Framework_TestCase &&0 ===strpos($test->getName(),'testLegacy') && !isset($this->testsWithWarnings[$test->getName()]) && !in_array('legacy',$groups,true)) {
213+
$test->getTestResultObject()->addWarning($test,new \PHPUnit_Framework_Warning('Using the testLegacy prefix to mark tests as legacy is deprecated since version 3.3 and will be removed in 4.0. Use the "@group legacy" notation instead to add the test to the legacy group.'),$time);
214+
}
215+
216+
if ($testinstanceof \PHPUnit_Framework_TestCase &&strpos($className,'\Legacy') && !isset($this->testsWithWarnings[$test->getName()]) && !in_array('legacy',$classGroups,true)) {
217+
$test->getTestResultObject()->addWarning($test,new \PHPUnit_Framework_Warning('Using the Legacy prefix to mark all tests of a class as legacy is deprecated since version 3.3 and will be removed in 4.0. Use the "@group legacy" notation instead to add the test to the legacy group.'),$time);
218+
}
200219
}
201220

202221
publicfunctionhandleError($type,$msg,$file,$line,$context)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp