Closed (fixed)
Project:
Drupal core
Version:
8.1.x-dev
Component:
simpletest.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
27 May 2016 at 12:10 UTC
Updated:
19 Feb 2020 at 13:35 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
klausiHere is a failing test.
Comment #4
klausiFound the problem, we need to handle shut down callbacks same as TestBase does.
Comment #5
dawehnerDo we need the same kind of code in KernelTestBase?
Comment #6
jibranLet's visit front page and check the blocks to make sure that we have valid html.
Comment #7
jibranOr maybe we can convert
\Drupal\standard\Tests\StandardTestto BTB.This test should be moved to
\Drupal\Tests\standard\Functionalnamespace.Comment #8
klausi@dawehner: not sure, as long as we don't run into problems I think we can ignore it for kernel tests.
@jibran: good idea, although converting StandardTest requires porting tons of assertion functions. Not fully done with StandardTest, so this will fail.
Comment #10
jibranHow about this? interdiff is from #4.
Comment #11
jibranI think we should add a helper method for
assertRawto assert session.Comment #13
jibranComment #14
jibranFound a bug.
Comment #16
jibranI don't know why root user is not able to login.
Comment #17
klausiThanks jibran, but I think we should modify StandardTest as little as possible and provide maximum method compatibility on BrowserTestBase. That will make conversions easier since we don't have to change the actual test code as much (as first step).
I moved all the assertion helper methods to a trait.
StandardTest is now passing without test code changes, hooray!
Interdiff is against my previous patch, not jibran's.
Comment #18
klausiFiled #2735691: Missing config schema for private files path
Comment #19
klausiTurns out that BrowserTestBase is wrong in this case, not the config schema. Copied the code from WebTestBase and improved comments.
Comment #20
klausiPrivate files were moved to settings.php in #2170235: file_private_path should be in $settings, like file_public_path, looks like that got lost when BrowserTestBase was created or we forgot to update.
Comment #21
klausiFixed use statements discovered when working on #2735199: Convert web tests to browser tests for help module.
Comment #22
dawehnerI left a big review in
https://www.drupal.org/node/2735199. Here is a start of that:Comment #23
klausiShould be indented 2 spaces on the second line. What are the wrapped methods you are referring to? I think the comment should be "Use methods of the WebAssert class instead, for example @code $this->assertSession()->statusCodeEquals(200); @endcode".
this method is not deprecated, so it should not be on the legacy trait.
I think this should be $this->assertSession()->elementExists(), because people don't know where $assert is coming from.
$message is unused here and should be removed.
$message is unused here and should be removed.
this should have a comment why we override the parent method. The more I think of it the more I don't like that we override assertEquals like that. It changes the meaning of the assert. Instead, I think we should fix all the invocations where we convert to string beforehand.
why is that overridden from the parent class? Please add a comment.
Comment #24
klausidoes not bleong on the legacy assert trait.
Let's keep this patch small by only adding the legacy assertion trait and not making any modifications to our Webassert class, we don't need it for this particular issue where we just fix StandardTest.
Comment #25
dawehner@klausi
Do you agree with the general idea?
Comment #26
klausiyes, I agree that we can expand WebAssert.php with useful helper methods. Thanks for your work on that and the idea! Can you move it to a separate issue?
Comment #27
dawehner@klausi
Thank you for your review btw.
Mh, so you would commit your latest commit as it is. To be honest I'm not sure which of the conversions actually is kinda the root, aka. the one which introduces the BrowserAssertTrait. Its tricky to introduce something, as people might use it, when we remove it again.
Comment #28
klausiI think this issue should introduce the assertion trait - and I like your name LegacyAssertTrait a lot more, because we should really be deprecating those assert methods and rely more on mink standard assertions. We don't have to maintain those, which means less code and less mistakes we can make.
Comment #29
dawehnerGreat improvement!
I hope its okay to add the documentation to KernelTestBase as well, where I got the code from.
* The parent method is overridden because its a private method.:(
It already isn't, see your bit.
Comment #30
klausiAlmost ready, this looks fluffy good!
pass() should not be empty, it should have an always true assertion. Otherwise PHPUnit will complain about a risky test if the test does not contain any other assertion.
I wonder if we should deprecate the usage of pass() as well. Since we are unsure and you did not deprecate this method let's move it to BrowserTestBase.
Comment #31
dawehnerTurns out, the other legacy trait already has the pass method.
Comment #32
klausiGreat, another round of nitpicks now that we have to keep the assert() method.
"its" should be "it is"
@param description should end with dots.
Description should start with a capital letter.
Comment #33
klausiThis is not a failure message, it is an assertion message. "The assertion message describing the condition."
Comment #34
dawehnerThank you!
Comment #35
klausiLooks good, assuming the testbot agrees.
Comment #36
alexpottSo this is doing way more than the issue title suggests - it's expanding BrowserTestBase's surface area to include legacy assertions. I think this is a good idea and will make conversion go much quicker - as shown by the conversion of StandardTest - but we need to be honest about what the issue is doing and why.
Comment #37
alexpottLet's go for
$this->containerhere. More future proof and encourages us to always make sure the container is up to date.Comment #38
dawehnerBetter title first
Comment #39
dawehnerComment #40
klausiRemoved the \Drupal usage in the new config() method, improved issue summary.
Comment #41
dawehnerThank you klausi!
Comment #42
klausiJust hiding some files.
Comment #43
alexpottCommitted 0d9a9c9 and pushed to 8.1.x and 8.2.x as this is opens up the possibility of converting tests to BrowserTestBase easily and divergence in 8.1.x and 8.2.x test infra is undesirable. Thanks!
Comment #46
pfrenssenThis is causing the BrowserTestBase tests in OG to fail, seemingly because the
assertLink()method is public instead of protected. Created followup: #2744089: Fix visibility of AssertLegacyTrait::assertLink().Comment #47
neclimdulCan I get a quick explanation of why this was changed as part of this issue so I can make the correct fix to #2735235: BrowserTestBase standards cleanup. I don't see any discussion and I don't see any uses of it or ::drupalLogin in the patch so its not clear.
Comment #48
klausiWe need AccountInterface because the following line should work:
$this->rootUser is created as UserSession in installDrupal().
Comment #49
klausiAnd $this->drupalLogin($this->rootUser); usage was discovered in #2735199: Convert web tests to browser tests for help module and ported to this issue.
Comment #51
effulgentsia commentedEven though this was also cherry picked to 8.1, I think it's worth mentioning in the 8.2.0 release notes.
Comment #52
gábor hojtsyWent back to 8.1, so moving accordingly.