Problem/Motivation
When running functional tests with a different user from the one that is running your webserver, an exception can be thrown and cause confusion.
1) Drupal\Tests\help\Functional\HelpTest::testHelp
Exception: Warning: mkdir(): Permission denied
Drupal\Component\PhpStorage\FileStorage->createDirectory() (Line: 165)
The error is misleading because even if you're running the command as root or have 777 permissions on *all* your docroot (for testing purposes only), this will not make a difference as you'd still not be running the command with the user PHPUnit expects.
Proposed resolution
If we cannot improve the exception, at least let's update the documentation in code so that people know what to expect and make changes to their command accordingly.
It'll be a good idea to also update https://www.drupal.org/node/2116263 after that issue has been committed.
Remaining tasks
Review patch. Agree on the approach.
User interface changes
None.
API changes
None.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #43 | interdiff-40-43.txt | 819 bytes | anavarre |
| #43 | 2760905-43.patch | 3.12 KB | anavarre |
| #40 | interdiff-38-40.txt | 858 bytes | anavarre |
| #40 | 2760905-40.patch | 3.05 KB | anavarre |
| #38 | interdiff-33-38.txt | 646 bytes | anavarre |
Comments
Comment #2
anavarreComments in README files should also probably be wrapped at 80 cols.
Comment #3
anavarreComment #4
anavarreComment #5
cilefen commentedThis is the same situation as with simpletest in Drupal 7. It isn't actually true that it must be the same user. A user in the same group as the web server user will do if file permissions are configured accordingly.
Comment #6
anavarreWorks better now?
Comment #7
anavarreTypo made it through.
Comment #8
anavarreCame back to this because I found a tricky one with
printerwhich needs to beprinterClassinstead. Code was correct in http://cgit.drupalcode.org/drupal/tree/core/phpunit.xml.dist?id=9d5b5a53... but there was a regression in #2706113: Disable Drupal\Tests\Listeners\HtmlOutputPrinter by default because PHPStorm is broken it seems.Comment #9
anavarreComment #10
jibranThere should be an equal sign '=' between --testsuite and the argument.
Comment #11
n.kishorekumar commentedComment #12
anavarreHelp command said
--testsuite <pattern> Filter which testsuite to run.so it didn't look obvious.EDIT: @N.kishorekumar and I have cross-posted, thus why the mess with the file upload. Sorry about that.
Comment #13
anavarreComment #14
dawehnerI really like this! Of course we can improve this documentation a lot more, its a process, rather than a steady state, but this itself improves things. I have a bit of a feeling that the grammar is weird, but its really just a feeling.
Comment #15
claudiu.cristeaWho's running tests? In the most of the cases the developer who also wrote that test. And writing a test always brings you to BrowserTestBase class. I would provide full instructions in the docblock of that class. BTW, it's the first time I notice that we have a core/tests/README.md file :)
Also I would add that printerClass attribute/value should go inside
<phpunit ...>tag. I was confused initially by the phpunit.xml.dist documentation, it was not very clear where that should go.Comment #16
anavarreThe question should probably be: to what extent what already exists in the documentation page should be added in code as well? Perhaps we should simply keep things fairly straight forward and link to https://www.drupal.org/node/2116263 for more details?
Comment #17
claudiu.cristeaOk, then.
Comment #18
klausimeh, don't do the "su www-data" dance if you are developing locally. Run Apache/Nginx under your own user account instead, as described in https://klau.si/dev
Comment #20
anavarreThis new patch addresses the concern raised in #18 and a mix of #15 and #16.
Comment #21
claudiu.cristeaComment #22
alexpottThis is a really nice improvment and will help people. But...
I think saying "Unix user" is a bit weird. What is someone who uses OS X or windows to think?
Comment #23
claudiu.cristeaComment #24
claudiu.cristeaComment #25
claudiu.cristeaSorry for posting twice. The site was stuck and I pressed again the button.
Comment #27
claudiu.cristeaComment #28
anavarreFair enough.
Comment #29
alexpottWhy is this TODO staying here when you move the other... I think we should move this one too.
This is not right - at least according to the help when I do
phpunit --helpTesting for me shows that #10 is not right.
Comment #30
anavarre1.
It's been moved following the comment in #15 because it can be confusing for people to know where to put
printerClass- I tried to make sense of https://youtrack.jetbrains.com/issue/WI-24808 but couldn't really tell if it's fixed or not. If it is, then we can remove the ToDo altogether and addprinterClassby default, I think. If we still need it, then IDK if it's important to keep the ToDos grouped or not? It was only moved to prevent any confusion withprinterClass, nothing else.2. I was also under the impression
--filter <pattern>didn't need the equal sign but it works equally well so I don't have any strong opinion.Comment #31
anavarreAny additional feedback?
Comment #32
dawehnerWell, let's go with what the official documentation says ...
Comment #33
anavarreAlright.
Comment #34
amitaibuI'm running into this problem, and that file doesn't seem to exist on my Mac (v10.10)
Comment #35
amitaibuOn Mac the config should be under
/etc/apache2/httpd.conf. I think it's probably better to document the location in the docs, instead of the patch - as I suspect it will differ from installation to installation.Comment #37
amitaibuTo continue from the above comment, and more specifically, for mac I found installation under
/etc/apache2/httpd.confin this section:Comment #38
anavarreI agree it's better to have this in the d.o. documentation. However, improving the README file can't really hurt unless the file name changes indeed. How about this patch for now?
Comment #39
dawehnerMh, this approach is potentially less secure, as your database server then might be able to access any data of your user. We should at least have some sort of notion that this is less secure than the other option.
Comment #40
anavarreI thought mentioning it's for developing locally was enough. Improved verbiage in this patch.
Comment #41
dawehnerThank you! Personally I think we can always iterate on here
Comment #42
amitaibuthe Mac => Mac
Also, maybe we can give a Mac example:
Comment #43
anavarreThere you go.
Comment #44
amitaibuGreat, thanks. Seems ready.
Comment #45
alexpottThis is helpful and a good start and I agree with @dawehner this can be iterated on further.
Committed and pushed cf37e90 to 8.3.x and c40dd5d to 8.2.x and dbcfdad to 8.1.x. Thanks!