blob: fe33bd69d17ad103d14a13d7c07b5ab4119fe115 (
plain)
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
|
<?php
/**
* Elgg Group Alias Tests
*
* Plugin authors: copy this file to your plugin's test directory. Register an Elgg
* plugin hook and function similar to:
*
* elgg_register_plugin_hook_handler('unit_test', 'system', 'my_new_unit_test');
*
* function my_new_unit_test($hook, $type, $value, $params) {
* $value[] = "path/to/my/unit_test.php";
* return $value;
* }
*
* @package Elgg
* @subpackage Test
*/
class ElggGroupAliasTest extends ElggCoreUnitTest {
// New group
var $new_group;
// Saved (aliased) group
var $existing_group;
/**
* Called before each test object.
*/
public function __construct() {
parent::__construct();
// all __construct() code should come after here
}
/**
* Called before each test method.
*/
public function setUp() {
$this->existing_group = new ElggGroup();
$this->existing_group->name = "Aliased Test Group";
$this->existing_group->alias = 'aliased_test_group';
$this->existing_group->save();
$this->new_group = new ElggGroup();
$this->new_group->name = 'group_alias test group';
}
/**
* Called after each test method.
*/
public function tearDown() {
// do not allow SimpleTest to interpret Elgg notices as exceptions
$this->swallowErrors();
// Remove created objects
$this->existing_group->delete();
$this->new_group->delete();
}
/**
* Called after each test object.
*/
public function __destruct() {
// all __destruct() code should go above here
parent::__destruct();
}
public function testNewGroupHasNoAlias() {
$this->assertNull($this->new_group->alias);
}
public function testGroupAliasSave() {
$this->new_group->alias = 'sample_alias';
$this->assertTrue($this->new_group->save());
$this->assertIdentical('sample_alias', $this->new_group->alias);
$this->assertNotNull($this->new_group->alias);
}
public function testGroupAliasUpdate() {
$alias = $this->existing_group->alias;
$this->assertEqual($alias, 'aliased_test_group');
$this->existing_group->set('alias', 'new_alias');
$this->assertTrue($this->existing_group->save());
$this->assertIdentical($this->existing_group->get('alias'), 'new_alias');
}
public function testGroupAliasPersistence() {
$this->existing_group->name = 'Changed Name';
$this->assertTrue($this->existing_group->save());
$this->assertIdentical($this->existing_group->alias, 'aliased_test_group');
}
// @todo: how to tell ElggGroup to save default metadata?
// public function testGroupAliasDefault() {
// $this->new_group->name = 'A group without an alias';
// $this->assertTrue($this->new_group->save());
// $this->assertIdentical('a_group_without_an_alias', $this->new_group->alias);
// }
}
|