class ContentExportTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/FunctionalTests/DefaultContent/ContentExportTest.php \Drupal\FunctionalTests\DefaultContent\ContentExportTest
Tests exporting content in YAML format.
Attributes
#[CoversClass(ContentExportCommand::class)]
#[CoversClass(Exporter::class)]
#[Group('DefaultContent')]
#[Group('Recipe')]
#[Group('#slow')]
#[RunTestsInSeparateProcesses]
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Tests\DrupalTestCaseTrait, \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\PhpUnitCompatibilityTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\FunctionalTests\DefaultContent\ContentExportTest uses \Drupal\Tests\field\Traits\EntityReferenceFieldCreationTrait, \Drupal\FunctionalTests\Core\Recipe\RecipeTestTrait, \Drupal\Tests\taxonomy\Traits\TaxonomyTestTrait extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of ContentExportTest
File
-
core/
tests/ Drupal/ FunctionalTests/ DefaultContent/ ContentExportTest.php, line 37
Namespace
Drupal\FunctionalTests\DefaultContentView source
class ContentExportTest extends BrowserTestBase {
use EntityReferenceFieldCreationTrait;
use RecipeTestTrait;
use TaxonomyTestTrait;
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Scans for content in the fixture.
*/
private readonly Finder $finder;
/**
* The directory where the default content is located.
*/
private readonly string $contentDir;
/**
* The user account which is doing the content import and export.
*/
private readonly UserInterface $adminUser;
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
// Apply the recipe that sets up the fields and configuration for our
// default content.
$fixtures_dir = $this->getDrupalRoot() . '/core/tests/fixtures';
$this->applyRecipe($fixtures_dir . '/recipes/default_content_base');
// We need an administrative user to import and export content.
$this->adminUser = $this->setUpCurrentUser(admin: TRUE);
// Import all of the default content from the fixture.
$this->contentDir = $fixtures_dir . '/default_content';
$this->finder = new Finder($this->contentDir);
$this->assertNotEmpty($this->finder->data);
$this->container
->get(Importer::class)
->importContent($this->finder);
}
/**
* Ensures that all imported content can be exported properly.
*/
public function testExportContent() : void {
// We should get an error if we try to export a non-existent entity type.
$process = $this->runDrupalCommand([
'content:export',
'camels',
42,
'--no-ansi',
]);
$this->assertSame(1, $process->wait());
$this->assertStringContainsString('The entity type "camels" does not exist.', $process->getOutput());
// We should get an error if we try to export a non-existent entity.
$process = $this->runDrupalCommand([
'content:export',
'taxonomy_term',
42,
'--no-ansi',
]);
$this->assertSame(1, $process->wait());
$this->assertStringContainsString('taxonomy_term 42 does not exist.', $process->getOutput());
// We should get an error if we try to export a config entity.
$process = $this->runDrupalCommand([
'content:export',
'taxonomy_vocabulary',
'tags',
'--no-ansi',
]);
$this->assertSame(1, $process->wait());
$this->assertStringContainsString('taxonomy_vocabulary is not a content entity type.', $process->getOutput());
$entity_repository = $this->container
->get(EntityRepositoryInterface::class);
foreach ($this->finder->data as $uuid => $imported_data) {
$entity_type_id = $imported_data['_meta']['entity_type'];
$entity = $entity_repository->loadEntityByUuid($entity_type_id, $uuid);
$this->assertInstanceOf(ContentEntityInterface::class, $entity);
$process = $this->runDrupalCommand([
'content:export',
$entity->getEntityTypeId(),
$entity->id(),
]);
// The export should succeed without error.
$this->assertSame(0, $process->wait());
// The path is added by the importer and is never exported.
unset($imported_data['_meta']['path']);
// The output should be identical to the imported data. Sort recursively
// by key to prevent false negatives.
$exported_data = Yaml::decode($process->getOutput());
// If the entity is a file, the file URI might vary slightly -- i.e., if
// the file already existed, the imported one would have been renamed. We
// need to account for that.
if ($entity->getEntityTypeId() === 'file') {
$imported_uri = $entity->getFileUri();
$extension = strlen('.' . pathinfo($imported_uri, PATHINFO_EXTENSION));
$imported_uri = substr($imported_uri, 0, -$extension);
$exported_uri = substr($exported_data['default']['uri'][0]['value'], 0, -$extension);
$this->assertStringStartsWith($imported_uri, $exported_uri);
// We know they match; no need to consider them further.
unset($exported_data['default']['uri'][0]['value'], $imported_data['default']['uri'][0]['value']);
}
// This specific node is special -- it is always reassigned to the current
// user during import, because its owner does not exist. Therefore, the
// current user is who it should be referring to when exported.
if ($uuid === '7f1dd75a-0be2-4d3b-be5d-9d1a868b9267') {
$new_owner = $this->adminUser
->uuid();
$exported_data['_meta']['depends'] = $imported_data['_meta']['depends'] = [
$new_owner => 'user',
];
$exported_data['default']['uid'][0]['entity'] = $imported_data['default']['uid'][0]['entity'] = $new_owner;
}
SortArray::sortByKeyRecursive($exported_data);
SortArray::sortByKeyRecursive($imported_data);
$this->assertSame($imported_data, $exported_data);
}
}
/**
* Tests various entity export scenarios.
*/
public function testEntityExportScenarios() : void {
$this->doTestExportSingleEntityToDirectory();
$this->doTestExportWithDependencies();
$this->doTestCircularDependency();
$this->doTestMissingDependenciesAreLogged();
$this->doTestExportFileEntityWithMissingPhysicalFile();
$this->doTestExportedPasswordIsPreserved();
$this->doTestExportEntitiesFilteredByType();
}
/**
* Tests that an exported user account can be logged in with after import.
*/
protected function doTestExportedPasswordIsPreserved() : void {
$account = $this->createUser();
$this->assertNotEmpty($account->passRaw);
// Export the account to temporary file.
$process = $this->runDrupalCommand([
'content:export',
'user',
$account->id(),
]);
$this->assertSame(0, $process->wait());
$dir = 'public://user-content';
mkdir($dir);
file_put_contents($dir . '/user.yml', $process->getOutput());
// Delete the account and re-import it.
$account->delete();
$this->container
->get(Importer::class)
->importContent(new Finder($dir));
// Ensure the import succeeded, and that we can log in with the imported
// account. We want to use the standard login form, rather than a one-time
// login link, to ensure the password is preserved.
$this->assertIsObject(user_load_by_name($account->getAccountName()));
$this->useOneTimeLoginLinks = FALSE;
$this->drupalLogin($account);
$this->assertSession()
->addressMatches('/\\/user\\/[0-9]+$/');
}
/**
* Tests exporting a single entity to a directory with attachments.
*/
protected function doTestExportSingleEntityToDirectory() : void {
$file = $this->container
->get(EntityRepositoryInterface::class)
->loadEntityByUuid('file', '7fb09f9f-ba5f-4db4-82ed-aa5ccf7d425d');
$this->assertInstanceOf(File::class, $file);
$dir = 'public://export-content';
$process = $this->runDrupalCommand([
'content:export',
'file',
$file->id(),
"--dir={$dir}",
]);
$this->assertSame(0, $process->wait());
$this->assertStringContainsString('One entity was exported to', $process->getOutput());
$this->assertFileExists($dir . '/file/' . $file->uuid() . '.yml');
$this->assertFileExists($dir . '/file/' . $file->getFilename());
}
/**
* Tests exporting a piece of content with its dependencies.
*/
protected function doTestExportWithDependencies() : void {
$image_uri = $this->getRandomGenerator()
->image(uniqid('public://') . '.png', '200x200', '300x300');
$file = File::create([
'uri' => $image_uri,
]);
$file->save();
$media = Media::create([
'bundle' => 'image',
'field_media_image' => [
$file,
],
]);
$media->save();
$this->createEntityReferenceField('node', 'article', 'field_media', 'Media', 'media', selection_handler_settings: [
'target_bundles' => [
'image' => 'image',
],
]);
$node = $this->drupalCreateNode([
'type' => 'article',
'field_tags' => Term::load(1),
'field_media' => $media,
'uid' => User::load(2),
]);
$command = [
'content:export',
'node',
$node->id(),
'--with-dependencies',
];
// With no `--dir` option, we should get an error.
$process = $this->runDrupalCommand($command);
$this->assertGreaterThan(0, $process->wait());
$this->assertStringContainsString('The --dir option is required to export multiple entities', $process->getErrorOutput());
$command[] = "--dir=public://content";
$process = $this->runDrupalCommand($command);
$this->assertSame(0, $process->wait());
$expected_output_dir = $this->container
->get(FileSystemInterface::class)
->realpath('public://content');
$this->assertStringContainsString('5 entities were exported to ', $process->getOutput());
$this->assertFileExists($expected_output_dir . '/node/' . $node->uuid() . '.yml');
$this->assertFileExists($expected_output_dir . '/taxonomy_term/' . $node->field_tags[0]->entity
->uuid() . '.yml');
$this->assertFileExists($expected_output_dir . '/media/' . $media->uuid() . '.yml');
$this->assertFileExists($expected_output_dir . '/file/' . $file->uuid() . '.yml');
$this->assertFileExists($expected_output_dir . '/user/' . $node->getOwner()
->uuid() . '.yml');
// The physical file should have been copied too.
$original_file_hash = hash_file('sha256', $file->getFileUri());
$this->assertIsString($original_file_hash);
$exported_file_hash = hash_file('sha256', $expected_output_dir . '/file/' . $file->getFilename());
$this->assertIsString($exported_file_hash);
$this->assertTrue(hash_equals($original_file_hash, $exported_file_hash));
}
/**
* Tests that the exporter handles circular dependencies gracefully.
*/
protected function doTestCircularDependency() : void {
$this->createEntityReferenceField('node', 'article', 'field_related', 'Related Content', 'node', selection_handler_settings: [
'target_bundles' => [
'page' => 'page',
],
]);
$this->createEntityReferenceField('node', 'page', 'field_related', 'Related Content', 'node', selection_handler_settings: [
'target_bundles' => [
'article' => 'article',
],
]);
$page = $this->drupalCreateNode([
'type' => 'page',
]);
$article = $this->drupalCreateNode([
'type' => 'article',
'field_related' => $page,
]);
$page->set('field_related', $article)
->save();
$command = [
'content:export',
'node',
$page->id(),
'--with-dependencies',
'--dir=public://content',
];
// If the export takes more than 10 seconds, it's probably stuck in an
// infinite loop.
$process = $this->runDrupalCommand($command, 10);
$this->assertSame(0, $process->wait());
$destination = 'public://content/node';
$this->assertFileExists($destination . '/' . $page->uuid() . '.yml');
$this->assertFileExists($destination . '/' . $article->uuid() . '.yml');
}
/**
* Tests that the exporter handles missing dependencies gracefully.
*/
protected function doTestMissingDependenciesAreLogged() : void {
$this->createEntityReferenceField('node', 'article', 'field_related', 'Related Content', 'node', selection_handler_settings: [
'target_bundles' => [
'page' => 'page',
],
]);
$page = $this->drupalCreateNode([
'type' => 'page',
]);
$page_id = $page->id();
$article = $this->drupalCreateNode([
'type' => 'article',
'field_related' => $page,
]);
$page->delete();
// We need to clear the caches or the related content is included because
// the article is cached.
$entity_storage = $this->container
->get(EntityTypeManagerInterface::class)
->getStorage('node');
$entity_storage->resetCache([
$page->id(),
$article->id(),
]);
$article = $entity_storage->load($article->id());
/** @var \Drupal\Core\DefaultContent\Exporter $exporter */
$exporter = $this->container
->get(Exporter::class);
$logger = new TestLogger();
$exporter->setLogger($logger);
$dependencies = $exporter->export($article)->metadata
->getDependencies();
// The export succeeded without throwing an exception, and depends only on
// the author. The page should not be among the dependencies.
$author_uuid = $this->adminUser
->uuid();
$this->assertCount(1, $dependencies);
$this->assertSame([
'user',
$author_uuid,
], $dependencies[0]);
// The invalid reference should have been logged.
$predicate = function (array $record) use ($page_id, $article) : bool {
return $record['message'] === 'Failed to export reference to @target_type %missing_id referenced by %field on @entity_type %label because the referenced @target_type does not exist.' && $record['context']['@target_type'] === 'content item' && $record['context']['%missing_id'] === $page_id && $record['context']['%field'] === 'Related Content' && $record['context']['@entity_type'] === 'content item' && $record['context']['%label'] === $article->label();
};
$this->assertTrue($logger->hasRecordThatPasses($predicate, LogLevel::WARNING));
}
/**
* Tests exporting file entities without an accompanying physical file.
*/
protected function doTestExportFileEntityWithMissingPhysicalFile() : void {
$file = $this->container
->get(EntityRepositoryInterface::class)
->loadEntityByUuid('file', '2b8e0616-3ef0-4a91-8cfb-b31d9128f9f8');
$this->assertInstanceOf(File::class, $file);
$this->assertFileDoesNotExist($file->getFileUri());
$logger = new TestLogger();
$this->container
->get('logger.factory')
->addLogger($logger);
/** @var \Drupal\Core\DefaultContent\Exporter $exporter */
$exporter = $this->container
->get(Exporter::class);
$attachments = $exporter->export($file)->metadata
->getAttachments();
// The export succeeded without throwing an exception, but the physical file
// does not exist, so it should not have been attached.
$this->assertEmpty($attachments);
// The problem should have been logged.
$predicate = function (array $record) use ($file) : bool {
return $record['level'] === RfcLogLevel::WARNING && $record['message'] === 'The file (%uri) associated with file entity %name does not exist.' && $record['context']['%uri'] === $file->getFileUri() && $record['context']['%name'] === $file->label();
};
$this->assertTrue($logger->hasRecordThatPasses($predicate));
}
/**
* Tests exporting entities filtered by type.
*/
protected function doTestExportEntitiesFilteredByType() : void {
// We should get an error if we try to export a non-existent entity type.
$process = $this->runDrupalCommand([
'content:export',
'camels',
]);
$this->assertSame(1, $process->wait());
$this->assertStringContainsString('The entity type "camels" does not exist.', $process->getOutput());
// We should get an error if we try to export a config entity.
$process = $this->runDrupalCommand([
'content:export',
'taxonomy_vocabulary',
]);
$this->assertSame(1, $process->wait());
$this->assertStringContainsString('taxonomy_vocabulary is not a content entity type.', $process->getOutput());
$content = Node::loadMultiple();
$this->assertNotEmpty($content);
$command = [
'content:export',
'node',
];
// With no `--dir` option, we should get an error.
$process = $this->runDrupalCommand($command);
$this->assertGreaterThan(0, $process->wait());
$this->assertStringContainsString('The --dir option is required to export multiple entities', $process->getErrorOutput());
$command[] = "--dir=public://content";
$process = $this->runDrupalCommand($command);
$this->assertSame(0, $process->wait());
$expected_output_dir = $this->container
->get(FileSystemInterface::class)
->realpath('public://content');
$this->assertStringContainsString(count($content) . ' entities were exported to ', $process->getOutput());
/** @var \Drupal\node\NodeInterface $node */
foreach ($content as $node) {
$this->assertFileExists($expected_output_dir . '/node/' . $node->uuid() . '.yml');
}
}
/**
* Tests exporting entities filtered by bundle.
*/
public function testExportEntitiesFilteredByBundle() : void {
$command = [
'content:export',
'node',
'--bundle=article',
];
// With no `--dir` option, we should get an error.
$process = $this->runDrupalCommand($command);
$this->assertGreaterThan(0, $process->wait());
$this->assertStringContainsString('The --dir option is required to export multiple entities', $process->getErrorOutput());
$command[] = "--dir=public://content";
$process = $this->runDrupalCommand($command);
$this->assertSame(0, $process->wait());
$expected_output_dir = $this->container
->get(FileSystemInterface::class)
->realpath('public://content');
$this->assertStringContainsString('2 entities were exported to ', $process->getOutput());
$this->assertFileExists($expected_output_dir . '/node/2d3581c3-92c7-4600-8991-a0d4b3741198.yml');
$this->assertFileExists($expected_output_dir . '/node/e1714f23-70c0-4493-8e92-af1901771921.yml');
// Create two additional taxonomy vocabularies, with two terms each, to
// test multiple `--bundle` options.
$vocabulary1 = $this->createVocabulary();
$vocabulary2 = $this->createVocabulary();
$term1 = $this->createTerm($vocabulary1)
->uuid();
$term2 = $this->createTerm($vocabulary1)
->uuid();
$term3 = $this->createTerm($vocabulary2)
->uuid();
$term4 = $this->createTerm($vocabulary2)
->uuid();
$process = $this->runDrupalCommand([
'content:export',
'taxonomy_term',
'--bundle=tags',
'--bundle=' . $vocabulary2->id(),
'--dir=public://content',
]);
$this->assertSame(0, $process->wait());
$this->assertStringContainsString('4 entities were exported to ', $process->getOutput());
$tags = $this->container
->get(EntityTypeManagerInterface::class)
->getStorage('taxonomy_term')
->loadByProperties([
'vid' => 'tags',
]);
$this->assertCount(2, $tags);
foreach ($tags as $tag) {
$this->assertFileExists($expected_output_dir . '/taxonomy_term/' . $tag->uuid() . '.yml');
}
$this->assertFileDoesNotExist($expected_output_dir . '/taxonomy_term/' . $term1 . '.yml');
$this->assertFileDoesNotExist($expected_output_dir . '/taxonomy_term/' . $term2 . '.yml');
$this->assertFileExists($expected_output_dir . '/taxonomy_term/' . $term3 . '.yml');
$this->assertFileExists($expected_output_dir . '/taxonomy_term/' . $term4 . '.yml');
// Export a single entity, with the bundle filter matching the entity's
// bundle.
$process = $this->runDrupalCommand([
'content:export',
'taxonomy_term',
1,
'--bundle=tags',
]);
$this->assertSame(0, $process->wait());
// If we try that with a mismatched bundle filter, it should result in no
// entity being exported, which is an error, but a hint should be given.
$process = $this->runDrupalCommand([
'content:export',
'taxonomy_term',
1,
'--bundle=' . $vocabulary1->id(),
]);
$this->assertSame(1, $process->wait());
$output = $process->getOutput();
$this->assertStringContainsString('taxonomy_term 1 does not exist.', $output);
$this->assertStringContainsString('Maybe this entity is not one of the specified bundles: ' . $vocabulary1->id(), $output);
// We should get an error if we try to export bundles that don't exist.
$process = $this->runDrupalCommand([
'content:export',
'taxonomy_term',
'--bundle=junk',
'--bundle=tags',
]);
$this->assertSame(1, $process->wait());
$this->assertStringContainsString('These bundles do not exist on the taxonomy_term entity type: junk', $process->getOutput());
}
}
Members
| Title Sort descending | Deprecated | Modifiers | Object type | Summary | Member alias | Overriden Title |
|---|---|---|---|---|---|---|
| BlockCreationTrait::placeBlock | protected | function | Creates a block instance based on default settings. | Aliased as: drupalPlaceBlock | ||
| BodyFieldCreationTrait::createBodyField | protected | function | Creates a field of an body field storage on the specified bundle. | |||
| BrowserHtmlDebugTrait::$htmlOutputBaseUrl | protected | property | The Base URI to use for links to the output files. | |||
| BrowserHtmlDebugTrait::$htmlOutputClassName | protected | property | Class name for HTML output logging. | |||
| BrowserHtmlDebugTrait::$htmlOutputCounter | protected | property | Counter for HTML output logging. | |||
| BrowserHtmlDebugTrait::$htmlOutputCounterStorage | protected | property | Counter storage for HTML output logging. | |||
| BrowserHtmlDebugTrait::$htmlOutputDirectory | protected | property | Directory name for HTML output logging. | |||
| BrowserHtmlDebugTrait::$htmlOutputEnabled | protected | property | HTML output enabled. | |||
| BrowserHtmlDebugTrait::$htmlOutputTestId | protected | property | HTML output test ID. | |||
| BrowserHtmlDebugTrait::formatHtmlOutputHeaders | protected | function | Formats HTTP headers as string for HTML output logging. | |||
| BrowserHtmlDebugTrait::getHtmlOutputHeaders | protected | function | Returns headers in HTML output format. | |||
| BrowserHtmlDebugTrait::getResponseLogHandler | protected | function | Provides a Guzzle middleware handler to log every response received. | |||
| BrowserHtmlDebugTrait::htmlOutput | protected | function | Logs a HTML output message in a text file. | |||
| BrowserHtmlDebugTrait::initBrowserOutputFile | protected | function | Creates the directory to store browser output. | |||
| BrowserTestBase::$baseUrl | protected | property | The base URL. | |||
| BrowserTestBase::$configImporter | protected | property | The config importer that can be used in a test. | |||
| BrowserTestBase::$mink | protected | property | Mink session manager. | |||
| BrowserTestBase::$minkDefaultDriverArgs | protected | property | Mink default driver params. | |||
| BrowserTestBase::$minkDefaultDriverClass | protected | property | Mink class for the default driver to use. | |||
| BrowserTestBase::$modules | protected static | property | Modules to install. | |||
| BrowserTestBase::$originalShutdownCallbacks | protected | property | The original array of shutdown function callbacks. | |||
| BrowserTestBase::$profile | protected | property | The profile to install as a basis for testing. | |||
| BrowserTestBase::$timeLimit | protected | property | Time limit in seconds for the test. | |||
| BrowserTestBase::cleanupEnvironment | protected | function | Clean up the test environment. | |||
| BrowserTestBase::config | protected | function | Configuration accessor for tests. Returns non-overridden configuration. | |||
| BrowserTestBase::filePreDeleteCallback | public static | function | Ensures test files are deletable. | |||
| BrowserTestBase::getDefaultDriverInstance | protected | function | Gets an instance of the default Mink driver. | |||
| BrowserTestBase::getDrupalSettings | protected | function | Gets the JavaScript drupalSettings variable for the currently-loaded page. | |||
| BrowserTestBase::getHttpClient | protected | function | Obtain the HTTP client for the system under test. | |||
| BrowserTestBase::getMinkDriverArgs | protected | function | Gets the Mink driver args from an environment variable. | |||
| BrowserTestBase::getOptions | Deprecated | protected | function | Helper function to get the options of select field. | ||
| BrowserTestBase::getSession | public | function | Returns Mink session. | |||
| BrowserTestBase::getSessionCookies | protected | function | Get session cookies from current session. | |||
| BrowserTestBase::getTestMethodCaller | protected | function | Retrieves the current calling line in the class under test. | Overrides BrowserHtmlDebugTrait::getTestMethodCaller | ||
| BrowserTestBase::initFrontPage | protected | function | Visits the front page when initializing Mink. | |||
| BrowserTestBase::initMink | protected | function | Initializes Mink sessions. | |||
| BrowserTestBase::installDrupal | public | function | Installs Drupal into the test site. | |||
| BrowserTestBase::registerSessions | protected | function | Registers additional Mink sessions. | |||
| BrowserTestBase::setDebugDumpHandler | public static | function | Registers the dumper CLI handler when the DebugDump extension is enabled. | |||
| BrowserTestBase::setUpAppRoot | protected | function | Sets up the root application path. | |||
| BrowserTestBase::tearDown | protected | function | ||||
| BrowserTestBase::translatePostValues | protected | function | Transforms a nested array into a flat array suitable for submitForm(). | |||
| BrowserTestBase::xpath | protected | function | Performs an xpath search on the contents of the internal browser. | |||
| BrowserTestBase::__construct | public | function | ||||
| BrowserTestBase::__sleep | public | function | Prevents serializing any properties. | |||
| ConfigTestTrait::configImporter | protected | function | Returns a ConfigImporter object to import test configuration. | |||
| ConfigTestTrait::copyConfig | protected | function | Copies configuration objects from source storage to target storage. | |||
| ContentExportTest::$adminUser | private | property | The user account which is doing the content import and export. | |||
| ContentExportTest::$contentDir | private | property | The directory where the default content is located. | |||
| ContentExportTest::$defaultTheme | protected | property | The theme to install as the default for testing. | Overrides BrowserTestBase::$defaultTheme | ||
| ContentExportTest::$finder | private | property | Scans for content in the fixture. | |||
| ContentExportTest::doTestCircularDependency | protected | function | Tests that the exporter handles circular dependencies gracefully. | |||
| ContentExportTest::doTestExportedPasswordIsPreserved | protected | function | Tests that an exported user account can be logged in with after import. | |||
| ContentExportTest::doTestExportEntitiesFilteredByType | protected | function | Tests exporting entities filtered by type. | |||
| ContentExportTest::doTestExportFileEntityWithMissingPhysicalFile | protected | function | Tests exporting file entities without an accompanying physical file. | |||
| ContentExportTest::doTestExportSingleEntityToDirectory | protected | function | Tests exporting a single entity to a directory with attachments. | |||
| ContentExportTest::doTestExportWithDependencies | protected | function | Tests exporting a piece of content with its dependencies. | |||
| ContentExportTest::doTestMissingDependenciesAreLogged | protected | function | Tests that the exporter handles missing dependencies gracefully. | |||
| ContentExportTest::setUp | protected | function | Overrides BrowserTestBase::setUp | |||
| ContentExportTest::testEntityExportScenarios | public | function | Tests various entity export scenarios. | |||
| ContentExportTest::testExportContent | public | function | Ensures that all imported content can be exported properly. | |||
| ContentExportTest::testExportEntitiesFilteredByBundle | public | function | Tests exporting entities filtered by bundle. | |||
| ContentTypeCreationTrait::createContentType | protected | function | Creates a custom content type based on default settings. | Aliased as: drupalCreateContentType | ||
| DrupalTestCaseTrait::checkErrorHandlerOnTearDown | public | function | Checks the test error handler after test execution. | |||
| EntityReferenceFieldCreationTrait::createEntityReferenceField | protected | function | Creates a field of an entity reference field storage on the specified bundle. | |||
| ExpectDeprecationTrait::expectDeprecation | Deprecated | public | function | Adds an expected deprecation. | ||
| ExpectDeprecationTrait::regularExpressionForFormatDescription | private | function | ||||
| ExtensionListTestTrait::getModulePath | protected | function | Gets the path for the specified module. | |||
| ExtensionListTestTrait::getThemePath | protected | function | Gets the path for the specified theme. | |||
| FunctionalTestSetupTrait::$apcuEnsureUniquePrefix | protected | property | The flag to set 'apcu_ensure_unique_prefix' setting. | |||
| FunctionalTestSetupTrait::$classLoader | protected | property | The class loader to use for installation and initialization of setup. | |||
| FunctionalTestSetupTrait::$rootUser | protected | property | The "#1" admin user. | |||
| FunctionalTestSetupTrait::$usesSuperUserAccessPolicy | protected | property | Set to TRUE to make user 1 a super user. | |||
| FunctionalTestSetupTrait::doInstall | protected | function | Execute the non-interactive installer. | |||
| FunctionalTestSetupTrait::initConfig | protected | function | Initialize various configurations post-installation. | |||
| FunctionalTestSetupTrait::initKernel | protected | function | Initializes the kernel after installation. | |||
| FunctionalTestSetupTrait::initSettings | protected | function | Initialize settings created during install. | |||
| FunctionalTestSetupTrait::initUserSession | protected | function | Initializes user 1 for the site to be installed. | |||
| FunctionalTestSetupTrait::installDefaultThemeFromClassProperty | protected | function | Installs the default theme defined by `static::$defaultTheme` when needed. | |||
| FunctionalTestSetupTrait::installModulesFromClassProperty | protected | function | Install modules defined by `static::$modules`. | |||
| FunctionalTestSetupTrait::installParameters | protected | function | Returns the parameters that will be used when the test installs Drupal. | |||
| FunctionalTestSetupTrait::prepareEnvironment | protected | function | Prepares the current environment for running the test. | |||
| FunctionalTestSetupTrait::prepareRequestForGenerator | protected | function | Creates a mock request and sets it on the generator. | |||
| FunctionalTestSetupTrait::prepareSettings | protected | function | Prepares site settings and services before installation. | |||
| FunctionalTestSetupTrait::rebuildAll | protected | function | Resets and rebuilds the environment after setup. | |||
| FunctionalTestSetupTrait::rebuildContainer | protected | function | Rebuilds \Drupal::getContainer(). | |||
| FunctionalTestSetupTrait::resetAll | protected | function | Resets all data structures after having enabled new modules. | |||
| FunctionalTestSetupTrait::setContainerParameter | protected | function | Changes parameters in the services.yml file. | |||
| FunctionalTestSetupTrait::setupBaseUrl | protected | function | Sets up the base URL based upon the environment variable. | |||
| FunctionalTestSetupTrait::writeSettings | protected | function | Rewrites the settings.php file of the test site. | |||
| NodeCreationTrait::createNode | protected | function | Creates a node based on default settings. | Aliased as: drupalCreateNode | ||
| NodeCreationTrait::getNodeByTitle | public | function | Get a node from the database based on its title. | Aliased as: drupalGetNodeByTitle | ||
| RandomGeneratorTrait::getRandomGenerator | protected | function | Gets the random generator for the utility methods. | |||
| RandomGeneratorTrait::randomMachineName | protected | function | Generates a unique random string containing letters and numbers. | |||
| RandomGeneratorTrait::randomObject | public | function | Generates a random PHP object. | |||
| RandomGeneratorTrait::randomString | public | function | Generates a pseudo-random string of ASCII characters of codes 32 to 126. | |||
| RecipeTestTrait::alterRecipe | protected | function | Alters an existing recipe. | |||
| RecipeTestTrait::applyRecipe | protected | function | Applies a recipe to the site. | |||
| RecipeTestTrait::createRecipe | protected | function | Creates a recipe in a temporary directory. | |||
| RecipeTestTrait::runDrupalCommand | protected | function | Runs the `core/scripts/drupal` script with the given arguments. | |||
| RefreshVariablesTrait::refreshVariables | protected | function | Refreshes in-memory configuration and state information. | |||
| SessionTestTrait::$sessionName | protected | property | The name of the session cookie. | |||
| SessionTestTrait::generateSessionName | protected | function | Generates a session cookie name. | |||
| SessionTestTrait::getSessionName | protected | function | Returns the session name in use on the child site. | |||
| StorageCopyTrait::replaceStorageContents | protected static | function | Copy the configuration from one storage to another and remove stale items. | |||
| TaxonomyTestTrait::createTaxonomyTermRevision | protected | function | Creates a new revision for a given taxonomy term. | |||
| TaxonomyTestTrait::createTerm | protected | function | Returns a new term with random properties given a vocabulary. | |||
| TaxonomyTestTrait::createVocabulary | protected | function | Returns a new vocabulary with random properties. | |||
| TestRequirementsTrait::getDrupalRoot | protected static | function | Returns the Drupal root directory. | |||
| TestSetupTrait::$configSchemaCheckerExclusions | protected static | property | An array of config object names that are excluded from schema checking. | |||
| TestSetupTrait::$databasePrefix | protected | property | The database prefix of this test run. | |||
| TestSetupTrait::$kernel | protected | property | The DrupalKernel instance used in the test. | |||
| TestSetupTrait::$originalSite | protected | property | The site directory of the original parent site. | |||
| TestSetupTrait::$privateContainer | private | property | Stores the container in case it is set before available with \Drupal. | |||
| TestSetupTrait::$privateFilesDirectory | protected | property | The private file directory for the test environment. | |||
| TestSetupTrait::$publicFilesDirectory | protected | property | The public file directory for the test environment. | |||
| TestSetupTrait::$root | protected | property | The app root. | |||
| TestSetupTrait::$siteDirectory | protected | property | The site directory of this test run. | |||
| TestSetupTrait::$strictConfigSchema | protected | property | Set to TRUE to strict check all configuration saved. | |||
| TestSetupTrait::$tempFilesDirectory | protected | property | The temporary file directory for the test environment. | |||
| TestSetupTrait::$testId | protected | property | The test run ID. | |||
| TestSetupTrait::changeDatabasePrefix | protected | function | Changes the database connection to the prefixed one. | |||
| TestSetupTrait::getConfigSchemaExclusions | protected | function | Gets the config schema exclusions for this test. | |||
| TestSetupTrait::prepareDatabasePrefix | protected | function | Generates a database prefix for running tests. | |||
| TestSetupTrait::__get | public | function | Implements the magic method for getting object properties. | |||
| TestSetupTrait::__set | public | function | Implements the magic method for setting object properties. | |||
| UiHelperTrait::$loggedInUser | protected | property | The current user logged in using the Mink controlled browser. | |||
| UiHelperTrait::$maximumMetaRefreshCount | protected | property | The number of meta refresh redirects to follow, or NULL if unlimited. | |||
| UiHelperTrait::$metaRefreshCount | protected | property | The number of meta refresh redirects followed during ::drupalGet(). | |||
| UiHelperTrait::$useOneTimeLoginLinks | protected | property | Use one-time login links instead of submitting the login form. | |||
| UiHelperTrait::assertSession | public | function | Returns WebAssert object. | |||
| UiHelperTrait::buildUrl | protected | function | Builds an absolute URL from a system path or a URL object. | |||
| UiHelperTrait::checkForMetaRefresh | protected | function | Checks for meta refresh tag and if found call drupalGet() recursively. | |||
| UiHelperTrait::click | protected | function | Clicks the element with the given CSS selector. | |||
| UiHelperTrait::clickLink | protected | function | Follows a link by complete name. | |||
| UiHelperTrait::cssSelect | protected | function | Searches elements using a CSS selector in the raw content. | |||
| UiHelperTrait::cssSelectToXpath | protected | function | Translates a CSS expression to its XPath equivalent. | |||
| UiHelperTrait::drupalGet | protected | function | Retrieves a Drupal path or an absolute path. | |||
| UiHelperTrait::drupalLogin | protected | function | Logs in a user using the Mink controlled browser. | |||
| UiHelperTrait::drupalLogout | protected | function | Logs a user out of the Mink controlled browser and confirms. | |||
| UiHelperTrait::drupalResetSession | protected | function | Resets the current active session back to Anonymous session. | |||
| UiHelperTrait::drupalUserIsLoggedIn | protected | function | Returns whether a given user account is logged in. | |||
| UiHelperTrait::getAbsoluteUrl | protected | function | Takes a path and returns an absolute path. | |||
| UiHelperTrait::getTextContent | protected | function | Retrieves the plain-text content from the current page. | |||
| UiHelperTrait::getUrl | protected | function | Get the current URL from the browser. | |||
| UiHelperTrait::isTestUsingGuzzleClient | protected | function | Determines if test is using DrupalTestBrowser. | |||
| UiHelperTrait::prepareRequest | protected | function | Prepare for a request to testing site. | |||
| UiHelperTrait::submitForm | protected | function | Fills and submits a form. | |||
| UserCreationTrait::checkPermissions | protected | function | Checks whether a given list of permission names is valid. | |||
| UserCreationTrait::createAdminRole | protected | function | Creates an administrative role. | |||
| UserCreationTrait::createRole | protected | function | Creates a role with specified permissions. | Aliased as: drupalCreateRole | ||
| UserCreationTrait::createUser | protected | function | Create a user with a given set of permissions. | Aliased as: drupalCreateUser | ||
| UserCreationTrait::grantPermissions | protected | function | Grant permissions to a user role. | |||
| UserCreationTrait::setCurrentUser | protected | function | Switch the current logged in user. | |||
| UserCreationTrait::setUpCurrentUser | protected | function | Creates a random user account and sets it as current user. | |||
| XdebugRequestTrait::extractCookiesFromRequest | protected | function | Adds xdebug cookies, from request setup. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.