function ConfigEntityBaseUnitTest::testThirdPartySettings

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityBaseUnitTest::testThirdPartySettings()
  2. 10 core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityBaseUnitTest::testThirdPartySettings()
  3. 11.x core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityBaseUnitTest::testThirdPartySettings()

@covers ::getThirdPartySetting @covers ::setThirdPartySetting @covers ::getThirdPartySettings @covers ::unsetThirdPartySetting @covers ::getThirdPartyProviders

File

core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php, line 604

Class

ConfigEntityBaseUnitTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Config%21Entity%21ConfigEntityBase.php/class/ConfigEntityBase/8.9.x" title="Defines a base configuration entity class." class="local">\Drupal\Core\Config\Entity\ConfigEntityBase</a> @group Config

Namespace

Drupal\Tests\Core\Config\Entity

Code

public function testThirdPartySettings() {
    $key = 'test';
    $third_party = 'test_provider';
    $value = $this->getRandomGenerator()
        ->string();
    // Test getThirdPartySetting() with no settings.
    $this->assertEquals($value, $this->entity
        ->getThirdPartySetting($third_party, $key, $value));
    $this->assertNull($this->entity
        ->getThirdPartySetting($third_party, $key));
    // Test setThirdPartySetting().
    $this->entity
        ->setThirdPartySetting($third_party, $key, $value);
    $this->assertEquals($value, $this->entity
        ->getThirdPartySetting($third_party, $key));
    $this->assertEquals($value, $this->entity
        ->getThirdPartySetting($third_party, $key, $this->randomGenerator
        ->string()));
    // Test getThirdPartySettings().
    $this->entity
        ->setThirdPartySetting($third_party, 'test2', 'value2');
    $this->assertEquals([
        $key => $value,
        'test2' => 'value2',
    ], $this->entity
        ->getThirdPartySettings($third_party));
    // Test getThirdPartyProviders().
    $this->entity
        ->setThirdPartySetting('test_provider2', $key, $value);
    $this->assertEquals([
        $third_party,
        'test_provider2',
    ], $this->entity
        ->getThirdPartyProviders());
    // Test unsetThirdPartyProviders().
    $this->entity
        ->unsetThirdPartySetting('test_provider2', $key);
    $this->assertEquals([
        $third_party,
    ], $this->entity
        ->getThirdPartyProviders());
}

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