Problem/Motivation

Two problems:

1) Unit test requires a database

Running TestSiteApplicationTest in isolation reveals that it errors out.

That's because it uses the SIMPLETEST_DB environmental variable, which is intended for use by KernelTestBase tests.

$ ./vendor/bin/phpunit -c core/ --testsuite unit --filter TestSiteApplicationTest
PHPUnit 6.5.8 by Sebastian Bergmann and contributors.

Testing 
EEESS.                                                              6 / 6 (100%)

Time: 17.01 seconds, Memory: 136.00MB

There were 3 errors:

1) Drupal\Tests\Scripts\TestSiteApplicationTest::testInstallWithNonExistingFile
InvalidArgumentException: Minimum requirement: driver://host/database

/Users/paulmitchum/projects/drupal8/core/lib/Drupal/Core/Database/Database.php:460
/Users/paulmitchum/projects/drupal8/core/tests/Drupal/Tests/Scripts/TestSiteApplicationTest.php:267
/Users/paulmitchum/projects/drupal8/core/tests/Drupal/Tests/Scripts/TestSiteApplicationTest.php:47

This can be mitigated by setting the SIMPLETEST_DB variable in phpunit.xml, but this ruins the isolation between unit and kernel tests.

2) This test is never run by run-tests.sh

Since it lives in core/tests/Scripts, the test is not discovered when run-tests.sh runs tests.

You can see evidence of this in this recent HEAD test. See the actual tests that were run which does not include TestSiteApplicationTest: https://dispatcher.drupalci.org/job/php7_mysql5.5/5506/artifact/jenkins-...

Versus the test list generated for that same build which lists TestSiteApplicationTest: https://dispatcher.drupalci.org/job/php7_mysql5.5/5506/artifact/jenkins-...

Here's an issue about fixing that discrepancy: #2878269: Modify TestDiscovery so the testbot runs all the tests

Proposed resolution

#2878269: Modify TestDiscovery so the testbot runs all the tests is in, so the test has been running.

Convert the test to the new build test framework. This takes it out of the unit testsuite, which helps avoid the need for a database. Also, this test case is much better suited to a build test which can modify the file system to perform site installs in isolation.

This includes changing \Drupal\BuildTests\Framework\BuildTestBase::executeCommand to use env variable 'COLUMNS' set to PHP_INT_MAX, so that the command output is one line. This allows assertions on the text to work as one would expect.

Remaining tasks

