From 046c84212fcb91df1fc6c2d66a4e893b890845b1 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sun, 16 Mar 2014 21:01:00 -0300 Subject: Squashed 'mod/group_alias/' content from commit 1a3c9da git-subtree-dir: mod/group_alias git-subtree-split: 1a3c9da3d7b9b002d28311fe75307ace8502463c --- tests/group_alias_test.php | 99 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 tests/group_alias_test.php (limited to 'tests/group_alias_test.php') diff --git a/tests/group_alias_test.php b/tests/group_alias_test.php new file mode 100644 index 000000000..fe33bd69d --- /dev/null +++ b/tests/group_alias_test.php @@ -0,0 +1,99 @@ +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); +// } + +} -- cgit v1.2.3