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

Unit tests include hardcoded paths #102

Closed
mfendeksilverstripe opened this issue Nov 10, 2017 · 15 comments
Closed

Unit tests include hardcoded paths #102

mfendeksilverstripe opened this issue Nov 10, 2017 · 15 comments
Labels
bug dev-issue Issue only affecting active developers help wanted

Comments

@mfendeksilverstripe
Copy link

I found this lovely piece of code in the AnnotatorPageTest.php. We moved Page and PageController to a different location (under Pages folder) in our project. Since these paths are hard coded unit tests are now failing. At least the code comments were honest about the situation.

// Why is this required?
// @todo get it to work properly
require_once(BASE_PATH . '/mysite/code/Page.php');
require_once(BASE_PATH . '/mysite/code/PageController.php');

I recommend avoiding using hard coded paths for includes if you're including stuff from project folder.

@robbieaverill
Copy link
Contributor

We've got this logged as #93, but this has a bit more detail so I'll close that in favour of this one.

We shouldn't need these require statements at all - do you feel like making a PR to remove them @mfendeksilverstripe?

@Firesphere
Copy link
Member

I'd love to get rid of this weird requirement! I've not found a reason for it, but if you have anything, please do make a PR @mfendeksilverstripe :D

@Firesphere
Copy link
Member

Sorry, wrong button!

@Firesphere
Copy link
Member

I have not yet gotten to the bottom as to why these use statements are needed in the tests. Any help is welcome

@Firesphere
Copy link
Member

It still requires the require, I would like to get it out for 3.x stable, but I can't find where it is, for the love of all that is holy and unholy

@Firesphere
Copy link
Member

Refering to #93 and closing this one

@Firesphere
Copy link
Member

Reopening because I did not think clearly.

@Firesphere Firesphere reopened this Jan 30, 2018
@Firesphere
Copy link
Member

Although it's weird/stupid this is somehow needed, how come your tests are failing @mfendeksilverstripe ? You shouldn't run vendor tests in your own code.

I agree it shouldn't be there, but it should also not affect your code?

@mfendeksilverstripe
Copy link
Author

@Firesphere I actually don't remember what exactly the issue was as we don't use this module anymore. I will have a look at it on Friday (Hackday).

@mfendeksilverstripe
Copy link
Author

@Firesphere I included the module and ran the project tests. No issues were present this time.

@robbieaverill
Copy link
Contributor

Ideally these classes would be loaded by composer. If this module doesn't use the SS class manifest and there's no autoloader definition for these classes then it might not work, which could be a reason why we'd need to keep this. If that's the case then it'll become a "meh, oh well" for now - we could look at making a PR to add a PSR-0 autoloading rule for them, but (in SS4) they're added as project files by recipe-cms so not sure whether the current recipe plugin would support adding those extra composer.json configs - I assume it probably won't

@Firesphere
Copy link
Member

Still an open issue. Slightly resolved in #107, which would at least check the classes exist. Proper solution implementation is only relevant for people actively working on this module and not end users.

Won't fix in the short term, but is on the list.

@Firesphere Firesphere added help wanted dev-issue Issue only affecting active developers labels May 27, 2018
@robbieaverill
Copy link
Contributor

Ah, I think it's because those stubs are suffixed with "Test" so PHPunit is trying to run them. I'll rename them

@robbieaverill
Copy link
Contributor

Fixed in #116

@Firesphere
Copy link
Member

Merged in #116

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug dev-issue Issue only affecting active developers help wanted
Projects
None yet
Development

No branches or pull requests

3 participants