Review
Commit

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#118 2962157-118.patch19.57 KBgauravvvv
#116 2962157-nr-bot.txt86 bytesneeds-review-queue-bot
#112 2962157-112.patch20.99 KBquietone
#112 interdiff-109-112.txt755 bytesquietone
#109 2962157-109.patch21 KBquietone
#109 interdiff-108-109.txt1.22 KBquietone
#108 2962157-108.patch22.31 KBquietone
#108 interdiff-105-108.txt1.08 KBquietone
#105 2962157-105.patch22.44 KBquietone
#105 interdiff-103-105.txt2.19 KBquietone
#103 2962157-103.patch20.92 KBquietone
#103 diff-88-103.txt3.78 KBquietone
#96 2962157-96.patch19.95 KBdhirendra.mishra
#96 interdiff_88-96.txt842 bytesdhirendra.mishra
#94 2962157-94.patch846 bytesdhirendra.mishra
#91 2962157-91.patch16 KBdhirendra.mishra
#91 interdiff_88_91.txt14.29 KBdhirendra.mishra
#88 2962157-88.patch19.88 KBquietone
#88 interdiff-86-88.txt1.25 KBquietone
#86 2962157-86.patch19.88 KBquietone
#86 diff-82-86.txt232 bytesquietone
#82 interdiff.2962157.80-82.txt480 byteslongwave
#82 2962157-82.patch19.87 KBlongwave
#80 2962157-80.patch19.87 KBanushrikumari
#70 interdiff.txt23.99 KBmile23
#70 2962157_70.patch19.45 KBmile23
#67 2962157_67.patch9.74 KBmile23
#57 2962157-57.patch664 bytesneclimdul
#57 2962157-57.interdiff.txt507 bytesneclimdul
#55 2962157-55.patch311 bytesneclimdul
#49 2962157_49.patch12.75 KBneclimdul
#49 2962157_49.interdiff.txt2.03 KBneclimdul
#48 2962157_48.interdiff.txt41.62 KBneclimdul
#48 2962157_48.patch52.33 KBneclimdul
#44 interdiff.txt687 bytesmile23
#44 2962157_44.patch12.77 KBmile23
#37 interdiff.txt2.15 KBmile23
#37 2962157_37.patch12.41 KBmile23
#34 interdiff.txt750 bytesmile23
#34 2962157_34.patch12.63 KBmile23
#31 2962157-30.patch12.66 KBalexpott
#31 20-30-interdiff.txt5.16 KBalexpott
#27 interdiff.txt5.48 KBmile23
#27 2962157_27.patch9.87 KBmile23
#24 interdiff.txt3.8 KBmile23
#24 2962157_24.patch14.04 KBmile23
#20 2962157-20.patch13.58 KBalexpott
#20 16-20-interdiff.txt6.37 KBalexpott
#16 interdiff.txt4.52 KBmile23
#16 2962157_15.patch9.63 KBmile23
#13 2962157-13.patch7.54 KBalexpott
#13 11-13-interdiff.txt4.98 KBalexpott
#11 2962157-11.patch3.75 KBalexpott
#11 9-11-interdiff.txt0 bytesalexpott
#9 2962157-9.patch3.75 KBalexpott
#9 4-9-interdiff.txt5.17 KBalexpott
#4 interdiff.txt2.56 KBmile23
#4 2962157_4.patch5.96 KBmile23
#3 2962157_3.patch4.52 KBmile23

Comments

Mile23 created an issue. See original summary.

alexpott’s picture

Let's just mark the test skipped if it is not present. If we want to test our test infrastructure we need to allow these types of tests.

mile23’s picture

Title: TestSiteApplicationTest requires SIMPLETEST_DB despite being a unit test » TestSiteApplicationTest requires a database despite being a unit test
Status: Active » Needs review
StatusFileSize
new4.52 KB

Thanks.

This gets back to #2242947-111: Integrate Symfony Console component to natively support command line operations and #2242947-96: Integrate Symfony Console component to natively support command line operations: We really need a base class for this kind of stuff. It can't be a KernelTestBase test, but we also shouldn't reinvent the wheel every time.

Since we're normalizing on symfony/console, we could use their app tester for many things. We can also follow the example of the testbot: https://cgit.drupalcode.org/drupalci_testbot/tree/tests/DrupalCI/Tests/D...

Also, we have to be careful with the results of this patch's test runs, because we don't yet have #2905007: Allow run-tests.sh to report skipped/incomplete PHPUnit tests

But that's all out of scope here.

mile23’s picture

StatusFileSize
new5.96 KB
new2.56 KB

OK, so the last test didn't run TestSiteApplicationTest.

But then again neither did HEAD.

That's because of the long-standing false-positive bug: #2878269: Modify TestDiscovery so the testbot runs all the tests

I only found the bug this issue addresses because I used phpunit and not run-tests.sh.

This leaves us with two options: Fix the real bug that fooled core maintainers when they committed TestSiteApplicationTest, or just move TestSiteApplicationTest to Drupal\Tests\Core\Scripts.

The patch here moves the test with a @todo about moving it back when #2878269: Modify TestDiscovery so the testbot runs all the tests is fixed.

Status: Needs review » Needs work

The last submitted patch, 4: 2962157_4.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

mile23’s picture

I can't repro the fails, so I think it's some state left over from initializing the db on the testbot.

Also, run-tests.sh can't report skipped tests so I'm left guessing if the tests passed or skipped locally when they should skip (3 seconds is a short time.. I guess.) #2905007: Allow run-tests.sh to report skipped/incomplete PHPUnit tests

mile23’s picture

mile23’s picture

Issue summary: View changes
alexpott’s picture

Status: Needs work » Needs review
StatusFileSize
new5.17 KB
new3.75 KB

