setMockedBaseFieldDefinitions example

    $definitions = $this->entityTypeManager->getDefinitions();
    $definitions[$definition->id()] = $definition;

    $cache_backend = $this->prophesize(CacheBackendInterface::class);
    $cache_data = new \StdClass();
    $cache_data->data = $definitions;
    $cache_backend->get('entity_type')->willReturn($cache_data);
    $this->entityTypeManager->setCacheBackend($cache_backend->reveal(), 'entity_type', ['entity_types']);
    $this->entityTypeManager->clearCachedDefinitions();

    if ($base_fields) {
      ViewsTestEntity::setMockedBaseFieldDefinitions($definition->id()$base_fields);
    }
  }

  /** * Tests base tables. */
  public function testBaseTables() {
    $data = $this->entityTypeManager->getHandler('entity_test', 'views_data')->getViewsData();

    $this->assertEquals('entity_test', $data['entity_test']['table']['entity type']);
    $this->assertEquals(FALSE, $data['entity_test']['table']['entity revision']);
    
Home | Imprint | This part of the site doesn't use cookies.