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

Normalizing test namespaces (and folder structure)? #529

Closed
zoliszabo opened this issue Feb 22, 2018 · 4 comments · Fixed by #785
Closed

Normalizing test namespaces (and folder structure)? #529

zoliszabo opened this issue Feb 22, 2018 · 4 comments · Fixed by #785

Comments

@zoliszabo
Copy link
Contributor

Currently we have a couple of different namespace structures:

  1. In emogrifier/tests/Unit/EmogrifierTest.php:
    -> namespace Pelago\Tests\Unit;
  2. In emogrifier/tests/Unit/CssInlinerTest.php:
    -> namespace Pelago\Emogrifer\Tests\Unit;
  3. In emogrifier/tests/Unit/Emogrifier/HtmlProcessor/AbstractHtmlProcessorTest.php:
    -> namespace Pelago\Tests\Unit\Emogrifier\HtmlProcessor;
    In emogrifier/tests/Unit/Emogrifier/HtmlProcessor/HtmlNormalizerTest.php:
    -> namespace Pelago\Tests\Unit\Emogrifier\HtmlProcessor;

I think we should decide between Pelago\Emogrifier\Tests\Unit and Pelago\Tests\Emogrifier\Unit as the prefix across all tests. Which one would you prefer?

Also, to keep sync between the src and tests folders, CssInlinerTest.php should be moved into the Emogrifier folder.

What do you think?

@oliverklee
Copy link
Contributor

The Emogrifier class is outside the namespace we'd like to have after all cleanup is done (which is Pelago\Emogrifier.

Usually, the test namespace structure should match that of the tested production classes. In this cases, I'm for making an exception and put the Emogrifier test into Pelago\Emogrifier\Tests\Unit (so it technically has an extra Emogrifier in the namespace) so at least the test namespaces are proper PSR-4.

I think we should decide between Pelago\Emogrifier\Tests\Unit and Pelago\Tests\Emogrifier\Unit as the prefix across all tests. Which one would you prefer?

Definitely Pelago\Emogrifier\Tests\Unit. I think I mixed it up by accident in the CssInlinerTest.

@oliverklee
Copy link
Contributor

Moving to 4.0 (as this is the milestone where we will remove the original Emogrifier class).

@oliverklee oliverklee modified the milestones: 2.1.0, 4.0.0 Apr 3, 2018
@JakeQZ
Copy link
Contributor

JakeQZ commented Sep 11, 2019

I just found there’s a typo in the CssInlinerTest namespace:

namespace Pelago\Emogrifer\Tests\Unit;

Simply correcting this to Pelago\Emogrifier\Tests\Unit didn’t seem right, as the other test classes all seem to be within Pelago\Tests\Unit\….

For consistency with how their namespace (and location) corresponds to the class under test, it looks like the namespace for CssInlinerTest should be Pelago\Tests\Unit\Emogrifier and the file should also be moved into the Emogrifier subdirectory of where it is now.

Definitely Pelago\Emogrifier\Tests\Unit. I think I mixed it up by accident in the CssInlinerTest.

But based on this comment, it's the other test classes that need changing, at least as far as the namespace name is concerned…

@oliverklee
Copy link
Contributor

oliverklee commented Sep 12, 2019

The namespace prefix should be Pelago\Emogrifier\Tests\Unit, and the PSR-4 namespace for the folder Tests/ should be Pelago\Emogrifier\Tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants