As per the parent issue.

./Cache/AssertPageCacheContextsAndTagsTrait.php
./Cache/CacheTestBase.php
./Cache/GenericCacheBackendUnitTestBase.php
./Cache/PageCacheTagsTestBase.php
./Cache/SessionExistsCacheContextTest.php

Comments

Jo Fitzgerald created an issue. See original summary.

jofitz’s picture

Assigned: jofitz » Unassigned
Status: Active » Needs review
StatusFileSize
new14.32 KB

Moved 2 files.
Corrected namespace.
Updated references.
Left the 3 previously-deprecated *TestBase.php files for BC purposes.

Status: Needs review » Needs work

The last submitted patch, 2: 2863318-2.patch, failed testing.

martin107’s picture

looks like we need to refactor

assertSessionCookieOnClient::assertSessionCookieOnClient()

to use

$this->assertSession()->cookieEquals() to check for the presence of the session name?

[Just feeling my way forward here.]

dawehner’s picture

@Jo Fitzgerald
Also note: For backward compatibility reasons we have to leave the traits and base classes around there as well. Instead copy them into the right directory.

michielnugter’s picture

Issue tags: +phpunit initiative
martin107’s picture

Status: Needs work » Needs review
StatusFileSize
new14.45 KB

Simple reroll, due to recent changes in TrackerTest.php

Status: Needs review » Needs work

The last submitted patch, 7: 2863318-7.patch, failed testing.

martin107’s picture

Status: Needs work » Needs review
StatusFileSize
new14.53 KB
new613 bytes

less errors.

Status: Needs review » Needs work

The last submitted patch, 9: opps-2863318-9.patch, failed testing.

dawehner’s picture

+++ b/core/modules/views/src/Tests/Plugin/ExposedFormTest.php
@@ -4,7 +4,7 @@
+use Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait;

Does that mean we should move/copy over the trait here?

martin107’s picture

I am thinking of doing something potentially controversial, so it is worth talking about it first

From the perspective of

https://events.drupal.org/baltimore2017/sessions/backwards-compatibility...

We are marking @depreciated several implied public APIs in our base classes.

./Cache/CacheTestBase.php
./Cache/GenericCacheBackendUnitTestBase.php
./Cache/PageCacheTagsTestBase.php

I want to go the extra step and mark the replacement base classes as @internal so that we can
signal that we are dropping long term legacy support for those public APIs.

I am happy to write the change record that come with this....

but hey if anyone objects please let me know.

dawehner’s picture

Totally +1 for that. Sharing that kind of code outside of core has a really limited usecase. I like this thinking.

lendude’s picture

Status: Needs work » Needs review
StatusFileSize
new10.51 KB
new13.82 KB

This deprecates the WebTestBase AssertPageCacheContextsAndTagsTrait, it only updates the BrowserTestBase tests to use the new version and leaves the old deprecated version on the WebTestBase tests.

While I'm all for #12, starting to implement that here sounds a bit off. It's something we need to do for all converted test bases then. So I'd be all for opening an issue where we @internal all BrowserTestBase TestBase classes. And then from that point on, we do it for all new conversions when appropriate.

Status: Needs review » Needs work

The last submitted patch, 14: 2863318-14.patch, failed testing. View results

naveenvalecha’s picture

Status: Needs work » Needs review
StatusFileSize
new15.68 KB
new1.87 KB

Here we go with fixes. It will un-postpone few issues in the queue.

Status: Needs review » Needs work

The last submitted patch, 16: 2863318-16.patch, failed testing. View results

naveenvalecha’s picture

We couldn't trigger error right now, b/c Webtestbase is using WTB AssertPageCacheContextsAndTagsTrait. So the interim solution is to remove the trigger_error for now.

//Naveen

naveenvalecha’s picture

Status: Needs work » Needs review
StatusFileSize
new15.33 KB
new731 bytes

Removed the deprecation trigger_error for now

//Naveen

lendude’s picture

Status: Needs review » Reviewed & tested by the community

Removing the trigger_error for now until we have a good way to handle them in our tests sounds like a good way to keep this moving. Adding the trigger_error later is easily done.

The rest looks nice and minimal.

Applied the patch to check all the moves and remaining files in core/modules/system/src/Tests/Cache. Everything in that folder is now @deprecated so this patch covers the correct scope.

wim leers’s picture

+++ b/core/modules/system/tests/src/Functional/Cache/SessionExistsCacheContextTest.php
@@ -59,8 +59,7 @@ public function testCacheContext() {
   public function assertSessionCookieOnClient($expected_present) {
-    $non_deleted_cookies = array_filter($this->cookies, function ($item) { return $item['value'] !== 'deleted'; });
-    $this->assertEqual($expected_present, isset($non_deleted_cookies[$this->getSessionName()]), 'Session cookie exists.');
+    $this->assertEqual($expected_present, (bool) $this->getSession()->getCookie($this->getSessionName()), 'Session cookie exists.');
   }

<3

This is SO much simpler! I wrote that original code and hated it, but that's what was necessary.

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Needs work

Looks good other than:

+++ b/core/modules/system/src/Tests/Cache/AssertPageCacheContextsAndTagsTrait.php
@@ -9,6 +9,10 @@
+ * @deprecated Scheduled for removal in Drupal 9.0.0. Use
+ *  \Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait
+ *  instead.
  */

Should have a @see to a change notice according to current guidelines :)

lendude’s picture

Added a change notice, https://www.drupal.org/node/2896632. Still needs a @see in the patch

martin107’s picture

Status: Needs work » Needs review
StatusFileSize
new21.65 KB
new638 bytes

added @see

lendude’s picture

Status: Needs review » Reviewed & tested by the community

@martin107 thanks!

Version: 8.4.x-dev » 8.5.x-dev

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

catch’s picture

Version: 8.5.x-dev » 8.4.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.5.x and cherry-picked to 8.4.x. Thanks!

  • catch committed d9247c2 on 8.5.x
    Issue #2863318 by martin107, naveenvalecha, Lendude, Jo Fitzgerald:...

Status: Fixed » Closed (fixed)

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

quietone’s picture

published the change record