Sub task to focus on just the tests provided by the system module.

CommentFileSizeAuthor
#56 interdiff.txt1.27 KBcatch
#56 2687897-56.patch116.69 KBcatch
#53 convert_system_module_s-2687897-53.patch116.37 KBjibran
#53 interdiff.txt690 bytesjibran
#49 interdiff.txt697 bytesdawehner
#49 2687897-49.patch116.68 KBdawehner
#45 interdiff.txt854 bytesdawehner
#45 2687897-45.patch116.59 KBdawehner
#43 interdiff.txt5.05 KBdawehner
#43 2687897-43.patch116.39 KBdawehner
#41 interdiff.txt6.6 KBdawehner
#41 2687897-41.patch121.46 KBdawehner
#39 interdiff.txt8.73 KBdawehner
#39 2687897-39.patch116.96 KBdawehner
#37 interdiff.txt1.22 KBdawehner
#37 2687897-37.patch112.46 KBdawehner
#34 2687897-30.patch138.19 KBdawehner
#30 interdiff.txt2.51 KBdawehner
#30 2687897-30.patch90.93 KBdawehner
#29 interdiff.txt371 bytesdawehner
#29 2687897-29.patch90.81 KBdawehner
#27 interdiff.txt6.16 KBdawehner
#27 2687897-27.patch90.83 KBdawehner
#24 2687897-24.patch96.66 KBdawehner
#24 interdiff.txt608 bytesdawehner
#22 interdiff.txt47.44 KBdawehner
#22 2687897-22.patch96.53 KBdawehner
#20 interdiff.txt13.35 KBdawehner
#20 2687897-20.patch86.79 KBdawehner
#16 2687897-16.patch89.7 KBjhedstrom
#16 interdiff.txt17.37 KBjhedstrom
#15 interdiff.txt941 bytesdawehner
#15 2687897-15.patch72.32 KBdawehner
#13 2687897-13.patch71.72 KBjhedstrom
#13 interdiff.txt8.05 KBjhedstrom
#12 2687897-12.patch63.67 KBjhedstrom
#12 interdiff.txt685 bytesjhedstrom
#9 2687897-09.patch63.58 KBjhedstrom
#9 interdiff.txt1.44 KBjhedstrom
#8 2687897-08.patch62.13 KBjhedstrom
#8 interdiff.txt14.57 KBjhedstrom
#6 2687897-06.patch47.57 KBjhedstrom
#6 interdiff.txt11.53 KBjhedstrom
#5 2687897-05.patch36.03 KBjhedstrom
#5 interdiff.txt16.29 KBjhedstrom
#4 2687897-04.patch19.74 KBjhedstrom
#4 interdiff.txt7.08 KBjhedstrom
#3 2687897-02.patch19.83 KBjhedstrom

Comments

jhedstrom created an issue. See original summary.

berdir’s picture

Note, I'd recommend to consider moving any where we do not actually test system *module* stuff but components to move out of the module and into core/tests/....

I've done the same with the config component tests that are currently in the config module.

jhedstrom’s picture

Assigned: jhedstrom » Unassigned
Status: Active » Needs review
StatusFileSize
new19.83 KB

I'd already done what's here by the time I saw Berdir's comment, so next patch will move these out of the system module.

I started at the end of the list working backward. I had to skip Theme/StableLibraryOverrideTest because it calls enableModules() from setUp, which is deprecated, and I need to figure out the right way to do this w/o hard-coding the entire module list of core into the $modules variable.

jhedstrom’s picture

StatusFileSize
new7.08 KB
new19.74 KB

Wanted to get more time, but only managed to move some of the already-converted tests to the core/tests directory/namespace. Will try to get more done tomorrow. There is somewhat of a gray area on what should go in system module. I chose as a general rule to leave anything that enables the system module itself in the test.

jhedstrom’s picture

StatusFileSize
new16.29 KB
new36.03 KB

A few more moved/converted.

jhedstrom’s picture

StatusFileSize
new11.53 KB
new47.57 KB

A few more.

Status: Needs review » Needs work

The last submitted patch, 6: 2687897-06.patch, failed testing.

jhedstrom’s picture

Status: Needs work » Needs review
StatusFileSize
new14.57 KB
new62.13 KB

A few more. Odd failure above as that test wasn't touched by the patch...

jhedstrom’s picture

StatusFileSize
new1.44 KB
new63.58 KB

Ah, the fail was related since it was looking for one of the files that moved.

