You are here

protected function EntityResourceTestBase::assertEntityArraySubset in Drupal 10

Same name and namespace in other branches
  1. 9 core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::assertEntityArraySubset()

Recursively asserts that the expected items are set in the tested entity.

A response may include more properties, we only need to ensure that all items in the request exist in the response.

Parameters

$expected: An array of expected values, may contain further nested arrays.

$actual: The object to test.

1 call to EntityResourceTestBase::assertEntityArraySubset()
EntityResourceTestBase::assertStoredEntityMatchesSentNormalization in core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php
Asserts that the stored entity matches the sent normalization.

File

core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php, line 1441

Class

EntityResourceTestBase
Even though there is the generic EntityResource, it's necessary for every entity type to have its own test, because they each have different fields, validation constraints, et cetera. It's not because the generic case works, that every case…

Namespace

Drupal\Tests\rest\Functional\EntityResource

Code

protected function assertEntityArraySubset($expected, $actual) {
  foreach ($expected as $key => $value) {
    if (is_array($value)) {
      $this
        ->assertEntityArraySubset($value, $actual[$key]);
    }
    else {
      $this
        ->assertSame($value, $actual[$key]);
    }
  }
}