Problem/Motivation

As title.

Proposed resolution

For example:

-    $this->assertTrue(array_key_exists($this->nodes['public_no_language_public']->id(), $nids), 'Returned node ID is no language public node.');
+    $this->assertArrayHasKey($this->nodes['public_no_language_public']->id(), $nids);

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

mondrake created an issue. See original summary.

jungle’s picture

Assigned: Unassigned » jungle
jungle’s picture

Title: Replace assertions involving calls to array_key_exists() with assertArrayHasKey() » Replace assertions involving calls to array_key_exists() with assertArrayHasKey()/assertArrayNotHasKey()
Status: Active » Needs review
StatusFileSize
new27.4 KB

Expanding the scope a little bit to have assertArrayNotHasKey() by changing the title

mondrake’s picture

I suggest to remove the $messages straight here... in this case PHPUnit default will be way better.

jungle’s picture

Thanks, @mondrake, on it.

jungle’s picture

StatusFileSize
new25.6 KB
new18.4 KB

Addressed #4

jungle’s picture

Assigned: jungle » Unassigned
longwave’s picture

Status: Needs review » Reviewed & tested by the community

Changes look good, no other instances of >assert.*array_key_exists.

mondrake’s picture

+++ b/core/modules/node/tests/src/Kernel/NodeAccessLanguageAwareCombinationTest.php
@@ -278,9 +278,9 @@ public function testNodeAccessLanguageAwareCombination() {
+    $this->assertArrayHasKey($this->nodes['public_both_public']->id(), $nids, 'Returned node ID is both public node.');
+    $this->assertArrayHasKey($this->nodes['public_ca_private']->id(), $nids, 'Returned node ID is Hungarian public only node.');
+    $this->assertArrayHasKey($this->nodes['private_both_public']->id(), $nids, 'Returned node ID is both public non-language-aware private only node.');
 

@@ -292,9 +292,9 @@ public function testNodeAccessLanguageAwareCombination() {
+    $this->assertArrayHasKey($this->nodes['public_both_public']->id(), $nids, 'Returned node ID is both public node.');
+    $this->assertArrayHasKey($this->nodes['public_hu_private']->id(), $nids, 'Returned node ID is Catalan public only node.');
+    $this->assertArrayHasKey($this->nodes['private_both_public']->id(), $nids, 'Returned node ID is both public non-language-aware private only node.');
 

These still have the $message, leftover or is there a reasoning behind?

jungle’s picture

Thanks, @longwave and @mondrake. Yes, leftover. A new patch coming soon.

jungle’s picture

StatusFileSize
new25.28 KB
new2.24 KB

Addressed #9. Stay RTBC.

  • catch committed 54f84c2 on 9.1.x
    Issue #3131223 by jungle, mondrake, longwave: Replace assertions...
catch’s picture

Version: 9.1.x-dev » 8.9.x-dev
Status: Reviewed & tested by the community » Needs work

Committed/pushed to 9.1.x and 8.0.x, needs a reroll for 8.9.x.

jungle’s picture

Status: Needs work » Needs review
StatusFileSize
new25.27 KB
new10.66 KB
jungle’s picture

Status: Needs review » Needs work
+++ b/Users/jungleran/3131223-11.patch
@@ -85,13 +85,13 @@ index 6886f22db6..2e750c8a65 100644
-     $this->assertEqual(count($nids), 3, 'db_select() returns 3 nodes when no langcode is specified.');
+     $this->assertEqual(count($nids), 3, '$connection->select() returns 3 nodes when no langcode is specified.');

A wrong comment, leftover message but looks like an unexpected change, reroll again. Sorry for the noises!

jungle’s picture

The reroll in #14 was correct, the raw-interdiff confused me. Sorry! Requeueing to run tests

  • catch committed 5b5c83a on 9.0.x
    Issue #3131223 by jungle, mondrake, longwave: Replace assertions...
jungle’s picture

I am setting this back to RTBC as it's a reroll, and the testing passed as expected. Thanks, @longwave and @mondrake for reviewing, @catch thank you for committing!

jungle’s picture

Status: Needs work » Reviewed & tested by the community
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed 4afd6fb and pushed to 8.9.x. Thanks!

  • catch committed 4afd6fb on 8.9.x
    Issue #3131223 by jungle, mondrake, longwave: Replace assertions...

Status: Fixed » Closed (fixed)

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