The last submitted patch, 8: 2687897-08.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 9: 2687897-09.patch, failed testing.

jhedstrom’s picture

Status: Needs work » Needs review
StatusFileSize
new685 bytes
new63.67 KB

This should fix the fail.

jhedstrom’s picture

StatusFileSize
new8.05 KB
new71.72 KB

This has one failure I can't quite figure out in the ExternalFormUrlTest.

Status: Needs review » Needs work

The last submitted patch, 13: 2687897-13.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new72.32 KB
new941 bytes

Yeah that one is super weird.

jhedstrom’s picture

StatusFileSize
new17.37 KB
new89.7 KB

This does all the file tests.

There are 4 or so failures. The mkdir permission failure is due to this in DirectoryTest:

    $absolute_path = drupal_realpath($directory) . DIRECTORY_SEPARATOR . $this->randomMachineName() . DIRECTORY_SEPARATOR . $this->randomMachineName();
    $this->assertTrue(drupal_mkdir($absolute_path, 0775, TRUE), 'No error reported when creating new absolute directories.', 'File');
 

The drupal_realpath() is failing for vfs (it returns something like /RANDOM/RANDOM.

The other failure from StreamWrapperTest I am not sure what to do about:

stream_select(): cannot represent a stream of type user-space as a select()able descriptor

Status: Needs review » Needs work

The last submitted patch, 16: 2687897-16.patch, failed testing.

berdir’s picture

Maybe we can make public:// work, see #31 in #2684141: Convert migrate kernel tests to KernelTestBaseTNG, not sure if the same applies here, though.

  1. +++ b/core/modules/system/tests/src/Kernel/File/DirectoryTest.php
    @@ -5,7 +5,7 @@
     
    -namespace Drupal\system\Tests\File;
    +namespace Drupal\Tests\system\Kernel\File;
    

    I think most of those tests are about testing FileSystem, which is in the core namespace or functions in include files.

    IMHO, those would be OK to move as well. entity tests for example also rely on system (and test modules in system.module).

  2. +++ b/core/modules/system/tests/src/Kernel/File/DirectoryTest.php
    @@ -82,7 +82,7 @@ function testFileCheckDirectoryHandling() {
           $this->assertFalse(file_prepare_directory($directory, 0), 'Error reported for a non-writeable directory.', 'File');
     
           // Test directory permission modification.
    -      $this->settingsSet('file_chmod_directory', 0777);
    +      $this->setSetting('file_chmod_directory', 0777);
           $this->assertTrue(file_prepare_directory($directory, FILE_MODIFY_PERMISSIONS), 'No error reported when making directory writeable.', 'File');
    

    the new assertTrue() only has two arguments, the group concept is gone. Not sure if we want to address that here since it doesn't really hurt and I fear that there are a lot of calls like that. Back then, we used that group thing quite a lot.

    In fact, we even still have asserts with t() calls in here.

  3. +++ b/core/modules/system/tests/src/Kernel/File/StreamWrapperTest.php
    @@ -41,14 +41,12 @@ class StreamWrapperTest extends FileTestBase {
     
       function setUp() {
    +    parent::setUp();
    +
         // Add file_private_path setting.
    -    $settings = Settings::getAll();
         $request = Request::create('/');;
         $site_path = DrupalKernel::findSitePath($request);
    -    $settings['file_private_path'] = $site_path . '/private';
    -    new Settings($settings + Settings::getAll());
    -
    -    parent::setUp();
    +    $this->setSetting('file_private_path', $site_path . '/private');
       }
    

    Hm, we might have done that deliberately before setUp(), not sure.

  4. +++ b/core/modules/system/tests/src/Kernel/KeyValueStore/DatabaseStorageExpirableTest.php
    @@ -5,10 +5,11 @@
    -namespace Drupal\system\Tests\KeyValueStore;
    +namespace Drupal\Tests\system\Kernel\KeyValueStore;
     
     use Drupal\Core\DependencyInjection\ContainerBuilder;
     use Drupal\Core\KeyValueStore\KeyValueFactory;
    +use Drupal\KernelTests\Core\KeyValueStore\StorageTestBase;
    

    Why only move some of those classes?

    Note that this one overrides containerBuild(), which is now called just register(). Not sure why it's not failing, maybe it's not required and we can drop it? Or we might not actually be testing what we think we are, since it defaults to memory?

  5. +++ b/core/modules/system/tests/src/Kernel/Routing/RouteProviderTest.php
    @@ -91,8 +91,8 @@ protected function setUp() {
        */
    -  public function containerBuild(ContainerBuilder $container) {
    -    parent::containerBuild($container); // TODO: Change the autogenerated stub
    +  public function register(ContainerBuilder $container) {
    +    parent::register($container); // TODO: Change the autogenerated stub
    

    lets drop that bogus todo while we touch that line.

  6. +++ b/core/modules/system/tests/src/Kernel/Routing/RouteProviderTest.php
    @@ -214,7 +215,8 @@ function testOutlinePathMatchTrailingSlash() {
         foreach ($routes as $route) {
    -      $this->assertEqual($route->compile()->getPatternOutline(), '/path/%/one', 'Found path has correct pattern');
    +      $this->assertEqual($route->compile()
    +        ->getPatternOutline(), '/path/%/one', 'Found path has correct pattern');
    

    looks like the typical automatic phpstorm changes, which seem unrelated and just make the patch bigger.

jhedstrom’s picture

Why only move some of those classes?

My reasoning was previously that if the test failed w/o the system module being enabled, I left it in the system module's namespace. If it's okay to lightly rely on some of the basics of the system module and still be moved to the core namespace, then more of these can be moved over.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new86.79 KB
new13.35 KB

Let's see whether this fixes all of the failures ...

In general I think the tests which should be kept in system should be just the ones which test functionality shipped by system module directly, like a custom controller or service. All the other ones belong totally

Status: Needs review » Needs work

The last submitted patch, 20: 2687897-20.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new96.53 KB
new47.44 KB

Status: Needs review » Needs work

The last submitted patch, 22: 2687897-22.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new608 bytes
new96.66 KB

There we go.

dawehner’s picture

Issue tags: +DrupalBCDays
klausi’s picture

Status: Needs review » Needs work
+++ b/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php
@@ -249,13 +251,13 @@ function testOutlinePathMatchDefaults() {
-    }
-    catch (ResourceNotFoundException $e) {
+    } catch (ResourceNotFoundException $e) {

unrelated change? all changes in this file are not needed? coding standards: catch must be oin a new line.

Otherwise looks good.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new90.83 KB
new6.16 KB

Thanks for the review klausi!

Status: Needs review » Needs work

The last submitted patch, 27: 2687897-27.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new90.81 KB
new371 bytes

No comment

dawehner’s picture

StatusFileSize
new90.93 KB
new2.51 KB

Here are two files I forgot to move.

klausi’s picture

Status: Needs review » Needs work
berdir’s picture

It does. But git is awesome, try "git merge -X theirs 8.1.x". Worked fine for me in #2456477: Convert deprecated \Drupal\simpletest\KernelTestBase tests to KernelTestBaseNG.

Can do it, but not sure how much @dawehner already did on this since the last patch.

berdir’s picture

That was a bit too optimistic, you still have to fix the namespace declarations then.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new138.19 KB

This was not at all a painful.

git merge -X theirs 8.1.x

You actually run git merge -X ours and then run the fixer again.

Status: Needs review » Needs work

The last submitted patch, 34: 2687897-30.patch, failed testing.

berdir’s picture

Found one remaining one: \Drupal\system\Tests\Cache\CacheContextOptimizationTest.

\Drupal\system\Tests\Cache\GenericCacheBackendUnitTestBase should get a @deprecated note.

I also found a left-over in views and some that weren't properly updated, will take care of that in #2456477: Convert deprecated \Drupal\simpletest\KernelTestBase tests to KernelTestBaseNG.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new112.46 KB
new1.22 KB

Thank you berdir!

Status: Needs review » Needs work

The last submitted patch, 37: 2687897-37.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
Related issues: +#2712419: ModuleInstaller::install() doesn't order the installed modules
StatusFileSize
new116.96 KB
new8.73 KB

Found an issue: #2712419: ModuleInstaller::install() doesn't order the installed modules ... here are some additional bugfixes

Status: Needs review » Needs work

The last submitted patch, 39: 2687897-39.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new121.46 KB
new6.6 KB

Status: Needs review » Needs work

The last submitted patch, 41: 2687897-41.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
Issue tags: +neworleans2016
StatusFileSize
new116.39 KB
new5.05 KB

Talked with alex, and we discussed to split off the problematic patches.

klausi’s picture

Status: Needs review » Needs work
+++ b/core/tests/Drupal/KernelTests/Core/Routing/ContentNegotiationRoutingTest.php
@@ -17,23 +17,13 @@ class ContentNegotiationRoutingTest extends KernelTestBase {
+  public function register(ContainerBuilder $container) {
+    parent::register($container);
 
     // \Drupal\simpletest\KernelTestBase::containerBuild() removes the alias path
     // processor.

Comment does not match the new function name register().

Otherwise looks good to me.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new116.59 KB
new854 bytes

Thank you klausi!

jibran’s picture

Status: Needs review » Reviewed & tested by the community

Let's get this in.

catch’s picture

+++ b/core/tests/Drupal/KernelTests/Core/Asset/AttachedAssetsTest.php
@@ -202,7 +202,7 @@ function testSettings() {
     $endToken = '}';
     $start = strpos($rendered_js, $startToken);
     $end = strrpos($rendered_js, $endToken);
-    $json  = Unicode::substr($rendered_js, $start, $end - $start + 1);
+    $json  = Unicode::substr((string) $rendered_js, $start, $end - $start + 1);

Why is the cast necessary when it's not for the strpos/strrpos calls above? If it really is necessary needs a comment.

catch’s picture

Status: Reviewed & tested by the community » Needs review
dawehner’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new116.68 KB
new697 bytes

Well, I understand it kinda, but not completely.\Drupal\Component\Utility\Unicode::substr breaks completely without mb disabled when you pass in a Markup object, see $c = ord($text[$bytes]);

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 49: 2687897-49.patch, failed testing.

dawehner’s picture

Status: Needs work » Reviewed & tested by the community

Just a random test failure ...

alexpott’s picture

Haven't reviewed yet but just so it is not forgotten there is one thing to fix on commit...

FILE: ...rupal/KernelTests/Core/Cache/GenericCacheBackendUnitTestBase.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 92 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected
    |       |     "NULL" but found "null"
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
jibran’s picture

StatusFileSize
new690 bytes
new116.37 KB

Fixed #52.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 53: convert_system_module_s-2687897-53.patch, failed testing.

dawehner’s picture

Status: Needs work » Reviewed & tested by the community

Thank you jibran!

catch’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new116.69 KB
new1.27 KB

#49 OK but why not cast before the strpos() calls. The added comment helps but it doesn't explain why it's necessary here and not later.

This is what I meant.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Totally works for me. Thank you!

catch’s picture

Status: Reviewed & tested by the community » Fixed

My change was tiny so I don't think it disqualifies me from committing this to 8.2.x - done that now.

  • catch committed 20a0802 on 8.2.x
    Issue #2687897 by dawehner, jhedstrom, catch, jibran, Berdir, klausi:...
jibran’s picture

Is it time to remove \Drupal\simpletest\KernelTestBase now?

klausi’s picture

No, there are still other base classes using it, that we need to convert, for example PluginBaseTest in Views.

$ ag simpletest\\\\KernelTestBase
modules/views/src/Tests/Plugin/PluginBaseTest.php
12:use Drupal\simpletest\KernelTestBase;

modules/views/src/Tests/ViewKernelTestBase.php
6:use Drupal\simpletest\KernelTestBase;

modules/system/src/Tests/DrupalKernel/DrupalKernelTest.php
7:use Drupal\simpletest\KernelTestBase;

modules/system/src/Tests/Entity/EntityUnitTestBase.php
5:use Drupal\simpletest\KernelTestBase;

modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php
7:use Drupal\simpletest\KernelTestBase;

modules/simpletest/src/TestBase.php
24: * \Drupal\simpletest\WebTestBase or \Drupal\simpletest\KernelTestBase.

modules/simpletest/src/Tests/KernelTestBaseTest.php
7:use Drupal\simpletest\KernelTestBase;

tests/Drupal/KernelTests/KernelTestBase.php
1194:      // @see \Drupal\simpletest\KernelTestBase::containerBuild()

berdir’s picture

All of those are unused base classes that we kept on purpose until we remove Drupal\simpletest\KernelTestBase. And the old KernelTestBase test class. So yes, we can open an issue to remove it now.

klausi’s picture

Ah cool, PluginBaseTest in Views is not deprecated, that's why I thought it is still used. Let's also @deprecate all of those unused base classes then.

klausi’s picture

oh, PluginBaseTest is not even a test base class, it is still just an old kernel test. So no, we cannot remove Drupal\simpletest\KernelTestBase because not all kernel tests have been converted.

berdir’s picture

Ah, looks like we missed that one, I think we can convert that in the same issue ,should be simple enough?

klausi’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.