$media_storage = $this->container->get('entity.manager')->getStorage('media');
// Create a media type and media item.
- $media_type = $this->createMediaType();
+ $media_type = $this->createMediaType('test');
$media = $media_storage->create([
'bundle' => $media_type->id(),
'name' => 'Unnamed',
$uri = 'temporary://foo.txt';
file_put_contents($uri, $this->randomString(128));
- $this->createMediaType(['bundle' => 'file', 'new_revision' => TRUE], 'file');
+ $this->createMediaType('file', ['id' => 'file', 'new_revision' => TRUE]);
// Create a media item.
$this->drupalGet('/media/add/file');
$page->fillField('Name', 'Foobar');
$page->attachFileToField('File', $this->container->get('file_system')->realpath($uri));
$page->pressButton('Save');
- $assert->addressMatches('/^\/media\/[0-9]+$/');
+ $assert->addressEquals('admin/content/media');
// The media item was just created, so it should only have one revision.
$media = $this->container
public function testImageMediaRevision() {
$assert = $this->assertSession();
- $this->createMediaType(['bundle' => 'image', 'new_revision' => TRUE], 'image');
+ $this->createMediaType('image', ['id' => 'image', 'new_revision' => TRUE]);
/** @var \Drupal\field\FieldConfigInterface $field */
// Disable the alt text field, because this is not a JavaScript test and
$this->drupalGet('/media/add/image');
$page = $this->getSession()->getPage();
$page->fillField('Name', 'Foobar');
- $page->attachFileToField('Image', \Drupal::root() . '/core/modules/media/tests/fixtures/example_1.jpeg');
+ $page->attachFileToField('Image', $this->root . '/core/modules/media/tests/fixtures/example_1.jpeg');
$page->pressButton('Save');
- $assert->addressMatches('/^\/media\/[0-9]+$/');
+ $assert->addressEquals('admin/content/media');
// The media item was just created, so it should only have one revision.
$media = $this->container
$entity_type = $entity->getEntityType();
$count = $this->container
- ->get('entity.query')
- ->get($entity_type->id())
+ ->get('entity_type.manager')
+ ->getStorage($entity_type->id())
+ ->getQuery()
->count()
->allRevisions()
->condition($entity_type->getKey('id'), $entity->id())