1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Tests for media entity controllers.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Defines media entity creation and management test cases.
|
10
|
*/
|
11
|
class MediaEntityTest extends MediaTestHelper {
|
12
|
|
13
|
/**
|
14
|
* Provides test information.
|
15
|
*/
|
16
|
public static function getInfo() {
|
17
|
return array(
|
18
|
'name' => 'Media entity',
|
19
|
'description' => 'Tests media entity handling',
|
20
|
'group' => 'Media',
|
21
|
);
|
22
|
}
|
23
|
|
24
|
/**
|
25
|
* Test the ability to create and query media items.
|
26
|
*/
|
27
|
public function testQueryMedia() {
|
28
|
$text_files = $this->drupalGetTestFiles('text');
|
29
|
$images = $this->drupalGetTestFiles('image');
|
30
|
|
31
|
// Moves serveral images to public://
|
32
|
foreach (array_merge($text_files, $images) as $file) {
|
33
|
// file_uri_to_object triggers a fatal error to d.o testbot.
|
34
|
// lets remove for now..
|
35
|
// $file = file_uri_to_object($file->uri);
|
36
|
file_save($file);
|
37
|
}
|
38
|
|
39
|
$query = new EntityFieldQuery();
|
40
|
$query->entityCondition('entity_type', 'file');
|
41
|
$query->propertyCondition('uri', 'public://%', 'LIKE');
|
42
|
$result = $query->execute();
|
43
|
$this->assertEqual(count($result['file']), count($images) + count($text_files), 'Returned results as expected for like % condition.');
|
44
|
|
45
|
$query = new EntityFieldQuery();
|
46
|
$query->entityCondition('entity_type', 'file');
|
47
|
$query->propertyCondition('uri', '%.jpg', 'LIKE');
|
48
|
$result = $query->execute();
|
49
|
$this->assertEqual(count($result['file']), 2, 'Returned 2 results as expected for jpgs.');
|
50
|
|
51
|
$query = new EntityFieldQuery();
|
52
|
$query->entityCondition('entity_type', 'file');
|
53
|
$query->propertyCondition('type', 'image');
|
54
|
$result = $query->execute();
|
55
|
$this->assertEqual(count($result['file']), count($images), 'Returned expected results for type query.');
|
56
|
|
57
|
$query = new EntityFieldQuery();
|
58
|
$query->entityCondition('entity_type', 'file');
|
59
|
$query->propertyCondition('uri', 'http://%', 'LIKE');
|
60
|
$result = $query->execute();
|
61
|
$this->assertEqual(count($result), 0, 'Returned 0 results as expected for http scheme uris.');
|
62
|
}
|
63
|
}
|