initializeWorkspacesModule example

/** * Tests workspace merging. * * @covers ::merge * @covers ::getNumberOfChangesOnSource * @covers ::getNumberOfChangesOnTarget * @covers ::getDifferringRevisionIdsOnSource * @covers ::getDifferringRevisionIdsOnTarget */
  public function testWorkspaceMerger() {
    $this->initializeWorkspacesModule();
    $this->createWorkspaceHierarchy();

    // Generate content in the workspace hierarchy with the following structure:     // Live:     // - Test article 1 - live     //     // Stage:     // - Test article 2 - stage     //     // Dev:     // - Test article 2 - stage
parent::setUp();

    $this->installEntitySchema('user');
    $this->installSchema('system', ['sequences']);
    $this->createUser();

    $fields['supported_reference'] = BaseFieldDefinition::create('entity_reference')->setSetting('target_type', 'entity_test_mulrevpub');
    $fields['unsupported_reference'] = BaseFieldDefinition::create('entity_reference')->setSetting('target_type', 'entity_test');
    $this->container->get('state')->set('entity_test_mulrevpub.additional_base_field_definitions', $fields);

    $this->installEntitySchema('entity_test_mulrevpub');
    $this->initializeWorkspacesModule();
  }

  /** * @covers ::validate */
  public function testNewEntitiesAllowedInDefaultWorkspace() {
    $entity = EntityTestMulRevPub::create([
      'unsupported_reference' => [
        'entity' => EntityTest::create([]),
      ],
      'supported_reference' => [
        

  protected $revEntityTypeId = 'entity_test_revpub';

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    $this->installSchema('system', ['sequences']);

    $this->initializeWorkspacesModule();
    $this->switchToWorkspace('stage');
  }

  /** * Tests that the 'workspace' entity type can not be moderated. * * @see \Drupal\workspaces\EntityTypeInfo::entityTypeAlter() */
  public function testWorkspaceEntityTypeModeration() {
    /** @var \Drupal\content_moderation\ModerationInformationInterface $moderation_info */
    $moderation_info = \Drupal::service('content_moderation.moderation_information');
    
$this->nodes[] = $this->createNode(['title' => 'live - 2 - r2 - unpublished', 'body' => 'node 2', 'created' => $this->createdTimestamp++, 'status' => FALSE]);

    $translation = $this->nodes[0]->addTranslation('de');
    $translation->setTitle('live - 1 - r1 - published - de');
    $translation->save();
  }

  /** * Tests various scenarios for creating and publishing content in workspaces. */
  public function testWorkspaces() {
    $this->initializeWorkspacesModule();

    // Notes about the structure of the test scenarios:     // - a multi-dimensional array keyed by the workspace ID, then by the entity     // ID and finally by the revision ID.     // - 'default_revision' indicates the entity revision that should be     // returned when loading an entity, non-revision entity queries and     // non-revision views *in a given workspace*, it does not indicate what is     // actually stored in the base and data entity tables.     $test_scenarios = [];

    // The $expected_workspace_association array holds the revision IDs which
Home | Imprint | This part of the site doesn't use cookies.