X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Ftests%2FDrupal%2FTests%2FCore%2FConfig%2FEntity%2FConfigEntityTypeTest.php;fp=web%2Fcore%2Ftests%2FDrupal%2FTests%2FCore%2FConfig%2FEntity%2FConfigEntityTypeTest.php;h=0c1ac1bd8f3c20e16a2fb990861e0eb018763389;hp=914d4f6fe53307b735eff76065aeb1c9bf298a7e;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityTypeTest.php b/web/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityTypeTest.php index 914d4f6fe..0c1ac1bd8 100644 --- a/web/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityTypeTest.php +++ b/web/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityTypeTest.php @@ -2,6 +2,8 @@ namespace Drupal\Tests\Core\Config\Entity; +use Drupal\Core\Config\TypedConfigManagerInterface; +use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Tests\UnitTestCase; use Drupal\Core\Config\Entity\ConfigEntityType; use Drupal\Core\Config\Entity\Exception\ConfigEntityStorageClassException; @@ -12,6 +14,23 @@ use Drupal\Core\Config\Entity\Exception\ConfigEntityStorageClassException; */ class ConfigEntityTypeTest extends UnitTestCase { + /** + * The mocked typed config manager. + * + * @var \Drupal\Core\Config\TypedConfigManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $typedConfigManager; + + /** + * {@inheritdoc} + */ + protected function setUp() { + $this->typedConfigManager = $this->getMock(TypedConfigManagerInterface::class); + $container = new ContainerBuilder(); + $container->set('config.typed', $this->typedConfigManager); + \Drupal::setContainer($container); + } + /** * Sets up a ConfigEntityType object for a given set of values. * @@ -85,7 +104,7 @@ class ConfigEntityTypeTest extends UnitTestCase { $this->setExpectedException(ConfigEntityStorageClassException::class, '\Drupal\Core\Entity\KeyValueStore\KeyValueEntityStorage is not \Drupal\Core\Config\Entity\ConfigEntityStorage or it does not extend it'); new ConfigEntityType([ 'id' => 'example_config_entity_type', - 'handlers' => ['storage' => '\Drupal\Core\Entity\KeyValueStore\KeyValueEntityStorage'] + 'handlers' => ['storage' => '\Drupal\Core\Entity\KeyValueStore\KeyValueEntityStorage'], ]); } @@ -137,11 +156,6 @@ class ConfigEntityTypeTest extends UnitTestCase { public function providerGetPropertiesToExport() { $data = []; - $data[] = [ - [], - NULL, - ]; - $data[] = [ [ 'config_export' => [ @@ -177,4 +191,27 @@ class ConfigEntityTypeTest extends UnitTestCase { return $data; } + /** + * @covers ::getPropertiesToExport + */ + public function testGetPropertiesToExportSchemaFallback() { + $this->typedConfigManager->expects($this->once()) + ->method('getDefinition') + ->will($this->returnValue(['mapping' => ['id' => '', 'dependencies' => '']])); + $config_entity_type = new ConfigEntityType([ + 'id' => 'example_config_entity_type', + ]); + $this->assertEquals(['id' => 'id', 'dependencies' => 'dependencies'], $config_entity_type->getPropertiesToExport('test')); + } + + /** + * @covers ::getPropertiesToExport + */ + public function testGetPropertiesToExportNoFallback() { + $config_entity_type = new ConfigEntityType([ + 'id' => 'example_config_entity_type', + ]); + $this->assertNull($config_entity_type->getPropertiesToExport()); + } + }