![](/img/trans.png)
[英]The "paragraph" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition()
[英]PHPunit Drupal8 : The “node” entity type does not exist
生成drupal模塊后:
vendor/bin/drupal generate:module
我試圖在我的新模塊中運行單元測試在這個文件中:modules / custom / candidacy_analyser / tests / src / Functional / LoadTest.php
所以我在創建phpunit.xml之后使用了這個命令並將它放在核心中
vendor/bin/phpunit --configuration core modules/custom/candidacy_analyser/tests/src/Functional/LoadTest.php
但我發現了錯誤:
有1個錯誤:
1)Drupal \\ Tests \\ candidacy_analyser \\ Functional \\ LoadTest :: testLoad Drupal \\ Component \\ Plugin \\ Exception \\ PluginNotFoundException:“節點”實體類型不存在。
堆棧跟蹤:
/var/www/html/core/lib/Drupal/Core/Entity/EntityTypeManager.php:133 /var/www/html/core/lib/Drupal/Core/Entity/EntityManager.php:54 / var / www / html /core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php:117 /var/www/html/core/lib/Drupal/Core/Field/BaseFieldDefinition.php:713 / var / www / html /core/lib/Drupal/Core/Field/BaseFieldDefinition.php:736 /var/www/html/core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php:388 / var / www / html / core / lib /Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php:696 /var/www/html/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php:309 / var / www / html / core / lib / Drupal /Core/Entity/Sql/SqlContentEntityStorage.php:1397 /var/www/html/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php:1483 / var / www / html / core / lib / Drupal / Core / Entity/Sql/SqlContentEntityStorage.php:1398 /var/www/html/core/lib/Drupal/Core/Entity/EntityTypeListener.php:71 / var / www / html / core / lib / Drupal / Core / Entity / EntityManager .php:534 / var / www / html / core / lib / Drupa l / Core / Entity / EntityDefinitionUpdateManager.php:157 /var/www/html/core/lib/Drupal/Core/Extension/ModuleInstaller.php:239 / var / www / html / core / lib / Drupal / Core / ProxyClass / Extension / ModuleInstaller.php:83 /var/www/html/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php:414 /var/www/html/core/tests/Drupal/Tests/BrowserTestBase.php:572 / var / www / html / core / tests / Drupal / Tests / BrowserTestBase.php:398 /var/www/html/modules/custom/candidacy_analyser/tests/src/Functional/LoadTest.php:33
生成的文件:LoadTest.php:
<?php
namespace Drupal\Tests\candidacy_analyser\Functional;
use Drupal\Core\Url;
use Drupal\Tests\BrowserTestBase;
/**
* Simple test to ensure that main page loads with module enabled.
*
* @group candidacy_analyser
*/
class LoadTest extends BrowserTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = ['candidacy_analyser'];
/**
* A user with permission to administer site configuration.
*
* @var \Drupal\user\UserInterface
*/
protected $user;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->user = $this->drupalCreateUser(['administer site configuration']);
$this->drupalLogin($this->user);
}
/**
* Tests that the home page loads with a 200 response.
*/
public function testLoad() {
$this->drupalGet(Url::fromRoute('<front>'));
$this->assertSession()->statusCodeEquals(200);
}
}
有什么幫助嗎?
嘗試將node
定義為$ modules之一:
public static $modules = ['node', 'candidacy_analyser'];
您可能還需要在setup()
包含它:
$this->installEntitySchema('node');
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.