Nice find @Mile23 and woah not fair testbot.

Status: Needs review » Needs work

The last submitted patch, 9: 2962157-9.patch, failed testing. View results

alexpott’s picture

Status: Needs work » Needs review
StatusFileSize
new0 bytes
new3.75 KB

So the counts in the tests where we're not doing an install are impossible in a concurrent test env where the db is shared so lets remove them.

Status: Needs review » Needs work

The last submitted patch, 11: 2962157-11.patch, failed testing. View results

alexpott’s picture

Status: Needs work » Needs review
StatusFileSize
new4.98 KB
new7.54 KB

What #11 should have been.

Status: Needs review » Needs work

The last submitted patch, 13: 2962157-13.patch, failed testing. View results

alexpott’s picture

Status: Needs work » Needs review
StatusFileSize
new697 bytes
new7.9 KB

More instrumentation.

mile23’s picture

StatusFileSize
new9.63 KB
new4.52 KB

Moves tests of TestSiteInstallCommand to TestSiteInstallCommandTest where they're unit tested and don't require SIMPLETEST_DB or separate processes.

Note that we have to use vfsStream to work around an almost-bug in the installer command where it can only evaluate files that haven't loaded yet.

Will need to add in the changes from #15.

edit: Didn't mean to hide any files... d.o did that.

The last submitted patch, , failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 16: 2962157_15.patch, failed testing. View results

alexpott’s picture

#15 was about finding out what was wrong! No need to include that :)

alexpott’s picture

Status: Needs work » Needs review
StatusFileSize
new6.37 KB
new13.58 KB

This might fix it.

mile23’s picture

Moving all the dependencies to setUp() is the best solution.

RTBC from me, but I contributed code.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

RTBC++

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 20: 2962157-20.patch, failed testing. View results

mile23’s picture

Status: Needs work » Needs review
StatusFileSize
new14.04 KB
new3.8 KB

Yay, preventing technical debt by not taking out the loan! Pretty sure this fail is coming off of #2961691: Change SYMFONY_DEPRECATIONS_HELPER back to strict

Remaining deprecation notices (7)

  7x: Not inheriting environment variables is deprecated since Symfony 3.3 and will always happen in 4.0. Set "Process::inheritEnvironmentVariables()" to true instead.
    4x in TestSiteApplicationTest::testInstallScript from Drupal\Tests\Core\Scripts
    2x in TestSiteApplicationTest::testInstallInDifferentLanguage from Drupal\Tests\Core\Scripts
    1x in TestSiteApplicationTest::testTearDownDbPrefixValidation from Drupal\Tests\Core\Scripts

It seems that passing the environmental array to Process::run() is the way to go, rather than during construction.

alexpott’s picture

Status: Needs review » Needs work

Why not just call inheritEnvironmentVariables() like it tells us to?

The additional env variables for start and run are just when you want to change the default environment you've set it up with. Constructing and running with the same $env is wrong.
See https://github.com/symfony/symfony/blob/bb4bde3bba9a8f8cd209855cb5589d10...
and https://github.com/symfony/symfony/blob/bb4bde3bba9a8f8cd209855cb5589d10...

alexpott’s picture

