Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OrderedClassElementsFixer - PHPUnit Bridge support #5311

Merged
merged 1 commit into from
Dec 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/Fixer/ClassNotation/OrderedClassElementsFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,13 @@ private function detectElementType(Tokens $tokens, $index)
if (
$nameToken->equalsAny([
[T_STRING, 'setUpBeforeClass'],
[T_STRING, 'doSetUpBeforeClass'],
[T_STRING, 'tearDownAfterClass'],
[T_STRING, 'doTearDownAfterClass'],
[T_STRING, 'setUp'],
[T_STRING, 'doSetUp'],
[T_STRING, 'tearDown'],
[T_STRING, 'doTearDown'],
], false)
) {
return ['phpunit', strtolower($nameToken->getContent())];
Expand Down Expand Up @@ -426,9 +430,13 @@ private function sortElements(array $elements)
{
static $phpunitPositions = [
'setupbeforeclass' => 1,
'teardownafterclass' => 2,
'setup' => 3,
'teardown' => 4,
'dosetupbeforeclass' => 2,
'teardownafterclass' => 3,
'doteardownafterclass' => 4,
'setup' => 5,
'dosetup' => 6,
'teardown' => 7,
'doteardown' => 8,
];

foreach ($elements as &$element) {
Expand Down
8 changes: 8 additions & 0 deletions tests/Fixer/ClassNotation/OrderedClassElementsFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,12 @@ public static function teardownafterclass() {

protected function setUp() {}

protected function doSetUp() {}

protected function tearDown() {}

protected function doTearDown() {}

abstract public function foo1($a, $b = 1);

// foo2
Expand Down Expand Up @@ -196,6 +200,10 @@ abstract public function foo1($a, $b = 1);

protected function tearDown() {}

protected function doSetUp() {}

protected function doTearDown() {}

public function __clone() {}

const C1 = 1;
Expand Down