function EntityResourceTestBase::assertEntityArraySubset

Same name in other branches
  1. 9 core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::assertEntityArraySubset()
  2. 11.x 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 1452

Class

EntityResourceTestBase
Defines a base class for testing all entity resources.

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]);
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.