|
5 | 5 | use Drupal\KernelTests\KernelTestBase; |
6 | 6 | use Drupal\next\Entity\NextEntityTypeConfig; |
7 | 7 | use Drupal\next\Entity\NextSite; |
| 8 | +use Drupal\node\Entity\NodeType; |
8 | 9 | use Drupal\Tests\node\Traits\NodeCreationTrait; |
9 | 10 |
|
10 | 11 | /** |
@@ -42,6 +43,8 @@ protected function setUp(): void { |
42 | 43 | $this->installEntitySchema('path_alias'); |
43 | 44 | $this->installConfig(['filter']); |
44 | 45 | $this->installSchema('node', ['node_access']); |
| 46 | + |
| 47 | + NodeType::create(['type' => 'page', 'name' => 'Page'])->save(); |
45 | 48 | } |
46 | 49 |
|
47 | 50 | /** |
@@ -169,4 +172,33 @@ public function testDraftEnabled() { |
169 | 172 | $this->assertFalse($entity_type_config->isDraftEnabled()); |
170 | 173 | } |
171 | 174 |
|
| 175 | + /** |
| 176 | + * Tests config dependency calculation. |
| 177 | + */ |
| 178 | + public function testConfigDependencies(): void { |
| 179 | + $blog_site = NextSite::create([ |
| 180 | + 'id' => 'blog', |
| 181 | + ]); |
| 182 | + $blog_site->save(); |
| 183 | + |
| 184 | + // Create entity type config. |
| 185 | + /** @var \Drupal\next\Entity\NextEntityTypeConfigInterface $entity_type_config */ |
| 186 | + $entity_type_config = NextEntityTypeConfig::create([ |
| 187 | + 'id' => 'node.page', |
| 188 | + 'site_resolver' => 'site_selector', |
| 189 | + 'configuration' => [ |
| 190 | + 'sites' => [ |
| 191 | + 'blog' => 'blog', |
| 192 | + ], |
| 193 | + ], |
| 194 | + ]); |
| 195 | + // Saving causes dependency calculation. |
| 196 | + $entity_type_config->save(); |
| 197 | + self::assertEquals([ |
| 198 | + 'config' => [ |
| 199 | + 'node.type.page', |
| 200 | + ], |
| 201 | + ], $entity_type_config->getDependencies()); |
| 202 | + } |
| 203 | + |
172 | 204 | } |
0 commit comments