+++ b/core/tests/Drupal/Tests/Core/Scripts/TestSiteApplicationTest.php
@@ -183,14 +142,15 @@ public function testInstallScript() {
+    $process = new Process($command_line, $this->root, $this->env);
     // Set the timeout to a value that allows debugging.
     $process->setTimeout(500);
-    $process->run();
+    $process->run(NULL, $this->env);

The other option here is to not pass $this->env to the constructor. But personally I don't like looking at $process->run(NULL, $this->env);. But's that's a taste thing.

mile23’s picture

Status: Needs work » Needs review
StatusFileSize
new9.87 KB
new5.48 KB

Why not just call inheritEnvironmentVariables() like it tells us to?

Well, ostensibly $this->env is there for a reason, so we shouldn't inherit environment variables. However, looking at setUp() I see it isn't there for a reason. It only copies SIMPLETEST_BASE_URL if it exists, which will be sent to the child process anyway.

So here we remove $this->env and act like it never existed.

alexpott’s picture

@Mile23 I think we'll find this is not that simple because of how PHPUnit.xml.dist configures environment variables especially in PHPUnit 4.

mile23’s picture

Fails under PHPUnit 6 anyway.

17:52:25 Drupal\Tests\Core\Scripts\TestSiteApplicationTest              0 passes   1 fails

I'm out for the afternoon so if you feel inspired...

Status: Needs review » Needs work

The last submitted patch, 27: 2962157_27.patch, failed testing. View results

alexpott’s picture

Status: Needs work » Needs review
StatusFileSize
new5.16 KB
new12.66 KB

So looking at Process again here's a patch that just passes the environment on to Process::run() I'm not a huge fan of $process->run(NULL, $this->env); but calling Process::inheritEnvironmentVariables() also seems silly because in symfony 4 that method is totally redundant. So this feels the best way to not use deprecated functionality.

mile23’s picture

Status: Needs review » Reviewed & tested by the community

I feel safe with RTBC-ing this issue even though I contributed because it's a superficial change after @borrison_'s RTBC in #22.

Running the testbot at PHP 5.5 which should un-RTBC if it fails.

mile23’s picture

Status: Reviewed & tested by the community » Needs work

PHP 5.5 says:

17:57:04 Drupal\Tests\Core\Scripts\TestSiteInstallCommandTest           0 passes   1 fails    

/frownyface

mile23’s picture

Status: Needs work » Needs review
StatusFileSize
new12.63 KB
new750 bytes

The error log says:

> Drupal\Core\Composer\Composer::upgradePHPUnit
PHP Fatal error:  Call to undefined method Drupal\Tests\Core\Scripts\TestSiteInstallCommandTest::expectException() in /var/www/html/core/tests/Drupal/Tests/Core/Scripts/TestSiteInstallCommandTest.php on line 43

So therefore we need the compatibility layer.

Anonymous’s picture

Status: Needs review » Reviewed & tested by the community

PHP 5.5 problem fixed. So back to RTBC again.

larowlan’s picture

Status: Reviewed & tested by the community » Needs review
  1. +++ b/core/tests/Drupal/Tests/Core/Scripts/TestSiteApplicationTest.php
    @@ -262,13 +226,16 @@ public function testTearDownDbPrefixValidation() {
    -    $target = __CLASS__ . $db_prefix;
    -    Database::addConnectionInfo($target, 'default', $database);
    -    return $target;
    +    $key = __CLASS__ . $db_prefix;
    +    Database::addConnectionInfo($key, 'default', $database);
    +    return $key;
    

    out of scope/merge conflict?

  2. +++ b/core/tests/Drupal/Tests/Core/Scripts/TestSiteInstallCommandTest.php
    @@ -0,0 +1,51 @@
    +      'non-existing-file' => ['The file this-class-does-not-exist does not exist.', 'this-class-does-not-exist'],
    +      'no-class' => ['The file core/tests/fixtures/empty_file.php.module does not contain a class', 'core/tests/fixtures/empty_file.php.module'],
    +      'non-setup-class' => ["The class $class contained in $file needs to implement \\$interface", $file],
    

    phpcs nit: these should be wrapped because > 80

mile23’s picture

StatusFileSize
new12.41 KB
new2.15 KB

Thanks!

All the changes from #36.

Anonymous’s picture

Status: Needs review » Reviewed & tested by the community

Probably not the best time for RTBC (while all test runs fail). But anyway.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 37: 2962157_37.patch, failed testing. View results

mile23’s picture

Status: Needs work » Reviewed & tested by the community

@mixologic put out the fire, so we can go back to RTBC.

neclimdul’s picture

Issue tags: +PHPUnit

Explains why I can't test core with phpunit.

neclimdul’s picture

Coming back to this, why isn't it just moving the test into the kernel namespace where the database requirement is explicit? No unit tests should require a database even if one exists. That's the core of the test suite separation.

alexpott’s picture

Another "core of the test separation" is that kerneltest etc... install Drupal for you. Using a unit test allows us to prove that this CLI command has 0 dependency on a Drupal-ized test environment.

mile23’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new12.77 KB
new687 bytes

Added that conversation to the docblock.

neclimdul’s picture

not convert it to a kernel test, move it to the kernel namespace. i.e. put it in the kernel test suite.

neclimdul’s picture

Not sure what's going on but I've run out of ideas for debugging this. Surely something archaic.

Locally I can run the tests in the patch just fine. Tried with ubuntu's php, official php containers, and Lando's containers and its fine. On a server I use for automated patch testing though I consistently get the following error for both php 7.2 and php 5.6. Same command that's roughly just php ./vendor/bin/phpunit -c ./core --testsuite unit

1) Drupal\Tests\Core\Scripts\TestSiteInstallCommandTest::testSetupFile with data set "non-setup-class" ('The class Drupal\Test\Fixture...erface', 'vfs://test/FixtureSetupFileClass.php')
Failed asserting that exception message 'The file vfs://test/FixtureSetupFileClass.php does not exist.' contains 'The class Drupal\Test\FixtureSetupFileClass contained in vfs://test/FixtureSetupFileClass.php needs to implement \Drupal\TestSite\TestSetupInterface'.
neclimdul’s picture

Status: Needs review » Needs work

going to NW this since its failing for me. Going to see if I can isolate what is special about the environment its failing in but any ideas would be appreciated.

neclimdul’s picture

Status: Needs work » Needs review
StatusFileSize
new52.33 KB
new41.62 KB

Spent a lot of time going down rabbit holes thinking it might be something directory related because jenkins does some weird directory names which lead me to figure out #2979150: vfs: directory created during unit tests finally but it wasn't. It was PhpUnit 6 causing this issue, seems providers run different and the VFS trick wasn't working.

Split the VFS test to a separate test.

neclimdul’s picture

StatusFileSize
new2.03 KB
new12.75 KB

bah, accidentally included the phpunit 6 composer change in that patch. sorry.

mile23’s picture

+1.

My only nit is:

+++ b/core/tests/Drupal/Tests/Core/Scripts/TestSiteApplicationTest.php
@@ -208,13 +168,16 @@ public function testInstallInDifferentLanguage() {
     $this->assertEquals(0, $process->getExitCode());

There are a bunch of these with no message. I suggest adding $process->getErrorOutput() as a message because it's a pain figuring out whether you're reviewing a failing test or a misconfigured local dev environment. :-)

I'd RTBC if I hadn't contributed code.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

RTBC based on #50, I don't think the problem with the misconfigured env will be a big problem, as that will make other tests fail as well.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/tests/Drupal/Tests/Core/Scripts/TestSiteApplicationTest.php
@@ -208,13 +168,16 @@ public function testInstallInDifferentLanguage() {
+    if (!getenv('SIMPLETEST_BASE_URL')) {
+      $this->markTestSkipped('This test requires the environment variable SIMPLETEST_BASE_URL to set. See core/phpunit.xml.dist.');
+    }

@@ -232,10 +195,11 @@ public function testInstallInDifferentLanguage() {
+    $this->assertEquals([], Database::getConnection('default', $this->addTestDatabase($db_prefix))->schema()->findTables('%'));
     $this->assertCount(0, Database::getConnection('default', $this->addTestDatabase($db_prefix))->schema()->findTables('%'));

@@ -262,6 +226,9 @@ public function testTearDownDbPrefixValidation() {
+   * @throws \SkippedTestError
+   *   Thrown if SIMPLETEST_DB environmental variable is not set.

Now everything is in setUp() how about we remove the other places we skip. Less stuff to maintain. Also I think this patch would be simpler just to add the new setUp().

For me there's way too many different unrelated things going on in the same patch.

  • Splitting tests out.
  • Moving stuff to VFS
  • Adding new assertions - that sure make sense but should replace the $this->assertCount()
neclimdul’s picture

A good point. Also, we don't currently skip l tests that require SIMPLETEST_X, we fail. That's something I've been trying to fix for a long long time now. #2714555: Regression in SIMPLETEST environment skipping

Why aren't we just moving this to the functional test suite that requires a database connection? This is a functional test after all.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

neclimdul’s picture

Status: Needs work » Needs review
StatusFileSize
new311 bytes

maybe? simplest solution for now.

Status: Needs review » Needs work

The last submitted patch, 55: 2962157-55.patch, failed testing. View results

neclimdul’s picture

Status: Needs work » Needs review
StatusFileSize
new507 bytes
new664 bytes

derp... have to change the namespace. Wish the Test Bot error was better when the class doesn't match the file...

Status: Needs review » Needs work

The last submitted patch, 57: 2962157-57.patch, failed testing. View results

mile23’s picture

It's actually a functional test, if we're just going to put it in a different namespace.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

neclimdul’s picture

Took another look at this and I think the failures are just that this test is broken.

Specifically there is this code at the top of the test:

    $simpletest_path = $this->root . DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . 'simpletest';
    if (!is_writable($simpletest_path)) {
      $this->markTestSkipped("Requires the directory $simpletest_path to exist and be writable");
    }

And we see testbot creating and granting permissions to the simpletest directory after unit tests and moving into kernel tests.

14:48:52 ---------------- Finished run_tests.phpunit in 92.005 seconds ---------------- 
14:48:52 ----------------   Starting run_tests.kernel   ----------------
14:48:52 Directory created at /var/lib/drupalci/workspace/jenkins-php-7.2-apache_mysql5.5-3824/ancillary/run_tests.kernel
14:48:52 mkdir -p /var/www/html/sites/simpletest/xml
14:48:52 chown -fR www-data:www-data /var/www/html/..

To confirm this I setup all the SIMPLETEST requirements locally and ran the test without the patch and it failed exactly the same way.

mile23’s picture

I think we might be able to move this test to a build test after #3031379: Add a new test type to do real update testing

neclimdul’s picture

Even if that would be a better place, the test can run just fine in the kernel suite as demonstrated by the failures actually catching the broken test. There's no reason to block this imho.

mile23’s picture

After #2878269: Modify TestDiscovery so the testbot runs all the tests TestSiteApplicationTest is marked as incomplete, leading to this issue.

We have #3031379: Add a new test type to do real update testing in the works, but it seems to have run out of momentum.

So we need to: a) Fix this test so it passes, since it hasn't been running under the testbot since it was committed to core. b) Figure out how to mitigate the need for a database and other such dependencies.

andypost’s picture

Maybe add getDatabaseStub() to \Drupal\Tests\UnitTestCase (there's already few stub methods)
In related issue this particular test is not covered

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

mile23’s picture

Status: Needs work » Needs review
StatusFileSize
new9.74 KB

I converted some of the methods on TestSiteApplicationTest to be build tests. I was also curious if testUserLogin() fails on the testbot because I couldn't repro a fail locally.

andypost’s picture

Status: Needs review » Needs work

The last submitted patch, 67: 2962157_67.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

mile23’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs issue summary update
StatusFileSize
new19.45 KB
new23.99 KB

Finishes the conversion to build test.

testUserLogin() is still marked incomplete, linking to #2949229: SQLite findTables Returns Empty Array on External DB., only because @andypost mentioned it. Might need a different follow-up.

If you remove the markTestIncomplete() line, and also comment out the 'Set-Cookie' line, testUserLogin() will pass, probably with a false positive.

Interdiff included for completeness, but it's much easier to review the patch.

mile23’s picture

See also: #2905007: Allow run-tests.sh to report skipped/incomplete PHPUnit tests

That change would allow us to see that this test is marked incomplete.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

andypost’s picture

longwave’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

#70 no longer applies to 9.1.x.

msuthars’s picture

Assigned: Unassigned » msuthars

Working on it.

msuthars’s picture

Assigned: msuthars » Unassigned

@andypost Thanks for the info. Will re-roll after that.

anushrikumari’s picture

Assigned: Unassigned » anushrikumari
anushrikumari’s picture

Assigned: anushrikumari » Unassigned
Status: Needs work » Needs review
StatusFileSize
new19.87 KB

Rerolled the patch for 9.1.x
Please review

Status: Needs review » Needs work

The last submitted patch, 80: 2962157-80.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

longwave’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new19.87 KB
new480 bytes

Strange, can't reproduce this same fail locally - the error output is the same as the expected message. However the output seems to depend on the window width, as the second assertion fails for me - the formatting breaks the message in a different place.

Fixing the coding standards issue, let's see what happens here.

Status: Needs review » Needs work

The last submitted patch, 82: 2962157-82.patch, failed testing. View results

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new232 bytes
new19.88 KB

Rerolled.

Locally (ddev) I get the error reported in #82.

daffie’s picture

Status: Needs review » Needs work
Issue tags: +Novice

There are some PHPCBF errors with the patch that need to be fixed. For that only is the issue for a novice.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new1.25 KB
new19.88 KB

I have been forgetting to run commit-code-check lately,

Status: Needs review » Needs work

The last submitted patch, 88: 2962157-88.patch, failed testing. View results

dhirendra.mishra’s picture

Assigned: Unassigned » dhirendra.mishra

I am working on it

dhirendra.mishra’s picture

Assigned: dhirendra.mishra » Unassigned
Status: Needs work » Needs review
StatusFileSize
new14.29 KB
new16 KB

PFA files,

longwave’s picture

Status: Needs review » Needs work

The patch just deletes a test now, this isn't right.

dhirendra.mishra’s picture

Assigned: Unassigned » dhirendra.mishra

Oh...thanks..Let me re-work on this

dhirendra.mishra’s picture

Assigned: dhirendra.mishra » Unassigned
Status: Needs work » Needs review
StatusFileSize
new846 bytes
longwave’s picture

Status: Needs review » Needs work

This still isn't right, I think we need to start again from #88.

dhirendra.mishra’s picture

Status: Needs work » Needs review
StatusFileSize
new842 bytes
new19.95 KB

Kindly ignore my previous patches.
I believe this time it will be helpful.

Status: Needs review » Needs work

The last submitted patch, 96: 2962157-96.patch, failed testing. View results

mradcliffe’s picture

Issue tags: -Novice

I am removing the Novice tag from this issue because I do not think this is a good Novice issue anymore based on @daffie's comments.

Also interestingly, this might be why I ran into issues trying to write tests for #2894476: [PP-1] Provide commands which are helpful for core development.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Status: Needs work » Needs review
Related issues: +#3082230: [meta] Convert some tests to Build tests
StatusFileSize
new3.78 KB
new20.92 KB

Just a reroll. I started from #88 because of comment #95 and the latest patch, #96, is adding an interface without explanation.

Status: Needs review » Needs work

The last submitted patch, 103: 2962157-103.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new2.19 KB
new22.44 KB

The failing test is testInstallWithNonSetupClass which I take to mean a test script without a setup method. So, I made such a class and used that in the test. That avoided the error message about The class SebastianBergmann\Version and gave instead one about the new test class. But the assertions were failing because the command output gets outputs with a small width. To get around that I changed \Drupal\BuildTests\Framework\BuildTestBase::executeCommand to use a width of PHP_INT_MAX (as in the original test) and now the test passes.

andypost’s picture

spokje’s picture

Status: Needs review » Needs work

This looks really great!

Ony tiny nit I stumbled over whilst doing a review:

--- a/core/tests/Drupal/Tests/Scripts/TestSiteApplicationTest.php
+++ b/core/tests/Drupal/BuildTests/Scripts/TestSiteApplicationTest.php
@@ -22,11 +19,13 @@
  * @runTestsInSeparateProcesses
  * @preserveGlobalState disabled
  *
+ * @requires externalCommand composer

[snipped]

@@ -49,35 +58,40 @@ protected function setUp(): void {
    * @coversNothing
    */
   public function testInstallWithNonExistingFile() {
+    $this->copyCodebase();
+    $this->executeCommand('composer install');
 
     // Create a connection to the DB configured in SIMPLETEST_DB.
     $connection = Database::getConnection('default', $this->addTestDatabase(''));
     $table_count = count($connection->schema()->findTables('%'));
 
     $command_line = $this->php . ' core/scripts/test-site.php install --setup-file "this-class-does-not-exist" --db-url "' . getenv('SIMPLETEST_DB') . '"';
-    $process = Process::fromShellCommandline($command_line, $this->root);
-    $process->run();
+    $this->executeCommand($command_line);
+
+    $this->assertErrorOutputContains('The file this-class-does-not-exist does not exist.');
+    $this->assertCommandExitCode(1);
 
-    $this->assertStringContainsString('The file this-class-does-not-exist does not exist.', $process->getErrorOutput());
-    $this->assertSame(1, $process->getExitCode());
     $this->assertCount($table_count, $connection->schema()->findTables('%'), 'No additional tables created in the database');
   }
 
   /**
+   * @requires externalCommand composer

We removed the use of @requires externalCommand in #3362083: '@requires externalCommand' is not parsed in PHPUnit 10 since it will be dropped in PHPUnit 10.

By the looks of it the two occurrences of this can be safely removed from the patch.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new1.08 KB
new22.31 KB

@Spokje, thanks!

I have removed the two lines per #107. I also sorted the 'use' statements.

quietone’s picture

Issue summary: View changes
StatusFileSize
new1.22 KB
new21 KB

Restore drupalci

spokje’s picture

Status: Needs review » Reviewed & tested by the community

Thanks @quietone, for me the changes look good now, let's see what Yer Fellow Core Commiters think, RTBC.

longwave’s picture

Status: Reviewed & tested by the community » Needs review
+++ b/core/tests/Drupal/BuildTests/Scripts/TestSiteApplicationTest.php
@@ -237,32 +237,28 @@ public function testInstallInDifferentLanguage() {
+    $this->markTestIncomplete('Fix this test as part of https://www.drupal.org/project/drupal/issues/2949229');

If this test is a false positive due to #2949229: SQLite findTables Returns Empty Array on External DB....

+++ b/core/tests/Drupal/BuildTests/Scripts/TestSiteApplicationTest.php
@@ -49,17 +56,19 @@ protected function setUp(): void {
     $this->assertCount($table_count, $connection->schema()->findTables('%'), 'No additional tables created in the database');

...don't other tests here that assert the number of tables have the same problem?

If this is SQLite only should we just skip these all these tests on SQLite?

quietone’s picture

StatusFileSize
new755 bytes
new20.99 KB

Here is the result of my research.

First, in this issue findTables is used successfully.

+++ b/core/tests/Drupal/BuildTests/Scripts/TestSiteApplicationTest.php
@@ -85,52 +96,52 @@ public function testInstallWithFileWithNoClass() {
     $this->assertGreaterThan(0, count(Database::getConnection('default', $key)->schema()->findTables('%')));

So skipping issues based on that is not right.

The skip in testUserLogin was first added in #2878269: Modify TestDiscovery so the testbot runs all the tests, where it pointed to this issue.

public function testUserLogin() {
     +    $this->markTestIncomplete('Fix this test in https://www.drupal.org/project/drupal/issues/2962157.');

That was changed in #70 changed it to point to #2949229: SQLite findTables Returns Empty Array on External DB.. But that testUserLogin does not use findTables, so that is the wrong message. There are two todos later in the test which explain that testing user login can't be done successfully. And local testing confirms that the test fails when testing the user login.

Therefore, I have made a new issue for fixing the userLogin test and updated the markTestIncomplete message accordingly.

Status: Needs review » Needs work

The last submitted patch, 112: 2962157-112.patch, failed testing. View results

longwave’s picture

Status: Needs work » Needs review

Random fail? in QuickStartTest, requeued.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Tests are all green. was previously RTBC in 110 and the feedback from 111 appears to be addressed from what I can tell. Going to remark it.

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new86 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

kostyashupenko’s picture

Issue tags: +Needs reroll
gauravvvv’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new19.57 KB

Rerolled patch #112, as it no longer applies. Removed needs-roll tag. please review

Status: Needs review » Needs work

The last submitted patch, 118: 2962157-118.patch, failed testing. View results

larowlan’s picture

Priority: Normal » Major

This is making things harder for us on gitlab CI

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.