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

Refactoring tests #6854

Merged
merged 1 commit into from
Dec 8, 2017
Merged

Refactoring tests #6854

merged 1 commit into from
Dec 8, 2017

Conversation

carusogabriel
Copy link
Contributor

@carusogabriel carusogabriel commented Nov 28, 2017

Simple version of #6853, just using assertNull, assertFileExists, assertTrue and assertFalse. Also, in develop branch.

Copy link
Member

@lcobucci lcobucci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, LGTM 👍

@lcobucci lcobucci added this to the 3.0 milestone Nov 28, 2017
@lcobucci
Copy link
Member

lcobucci commented Nov 28, 2017

Since @guilhermeblanco is rebasing develop I'll leave this to him.

@carusogabriel
Copy link
Contributor Author

carusogabriel commented Dec 1, 2017

I've improved more tests, using:

@@ -174,7 +174,7 @@ problems using the following approach:
// do stuff with the data in the row, $row[0] is always the object

// detach all entities from Doctrine, so that Garbage-Collection can kick in immediately
$this->em->clear();
$this->_em->clear();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is incorrect.

@carusogabriel
Copy link
Contributor Author

I’m trying to rebase, but I guess I lost my work 😭

@Majkl578
Copy link
Contributor

Majkl578 commented Dec 4, 2017

You've probably just incorrectly rebased, but your commits still exist: 6999d39 + 60cd9cf.
Hint: Sometimes it's easier to just hard-reset local copy and re-apply the commits again by cherry-picking them.

@carusogabriel
Copy link
Contributor Author

I’m gonna try this, thanks for the tip

@carusogabriel
Copy link
Contributor Author

Should we refactory assertEquals('', $foo)/assertSame('', $foo) with assertEmpty($foo), and assertEquals([], $bar)/assertSame([], $bar) with assertEmpty($bar)?

@Ocramius
Copy link
Member

Ocramius commented Dec 4, 2017 via email

Copy link
Contributor

@Majkl578 Majkl578 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Develop has already been rebased so this can be merged now.

@Majkl578 Majkl578 merged commit 044239c into doctrine:develop Dec 8, 2017
@Majkl578 Majkl578 assigned Majkl578 and unassigned guilhermeblanco Dec 8, 2017
@carusogabriel carusogabriel deleted the refactoring-tests branch December 8, 2017 01:58
@Majkl578
Copy link
Contributor

Majkl578 commented Dec 8, 2017

@carusogabriel Thanks!

@carusogabriel
Copy link
Contributor Author

Any time @Majkl578 👨‍💻

@carnage
Copy link
Contributor

carnage commented Jul 24, 2021

Took a quick look at back porting this one and well, lets just say it's potentially going to be a big job.

94 out of 96 files have conflicts, a 95th is a deleted/modified conflict.

One of the biggest things I've noticed is there are conflicts on a lot of lines where $this->assert* has been changed to self::assert* (technically, the correct way to call the asserts) however this wasn't done in this PR. My guess is that we're missing a PR somewhere that did all the changes from $this-> to self:: and that finding and merging that one first might reduce the number of conflicts in this PR or at the very least make it possible to see what's going on in the diffs.

It is of cause possible that that PR will also have a huge number of conflicts, so it might be prudent to redo the work to change $this-> to self:: as it can be automated by php cs fixer.

Alternatively, if it's the project's choice to use $this-> to call the asserts php cs fixer could be run it in the opposite direction against the changes in this PR to make it closer to the current codebase before a merge is attempted.

@greg0ire
Copy link
Member

I think redoing the change would be best, because you would not catch all occurrences anyway. We use phpcs in this project, maybe we can find a rule to add to our coding standard?

@carnage
Copy link
Contributor

carnage commented Jul 24, 2021

This is the rule class for php cs fixer https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/3.0/src/Fixer/PhpUnit/PhpUnitTestCaseStaticMethodCallsFixer.php but I can't find an equivalent in php codesniffer. We'd also need to decide which style to support (options being Assert::assertX, static::assertX, self::assertX and $this->assertX with the latter two being the usual choices)

@greg0ire
Copy link
Member

🤔 I wonder why it is a phpunit-specific rule. My personal preference would be to run it once and make a PR, and pick self, because it won't conflict but because if we already merged that in the old-prototype-3.x, then there must be some consensus on using that.

@carnage
Copy link
Contributor

carnage commented Aug 8, 2021

In case anyone else comes across this ticket as a TODO, I have started work on it; however there are still ~60 conflicted files to go through so it's going to take a while :)

@carnage carnage mentioned this pull request Aug 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants