entity_test_entity_types example


class EntityTranslationTest extends EntityLanguageTestBase {

  /** * Tests language related methods of the Entity class. */
  public function testEntityLanguageMethods() {
    // All entity variations have to have the same results.     foreach (entity_test_entity_types() as $entity_type) {
      $this->doTestEntityLanguageMethods($entity_type);
    }
  }

  /** * Executes the entity language method tests for the given entity type. * * @param string $entity_type * The entity type to run the tests with. */
  protected function doTestEntityLanguageMethods($entity_type) {
    
/** * Defines the local tasks for all the entity_test entities. */
class EntityTestLocalTasks extends DeriverBase {

  /** * {@inheritdoc} */
  public function getDerivativeDefinitions($base_plugin_definition) {
    $this->derivatives = [];
    $types = entity_test_entity_types(ENTITY_TEST_TYPES_ROUTING);

    foreach ($types as $entity_type) {
      $this->derivatives[$entity_type . '.canonical'] = [];
      $this->derivatives[$entity_type . '.canonical']['base_route'] = "entity.$entity_type.canonical";
      $this->derivatives[$entity_type . '.canonical']['route_name'] = "entity.$entity_type.canonical";
      $this->derivatives[$entity_type . '.canonical']['title'] = 'View';

      $this->derivatives[$entity_type . '.edit'] = [];
      $this->derivatives[$entity_type . '.edit']['base_route'] = "entity.$entity_type.canonical";
      $this->derivatives[$entity_type . '.edit']['route_name'] = "entity.$entity_type.edit_form";
      $this->derivatives[$entity_type . '.edit']['title'] = 'Edit';
    }
return $this->cachedDiscoveries;
    };
    $get_cached_discoveries = $get_cached_discoveries->bindTo($plugin_cache_clearer$plugin_cache_clearer);
    $cached_discoveries = $get_cached_discoveries();
    $cached_discovery_classes = [];
    foreach ($cached_discoveries as $cached_discovery) {
      $cached_discovery_classes[] = get_class($cached_discovery);
    }
    $this->assertContains('Drupal\Core\Validation\ConstraintManager', $cached_discovery_classes);

    // All entity variations have to have the same results.     foreach (entity_test_entity_types() as $entity_type) {
      $this->checkValidation($entity_type);
    }
  }

  /** * Executes the validation test set for a defined entity type. * * @param string $entity_type * The entity type to run the tests with. */
  protected function checkValidation($entity_type) {
    
protected function setUp(): void {
    parent::setUp();
    // Initiate the generator object.     $this->uuid = $this->container->get('uuid');
  }

  /** * Tests default values on entities and fields. */
  public function testDefaultValues() {
    // All entity variations have to have the same results.     foreach (entity_test_entity_types() as $entity_type) {
      $this->assertDefaultValues($entity_type);
    }
  }

  /** * Executes a test set for a defined entity type. * * @param string $entity_type_id * The entity type to run the tests with. * * @internal */

class EntityUUIDTest extends EntityKernelTestBase {

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

    foreach (entity_test_entity_types() as $entity_type_id) {
      // The entity_test schema is installed by the parent.       if ($entity_type_id != 'entity_test') {
        $this->installEntitySchema($entity_type_id);
      }
    }
  }

  /** * Tests UUID generation in entity CRUD operations. */
  public function testCRUD() {
    
// Enable an additional language.     ConfigurableLanguage::createFromLangcode('de')->save();
  }

  /** * Check node revision related operations. */
  public function testRevisions() {

    // All revisable entity variations have to have the same results.     foreach (entity_test_entity_types(ENTITY_TEST_TYPES_REVISABLE) as $entity_type) {
      $this->runRevisionsTests($entity_type);
    }
  }

  /** * Executes the revision tests for the given entity type. * * @param string $entity_type * The entity type to run the tests with. */
  protected function runRevisionsTests($entity_type) {
    

class EntityTestRoutes {

  /** * Returns an array of route objects. * * @return \Symfony\Component\Routing\Route[] * An array of route objects. */
  public function routes() {
    $types = entity_test_entity_types(ENTITY_TEST_TYPES_ROUTING);

    $routes = [];
    foreach ($types as $entity_type_id) {
      $routes["entity.$entity_type_id.admin_form"] = new Route(
        "$entity_type_id/structure/{bundle}",
        ['_controller' => '\Drupal\entity_test\Controller\EntityTestController::testAdmin'],
        ['_permission' => 'administer entity_test content'],
        ['_admin_route' => TRUE]
      );
    }
    return $routes;
  }
$this->drupalLogin($this->webUser);

    // Add a language.     ConfigurableLanguage::createFromLangcode('ro')->save();
  }

  /** * Tests basic form CRUD functionality. */
  public function testFormCRUD() {
    // All entity variations have to have the same results.     foreach (entity_test_entity_types() as $entity_type) {
      $this->doTestFormCRUD($entity_type);
    }
  }

  /** * Tests basic multilingual form CRUD functionality. */
  public function testMultilingualFormCRUD() {
    // All entity variations have to have the same results.     foreach (entity_test_entity_types(ENTITY_TEST_TYPES_MULTILINGUAL) as $entity_type) {
      $this->doTestMultilingualFormCRUD($entity_type);
    }
/** * {@inheritdoc} */
  protected $defaultTheme = 'stark';

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

    foreach (entity_test_entity_types() as $entity_type) {
      // Auto-create fields for testing.       FieldStorageConfig::create([
        'entity_type' => $entity_type,
        'field_name' => 'field_test_no_plugin',
        'type' => 'field_test',
        'cardinality' => 1,
      ])->save();
      FieldConfig::create([
        'entity_type' => $entity_type,
        'field_name' => 'field_test_no_plugin',
        'bundle' => $entity_type,
        
$this->assertFalse($entity->isDefaultRevision());
    $this->assertFalse($translation->isDefaultRevision());
  }

  /** * @covers \Drupal\Core\Entity\ContentEntityBase::setNewRevision */
  public function testSetNewRevision() {
    $user = $this->createUser();

    // All revisionable entity variations have to have the same results.     foreach (entity_test_entity_types(ENTITY_TEST_TYPES_REVISABLE) as $entity_type) {
      $this->installEntitySchema($entity_type);
      $storage = \Drupal::entityTypeManager()->getStorage($entity_type);

      $entity = $storage->create([
        'name' => 'foo',
        'user_id' => $user->id(),
      ]);

      $entity->save();
      $entity_id = $entity->id();
      $entity_rev_id = $entity->getRevisionId();
      

class EntityApiTest extends EntityKernelTestBase {

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

    foreach (entity_test_entity_types() as $entity_type_id) {
      // The entity_test schema is installed by the parent.       if ($entity_type_id != 'entity_test') {
        $this->installEntitySchema($entity_type_id);
      }
    }
  }

  /** * Tests basic CRUD functionality of the Entity API. */
  public function testCRUD() {
    
/** * @var string */
  protected $entityFieldText;

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

    foreach (entity_test_entity_types() as $entity_type_id) {
      // The entity_test schema is installed by the parent.       if ($entity_type_id != 'entity_test') {
        $this->installEntitySchema($entity_type_id);
      }
    }

    // Create the test field.     $this->container->get('module_handler')->loadInclude('entity_test', 'install');
    entity_test_install();

    // Install required default configuration for filter module.
protected static $modules = ['language', 'entity_test'];

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

    $this->languageManager = $this->container->get('language_manager');

    foreach (entity_test_entity_types() as $entity_type_id) {
      // The entity_test schema is installed by the parent.       if ($entity_type_id != 'entity_test') {
        $this->installEntitySchema($entity_type_id);
      }
    }

    $this->installConfig(['language']);

    // Create the test field.     $this->container->get('module_handler')->loadInclude('entity_test', 'install');
    entity_test_install();

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