setUpFixtures example


  protected function setUp($import_test_views = TRUE): void {
    parent::setUp();

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

    if ($import_test_views) {
      ViewTestData::createTestViews(static::class['views_test_config']);
    }
  }

  /** * Sets up the configuration and schema of views and views_test_data modules. * * Because the schema of views_test_data.module is dependent on the test * using it, it cannot be enabled normally. */
/** * A regular user account. * * @var \Drupal\user\UserInterface */
  protected $regularUser;

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

    $this->installEntitySchema('user');
    $this->installEntitySchema('node');
    $this->installSchema('node', 'node_access');

    $type = NodeType::create(['type' => 'test']);
    $type->save();

    $this->editorUser = $this->createUser(['bypass node access']);
    $this->powerUser = $this->createUser(['access content', 'create test content', 'edit own test content', 'delete own test content']);
    $this->regularUser = $this->createUser(['access content']);

    
/** * @var \Drupal\user\Entity\User */
  protected $rootUser;

  /** * {@inheritdoc} */
  protected function setUpFixtures() {
    $this->installEntitySchema('user');
    $this->installConfig(['user']);
    parent::setUpFixtures();

    // Create a record for uid 1.     $this->rootUser = User::create(['name' => $this->randomMachineName()]);
    $this->rootUser->save();

    Views::viewsData()->clear();
  }

  /** * Overrides \Drupal\views\Tests\ViewTestBase::schemaDefinition(). * * Adds a uid column to test the relationships. * * @internal */
$this->installEntitySchema('user');
    $this->installEntitySchema('node');
    $this->installEntitySchema('comment');
    $this->installSchema('comment', ['comment_entity_statistics']);
    $this->installConfig(['system', 'field', 'node', 'comment']);

    NodeType::create([
      'type' => 'page',
      'name' => 'Page',
    ])->save();
    $this->addDefaultCommentField('node', 'page');
    parent::setUpFixtures();

    $this->installConfig(['filter']);
  }

  /** * Tests the views.executable container service. */
  public function testFactoryService() {
    $factory = $this->container->get('views.executable');
    $this->assertInstanceOf(ViewExecutableFactory::class$factory);
    $view = View::load('test_executable_displays');
    
$_ENV['APP_ENV'] = $_SERVER['APP_ENV'];
        $_SERVER['FEATURE_ALL'] = self::$featureAllValue;
        $_ENV['FEATURE_ALL'] = $_SERVER['FEATURE_ALL'];

        unset($_SERVER['FEATURE_NEXT_101']$_SERVER['FEATURE_NEXT_102']);

        KernelLifecycleManager::bootKernel(true, self::$customCacheId);
    }

    public function testABoolGetsReturned(): void
    {
        $this->setUpFixtures();
        static::assertFalse(Feature::isActive('FEATURE_NEXT_102'));
        $_SERVER['FEATURE_NEXT_102'] = '1';
        static::assertTrue(Feature::isActive('FEATURE_NEXT_102'));
    }

    public function testHasFunction(): void
    {
        $this->setUpFixtures();

        static::assertFalse(Feature::has('not-existing'));
        static::assertTrue(Feature::has('FEATURE_NEXT_102'));
    }
'theme' => 'olivero',
      'plugin' => 'system_branding_block',
      'weight' => 1,
    ]);

    $this->placeBlock('system_powered_by_block', [
      'id' => 'id_olivero_powered',
      'theme' => 'olivero',
      'weight' => 2,
    ]);

    parent::setUpFixtures();
  }

  /** * Tests the order of the handlers. */
  public function testAreaOrder() {
    $view = Views::getView('test_area_order');
    $renderable = $view->buildRenderable();
    $output = $this->render($renderable);

    $position_powered = strpos($output, 'block-id-olivero-powered');
    
'id' => 'test_role',
      'label' => 'Can view test entities',
      'permissions' => ['view test entity'],
    ])->save();

    $this->user = User::create([
      'name' => 'test user',
      'roles' => ['test_role'],
    ]);
    $this->user->save();

    parent::setUpFixtures();
  }

  /** * Tests the default rendered entity output. */
  public function testRenderedEntityWithoutField() {
    \Drupal::currentUser()->setAccount($this->user);

    EntityViewDisplay::load('entity_test.entity_test.foobar')
      ->removeComponent('test_field')
      ->save();

    
protected function setUpFixtures() {
    // Install the themes used for this test.     $this->container->get('theme_installer')->install(['olivero']);
    $this->container->get('config.factory')->getEditable('system.theme')->set('default', 'olivero')->save();

    $this->installEntitySchema('user');
    $this->installEntitySchema('entity_test');
    $this->installConfig(['entity_test']);

    $this->placeBlock('system_main_block', ['id' => 'test_block']);

    parent::setUpFixtures();
  }

  /** * Tests views data for entity area handlers. */
  public function testEntityAreaData() {
    $data = $this->container->get('views.views_data')->get('views');
    $entity_types = $this->container->get('entity_type.manager')->getDefinitions();

    $expected_entities = array_filter($entity_typesfunction DEntityTypeInterface $entity_type) {
      return $entity_type->hasViewBuilderClass();
    });
/** * An admin user account. * * @var \Drupal\user\UserInterface */
  protected $adminUser;

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

    // Create the anonymous user account and set it as current user.     $this->setUpCurrentUser(['uid' => 0]);

    $this->installEntitySchema('entity_test');
    $this->installConfig(['user']);

    // Create some test entities.     for ($i = 0; $i < 5; $i++) {
      EntityTest::create(['name' => $this->randomString()])->save();
    }

    
Home | Imprint | This part of the site doesn't use cookies.