1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
<?php
/**
* Elgg Regression Tests -- Trac Bugfixes
* Any bugfixes from Trac that require testing belong here.
*
* @package Elgg
* @subpackage Test
*/
class ElggCoreRegressionBugsTest extends ElggCoreUnitTest {
/**
* Called before each test object.
*/
public function __construct() {
$this->ia = elgg_set_ignore_access(TRUE);
parent::__construct();
// all __construct() code should come after here
}
/**
* Called before each test method.
*/
public function setUp() {
}
/**
* Called after each test method.
*/
public function tearDown() {
// do not allow SimpleTest to interpret Elgg notices as exceptions
$this->swallowErrors();
}
/**
* Called after each test object.
*/
public function __destruct() {
elgg_set_ignore_access($this->ia);
// all __destruct() code should go above here
parent::__destruct();
}
/**
* #1558
*/
public function testElggObjectClearAnnotations() {
$this->entity = new ElggObject();
$guid = $this->entity->save();
$this->entity->annotate('test', 'hello', ACCESS_PUBLIC);
$this->entity->deleteAnnotations('does not exist');
$num = $this->entity->countAnnotations('test');
//$this->assertIdentical($num, 1);
$this->assertEqual($num, 1);
// clean up
$this->entity->delete();
}
/**
* #2063 - get_resized_image_from_existing_file() fails asked for image larger than selection and not scaling an image up
* Test get_image_resize_parameters().
*/
public function testElggResizeImage() {
$orig_width = 100;
$orig_height = 150;
// test against selection > max
$options = array(
'maxwidth' => 50,
'maxheight' => 50,
'square' => TRUE,
'upscale' => FALSE,
'x1' => 25,
'y1' => 75,
'x2' => 100,
'y2' => 150
);
// should get back the same x/y offset == x1, y1 and an image of 50x50
$params = get_image_resize_parameters($orig_width, $orig_height, $options);
$this->assertEqual($params['newwidth'], $options['maxwidth']);
$this->assertEqual($params['newheight'], $options['maxheight']);
$this->assertEqual($params['xoffset'], $options['x1']);
$this->assertEqual($params['yoffset'], $options['y1']);
// test against selection < max
$options = array(
'maxwidth' => 50,
'maxheight' => 50,
'square' => TRUE,
'upscale' => FALSE,
'x1' => 75,
'y1' => 125,
'x2' => 100,
'y2' => 150
);
// should get back the same x/y offset == x1, y1 and an image of 25x25
$params = get_image_resize_parameters($orig_width, $orig_height, $options);
$this->assertEqual($params['newwidth'], 25);
$this->assertEqual($params['newheight'], 25);
$this->assertEqual($params['xoffset'], $options['x1']);
$this->assertEqual($params['yoffset'], $options['y1']);
}
}
|