Problem/Motivation

SimpleTest's TestBase class has helper methods to import config and copy config objects. We need the same functionalitity on our PHPUnit Kernel tests and Browser tests.

Proposed resolution

Create a trait to share the code

Remaining tasks

Patch.

User interface changes

None.

API changes

None.

Data model changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

klausi created an issue. See original summary.

klausi’s picture

Status: Active » Needs review
FileSize
8.24 KB

Patch.

martin107’s picture

thanks a good idea +1 from me

Patch looks clean

jibran’s picture

Status: Needs review » Reviewed & tested by the community

Let's get this in.

dawehner’s picture

+++ b/core/tests/Drupal/Tests/ConfigTestTrait.php
@@ -0,0 +1,59 @@
+  public function copyConfig(StorageInterface $source_storage, StorageInterface $target_storage) {

Does this has to be public?

klausi’s picture

Probably not, but it was public on Simpletest's TestBase and KernelTestBase, so I would keep it public to avoid an API break for now.

dawehner’s picture

Well, IMHO we can change it to be public later always, but changing from public to protected is more tricky.

klausi’s picture

Status: Reviewed & tested by the community » Needs review

Yes, and changing it to protected now is tricky because it was public before ;)

Or do you suggest to change the visibility of the method on the old TestBase with

// Change visibility of sayHello
class MyClass1 {
    use HelloWorld { sayHello as protected; }
}

?

dawehner’s picture

Yes, and changing it to protected now is tricky because it was public before ;)

Well for the old testbase we can set them to be public, but for BTB we could leave them as protected.

klausi’s picture

Status: Needs review » Needs work

Yes, makes sense!

dawehner’s picture

Cool, thank you!

klausi’s picture

Status: Needs work » Needs review
FileSize
8.38 KB
1.28 KB

Done!

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Nice! I wasn't even aware that this kind of syntax exists.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 12: config-trait-2759853-12.patch, failed testing.

The last submitted patch, 12: config-trait-2759853-12.patch, failed testing.

klausi’s picture

Status: Needs work » Reviewed & tested by the community

Looks like the random test fail from #2749955: Random fails in UpdatePathTestBase tests, retesting.

klausi’s picture

Status: Reviewed & tested by the community » Needs work

argl, does not apply anymore.

klausi’s picture

Status: Needs work » Needs review
FileSize
8.45 KB

Simple reroll, no other changes.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Let's move back to RTBC

xjm’s picture

Status: Reviewed & tested by the community » Fixed

I love this patch!

Committed a1d45d3 and pushed to 8.2.x. Thanks!

  • xjm committed a1d45d3 on 8.2.x
    Issue #2759853 by klausi, dawehner: Create ConfigTestTrait to share code...

  • xjm committed a1d45d3 on 8.3.x
    Issue #2759853 by klausi, dawehner: Create ConfigTestTrait to share code...

  • xjm committed a1d45d3 on 8.3.x
    Issue #2759853 by klausi, dawehner: Create ConfigTestTrait to share code...

Status: Fixed » Closed (fixed)

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