Commit 7cb23b07 authored by JacobSingh's avatar JacobSingh

#975860: Removed Entity module

parent 99856ee6
......@@ -17,4 +17,3 @@ files[] = test/media.entity.test
dependencies[] = file
dependencies[] = image
dependencies[] = file_styles
dependencies[] = entity
......@@ -1091,8 +1091,6 @@ function media_entity_info() {
$return = array(
'media' => array(
'label' => t('Media'),
'entity class' => 'Media',
'controller class' => 'MediaEntityController',
'base table' => 'file_managed',
'fieldable' => TRUE,
'view modes' => $view_modes,
......
......@@ -267,24 +267,4 @@ function media_media_format_form_prepare_alter(&$form, &$form_state, $media) {
);
break;
}
}
if (!class_exists('EntityDB')) {
if (basename($_SERVER["SCRIPT_NAME"]) == 'index.php') {
// Don't show the warning if they are on update.php or running via drush.
//drupal_set_message('You must run update.php immediately to enable the entity module or Media will not function.', 'error');
}
}
else {
class Media extends EntityDB {
}
// Historically, this Entitycontroller has a point, now it is simply here
// so that the EntityAPI can be used. Media isn't really using this API much anyway
// since the main benefits are CRUD extensions and media is based on the files API
// which has its own (bad) CRUD stuff.
// @todo: remove coupling on entity API (needs issue).
class MediaEntityController extends EntityAPIController{}
}
}
\ No newline at end of file
......@@ -40,37 +40,39 @@ class MediaEntityTest extends DrupalWebTestCase {
'status' => 1,
'timestamp'=> time(),
);
$m = new Media($values);
$m->save();
return $m;
}
function testCreateMedia() {
$m = $this->createMedia('blah.jpg');
$loaded = entity_get_controller('media')->load(array($m->fid));
$media = current($loaded);
$this->assertEqual($media->filename, 'blah.jpg');
return file_save((object)$values);
}
/**
* Test the ability to create and query media items.
*/
function testQueryMedia() {
$this->createMedia('blah.jpg');
$this->createMedia('blah2.jpg');
$text_files = $this->drupalGetTestFiles('text');
$images = $this->drupalGetTestFiles('image');
// Moves serveral images to public://
foreach (array_merge($text_files, $images) as $file) {
file_save($file);
}
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'media');
$query->propertyCondition('uri', 'temporary://%', 'LIKE');
$query->propertyCondition('uri', 'public://%', 'LIKE');
$result = $query->execute();
$this->verbose(dpr($result, 1));
$this->assertEqual(count($result['media']), count($images) + count($text_files), "Returned results as expected for like % condition");
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'media');
$query->propertyCondition('uri', '%.jpg', 'LIKE');
$result = $query->execute();
$this->assertEqual(count($result['media']), 2, "Returned two results as expected for like % condition");
$this->assertEqual(count($result['media']), 2, "Returned 2 results as expected for jpgs");
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'media');
$query->propertyCondition('uri', 'temporary://blah.jpg');
$query->propertyCondition('type', 'image');
$result = $query->execute();
$this->assertEqual(count($result['media']), 1, "Got one result for equality query");
$this->assertEqual(count($result['media']), count($images), "Returned expected results for type query");
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'media');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment