'Media entity', 'description' => 'Tests media entity handling', 'group' => 'Media', ); } 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_save($file); } $query = new EntityFieldQuery(); $query->entityCondition('entity_type', 'media'); $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 2 results as expected for jpgs"); $query = new EntityFieldQuery(); $query->entityCondition('entity_type', 'media'); $query->propertyCondition('type', 'image'); $result = $query->execute(); $this->assertEqual(count($result['media']), count($images), "Returned expected results for type query"); $query = new EntityFieldQuery(); $query->entityCondition('entity_type', 'media'); $query->propertyCondition('uri', 'http://%', 'LIKE'); $result = $query->execute(); $this->assertEqual(count($result), 0, "Got no results for http scheme uris"); } } ?>