Problem/Motivation
If you do not set a SIMPLETEST_BASE_URL environment variable and run a test that extends JavascriptTestBase, JavascriptTestBase::tearDown() will still be run even though ::setUp() throws an exception. JavascriptTestBase::tearDown(), however, assumes that $this->mink is set so it fatals in this case.
Proposed resolution
Add a check if $this->mink is set inside JavascriptTestBase::tearDown(). This is inline with e.g. BrowserTestBase::tearDown().
Remaining tasks
Review patch. (See the "no-whitespace" patch, which was rolled with -w.)
User interface changes
None.
API changes
None.
Data model changes
None.
Comments
Comment #2
mtodor commentedI have tried this patch, it works fine and solution is ok.
It's also quite annoying issue, because exception thrown from JavascriptTestBase::tearDown "hides" real problem behind.
Comment #3
dawehnerAh damnit, we had a similar issue for BrowserTestBase. A good review could have caught that ...
I guess we should document
\Drupal\Tests\BrowserTestBase::$minkto also be|nullas long its not initialized.Comment #4
tstoecklerSo, something like this?
Comment #5
dawehnerYeah, that looks great for me
Comment #6
cilefen commentedI don't actually know the policy on magic numbers. If anybody knows or cares, change it.
The comment exceeds the 80 column width.
"whilst" is British English. As far as I know we use American English.
Comment #7
tstoeckler1. I tend to agree, but changing this is out of scope of this issue, this is used in a lot of other places in the same way.
2.+3. Fixed
Comment #8
dawehnerThank you @cilefen and @tstoeckler
Comment #9
alexpottIs this untestable?
Comment #10
tstoecklerI think so, yes. At least I have no idea, how I could manage to create an error in mink setup just for a single test.
Comment #11
xjmRegarding #6 and #7, yeah, it is out of scope to fix those here since they only reason they are changed is just a change to indenting. This can be seen with a
git diff -w. Edit: And I see the summary mentions that too. Super. :)If we had the same bug in BTB, is there any way we refactor so that it fixes both? In the caller or something? It's a bit worrisome to patch it in both places for a silent no-op. Even more so if it's not testable.
Is this the hunk in question in BTB?
In that case it's obvious why
$this->minkneeds to be set; maybe in this case we could at least add an inline comment.Not sure if my suggestions are actually helpful though, so leaving at RTBC for now.
Comment #12
alexpottSo whilst I think the
whilsttowhilechange is out-of-scope and, whilst it might(emphasis mine - http://blog.oxforddictionaries.com/2016/02/while-or-whilst/), I think we're good to go here :)
I can't work out a way of testing this and this type of change ensures that people can focus on the real error so committing.
Committed and pushed aa5da27 to 8.3.x and 5d59627 to 8.2.x. Thanks!