first import
This commit is contained in:
64
sites/all/modules/media/test/media.entity.test
Normal file
64
sites/all/modules/media/test/media.entity.test
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests for media entity controllers.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Test media type creation and management.
|
||||
*/
|
||||
class MediaEntityTest extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Media entity',
|
||||
'description' => 'Tests media entity handling',
|
||||
'group' => 'Media',
|
||||
'dependencies' => array('ctools'),
|
||||
);
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
parent::setUp('media');
|
||||
// Nice, TDD FTW. #totalsarcasm
|
||||
variable_set('simpletest_verbose', TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the ability to create and query media items.
|
||||
*/
|
||||
function testQueryMedia() {
|
||||
$text_files = $this->drupalGetTestFiles('text');
|
||||
$images = $this->drupalGetTestFiles('image');
|
||||
// Moves serveral images to public://
|
||||
foreach (array_merge($text_files, $images) as $file) {
|
||||
$file = file_uri_to_object($file->uri);
|
||||
file_save($file);
|
||||
}
|
||||
|
||||
$query = new EntityFieldQuery();
|
||||
$query->entityCondition('entity_type', 'file');
|
||||
$query->propertyCondition('uri', 'public://%', 'LIKE');
|
||||
$result = $query->execute();
|
||||
$this->assertEqual(count($result['file']), count($images) + count($text_files), "Returned results as expected for like % condition");
|
||||
|
||||
$query = new EntityFieldQuery();
|
||||
$query->entityCondition('entity_type', 'file');
|
||||
$query->propertyCondition('uri', '%.jpg', 'LIKE');
|
||||
$result = $query->execute();
|
||||
$this->assertEqual(count($result['file']), 2, "Returned 2 results as expected for jpgs");
|
||||
|
||||
$query = new EntityFieldQuery();
|
||||
$query->entityCondition('entity_type', 'file');
|
||||
$query->propertyCondition('type', 'image');
|
||||
$result = $query->execute();
|
||||
$this->assertEqual(count($result['file']), count($images), "Returned expected results for type query");
|
||||
|
||||
$query = new EntityFieldQuery();
|
||||
$query->entityCondition('entity_type', 'file');
|
||||
$query->propertyCondition('uri', 'http://%', 'LIKE');
|
||||
$result = $query->execute();
|
||||
$this->assertEqual(count($result), 0, "Got no results for http scheme uris");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user