Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ protected function setUp(): void {
$this->installConfig(['filter', 'next']);
$this->installSchema('node', ['node_access']);

$type = NodeType::create([
'type' => 'article',
]);
$type->save();
NodeType::create(['type' => 'article', 'name' => 'Article'])->save();

foreach (range(1, 100) as $number) {
$article = $this->createNode([
Expand Down
14 changes: 14 additions & 0 deletions modules/next/src/Entity/NextEntityTypeConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,20 @@ public function getPluginCollections() {
return $collections;
}

/**
* {@inheritdoc}
*
* @todo add sites with onDependencyRemoval support.
*/
public function calculateDependencies() {
parent::calculateDependencies();
[$entity_type_id, $bundle] = explode('.', $this->id());
$target_entity_type = $this->entityTypeManager()->getDefinition($entity_type_id);
$bundle_config_dependency = $target_entity_type->getBundleConfigDependency($bundle);
$this->addDependency($bundle_config_dependency['type'], $bundle_config_dependency['name']);
return $this;
}

/**
* Wraps the site_resolver plugin manager.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Drupal\KernelTests\KernelTestBase;
use Drupal\next\Controller\NextPreviewUrlController;
use Drupal\next\Entity\NextSite;
use Drupal\node\Entity\NodeType;
use Drupal\Tests\node\Traits\NodeCreationTrait;
use Drupal\Tests\user\Traits\UserCreationTrait;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -44,6 +45,8 @@ protected function setUp(): void {
$this->installConfig(['filter', 'next']);
$this->installSchema('node', ['node_access']);

NodeType::create(['type' => 'page', 'name' => 'Page'])->save();

$this->nextSite = NextSite::create([
'label' => 'Blog',
'id' => 'blog',
Expand Down
32 changes: 32 additions & 0 deletions modules/next/tests/src/Kernel/Entity/NextEntityTypeConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Drupal\KernelTests\KernelTestBase;
use Drupal\next\Entity\NextEntityTypeConfig;
use Drupal\next\Entity\NextSite;
use Drupal\node\Entity\NodeType;
use Drupal\Tests\node\Traits\NodeCreationTrait;

/**
Expand Down Expand Up @@ -42,6 +43,8 @@ protected function setUp(): void {
$this->installEntitySchema('path_alias');
$this->installConfig(['filter']);
$this->installSchema('node', ['node_access']);

NodeType::create(['type' => 'page', 'name' => 'Page'])->save();
}

/**
Expand Down Expand Up @@ -169,4 +172,33 @@ public function testDraftEnabled() {
$this->assertFalse($entity_type_config->isDraftEnabled());
}

/**
* Tests config dependency calculation.
*/
public function testConfigDependencies(): void {
$blog_site = NextSite::create([
'id' => 'blog',
]);
$blog_site->save();

// Create entity type config.
/** @var \Drupal\next\Entity\NextEntityTypeConfigInterface $entity_type_config */
$entity_type_config = NextEntityTypeConfig::create([
'id' => 'node.page',
'site_resolver' => 'site_selector',
'configuration' => [
'sites' => [
'blog' => 'blog',
],
],
]);
// Saving causes dependency calculation.
$entity_type_config->save();
self::assertEquals([
'config' => [
'node.type.page',
],
], $entity_type_config->getDependencies());
}

}
3 changes: 3 additions & 0 deletions modules/next/tests/src/Kernel/Entity/NextSiteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Drupal\KernelTests\KernelTestBase;
use Drupal\next\Entity\NextSite;
use Drupal\node\Entity\NodeType;
use Drupal\Tests\node\Traits\NodeCreationTrait;
use Drupal\Tests\user\Traits\UserCreationTrait;
use Drupal\user\Entity\User;
Expand Down Expand Up @@ -42,6 +43,8 @@ protected function setUp(): void {
$this->installConfig(['filter', 'next']);
$this->installSchema('node', ['node_access']);

NodeType::create(['type' => 'page', 'name' => 'Page'])->save();

$this->nextSite = NextSite::create([
'label' => 'Blog',
'id' => 'blog',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Drupal\dblog\Controller\DbLogController;
use Drupal\KernelTests\KernelTestBase;
use Drupal\next\Entity\NextEntityTypeConfig;
use Drupal\node\Entity\NodeType;
use Drupal\Tests\node\Traits\NodeCreationTrait;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand Down Expand Up @@ -45,6 +46,8 @@ protected function setUp(): void {
$this->installSchema('node', ['node_access']);
$this->installSchema('user', ['users_data']);

NodeType::create(['type' => 'page', 'name' => 'Page'])->save();

// Create entity type config.
$entity_type_config = NextEntityTypeConfig::create([
'id' => 'node.page',
Expand Down
3 changes: 3 additions & 0 deletions modules/next/tests/src/Kernel/NextEntityTypeManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Drupal\KernelTests\KernelTestBase;
use Drupal\next\Entity\NextEntityTypeConfig;
use Drupal\next\Entity\NextSite;
use Drupal\node\Entity\NodeType;
use Drupal\Tests\node\Traits\NodeCreationTrait;

/**
Expand Down Expand Up @@ -33,6 +34,8 @@ protected function setUp(): void {
$this->installEntitySchema('user');
$this->installConfig(['filter', 'next']);
$this->installSchema('node', ['node_access']);

NodeType::create(['type' => 'page', 'name' => 'Page'])->save();
}

/**
Expand Down
3 changes: 3 additions & 0 deletions modules/next/tests/src/Kernel/Plugin/PathRevalidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Drupal\KernelTests\KernelTestBase;
use Drupal\next\Entity\NextEntityTypeConfig;
use Drupal\next\Entity\NextSite;
use Drupal\node\Entity\NodeType;
use Drupal\Tests\node\Traits\NodeCreationTrait;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Psr7\Response as GuzzleResponse;
Expand Down Expand Up @@ -48,6 +49,8 @@ protected function setUp(): void {
$this->installEntitySchema('path_alias');
$this->installConfig(['filter']);
$this->installSchema('node', ['node_access']);

NodeType::create(['type' => 'page', 'name' => 'Page'])->save();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Drupal\KernelTests\KernelTestBase;
use Drupal\next\Entity\NextEntityTypeConfig;
use Drupal\next\Entity\NextSite;
use Drupal\node\Entity\NodeType;
use Drupal\Tests\node\Traits\NodeCreationTrait;
use Drupal\Tests\user\Traits\UserCreationTrait;
use Drupal\user\Entity\User;
Expand Down Expand Up @@ -52,6 +53,8 @@ protected function setUp(): void {
$this->installConfig(['filter', 'next']);
$this->installSchema('node', ['node_access']);

NodeType::create(['type' => 'page', 'name' => 'Page'])->save();

$this->nextSettingsManager = $this->container->get('next.settings.manager');

// Create NextSite entities.
Expand Down
15 changes: 3 additions & 12 deletions modules/next/tests/src/Kernel/Plugin/SiteResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,9 @@ protected function setUp(): void {
$this->installConfig(['filter']);
$this->installSchema('node', ['node_access']);

// Create page type.
$page_type = NodeType::create([
'type' => 'page',
'label' => 'Page',
]);
$page_type->save();

$article_type = NodeType::create([
'type' => 'article',
'label' => 'Article',
]);
$article_type->save();
// Create content types.
NodeType::create(['type' => 'page', 'name' => 'Page'])->save();
NodeType::create(['type' => 'article', 'name' => 'Article'])->save();

// Create NextSite entities.
$blog = NextSite::create([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,9 @@ protected function setUp(): void {
$this->installSchema('node', ['node_access']);
$this->installSchema('user', ['users_data']);

// Create page type.
$page_type = NodeType::create([
'type' => 'page',
'label' => 'Page',
]);
$page_type->save();

$article_type = NodeType::create([
'type' => 'article',
'label' => 'Article',
]);
$article_type->save();
// Create content types.
NodeType::create(['type' => 'page', 'name' => 'Page'])->save();
NodeType::create(['type' => 'article', 'name' => 'Article'])->save();

// Create NextSite entities.
$blog = NextSite::create([
Expand Down