diff options
Diffstat (limited to 'engine')
-rw-r--r-- | engine/tests/objects/entities.php | 63 | ||||
-rw-r--r-- | engine/tests/objects/objects.php | 65 | ||||
-rw-r--r-- | engine/tests/objects/sites.php | 3 | ||||
-rw-r--r-- | engine/tests/objects/users.php | 1 |
4 files changed, 68 insertions, 64 deletions
diff --git a/engine/tests/objects/entities.php b/engine/tests/objects/entities.php index 44d16c852..1504c2f93 100644 --- a/engine/tests/objects/entities.php +++ b/engine/tests/objects/entities.php @@ -37,27 +37,28 @@ class ElggCoreEntityTest extends ElggCoreUnitTest { $test_attributes['access_id'] = ACCESS_PRIVATE; $test_attributes['time_created'] = ''; $test_attributes['time_updated'] = ''; + $test_attributes['last_action'] = ''; $test_attributes['enabled'] = 'yes'; $test_attributes['tables_split'] = 1; $test_attributes['tables_loaded'] = 0; $this->assertIdentical($this->entity->expose_attributes(), $test_attributes); } - + public function testElggEntityGetAndSetBaseAttributes() { // explicitly set and get access_id $this->assertIdentical($this->entity->get('access_id'), ACCESS_PRIVATE); $this->assertTrue($this->entity->set('access_id', ACCESS_PUBLIC)); $this->assertIdentical($this->entity->get('access_id'), ACCESS_PUBLIC); - + // check internal attributes array $attributes = $this->entity->expose_attributes(); $this->assertIdentical($attributes['access_id'], ACCESS_PUBLIC); - + // implicitly set and get access_id $this->entity->access_id = ACCESS_PRIVATE; $this->assertIdentical($this->entity->access_id, ACCESS_PRIVATE); - + // unset access_id unset($this->entity->access_id); $this->assertIdentical($this->entity->access_id, ''); @@ -66,10 +67,10 @@ class ElggCoreEntityTest extends ElggCoreUnitTest { $this->assertFalse($this->entity->set('guid', 'error')); $this->entity->guid = 'error'; $this->assertNotEqual($this->entity->guid, 'error'); - + // fail on non-attribute $this->assertNull($this->entity->get('non_existent')); - + // consider helper methods $this->assertIdentical($this->entity->getGUID(), $this->entity->guid ); $this->assertIdentical($this->entity->getType(), $this->entity->type ); @@ -79,20 +80,20 @@ class ElggCoreEntityTest extends ElggCoreUnitTest { $this->assertIdentical($this->entity->getTimeCreated(), $this->entity->time_created ); $this->assertIdentical($this->entity->getTimeUpdated(), $this->entity->time_updated ); } - + public function testElggEntityGetAndSetMetaData() { // ensure metadata not set $this->assertNull($this->entity->get('non_existent')); $this->assertFalse(isset($this->entity->non_existent)); - + // create metadata $this->assertTrue($this->entity->non_existent = 'testing'); - + // check metadata set $this->assertTrue(isset($this->entity->non_existent)); $this->assertIdentical($this->entity->non_existent, 'testing'); $this->assertIdentical($this->entity->getMetaData('non_existent'), 'testing'); - + // check internal metadata array $metadata = $this->entity->expose_metadata(); $this->assertIdentical($metadata['non_existent'], 'testing'); @@ -114,7 +115,7 @@ class ElggCoreEntityTest extends ElggCoreUnitTest { $this->assertIsA($annotations[0], 'ElggAnnotation'); $this->assertIdentical($annotations[0]->name, 'non_existent'); $this->assertEqual($this->entity->countAnnotations('non_existent'), 1); - + // clear annotation $this->assertTrue($this->entity->clearAnnotations()); $this->assertEqual($this->entity->countAnnotations('non_existent'), 0); @@ -122,22 +123,22 @@ class ElggCoreEntityTest extends ElggCoreUnitTest { // clean up $this->assertTrue($this->entity->delete()); } - + public function testElggEntityCache() { global $ENTITY_CACHE; $ENTITY_CACHE = NULL; - + $this->assertNull($ENTITY_CACHE); initialise_entity_cache(); $this->assertIsA($ENTITY_CACHE, 'array'); } - + public function testElggEntitySaveAndDelete() { global $ENTITY_CACHE; - + // unable to delete with no guid $this->assertFalse($this->entity->delete()); - + // error on save try { $this->entity->save(); @@ -146,53 +147,53 @@ class ElggCoreEntityTest extends ElggCoreUnitTest { $this->assertIsA($e, 'InvalidParameterException'); $this->assertIdentical($e->getMessage(), elgg_echo('InvalidParameterException:EntityTypeNotSet')); } - + // set elements $this->entity->type = 'site'; $this->entity->non_existent = 'testing'; - + // save $this->AssertEqual($this->entity->getGUID(), 0); $guid = $this->entity->save(); $this->AssertNotEqual($guid, 0); - + // check guid $this->AssertEqual($this->entity->getGUID(), $guid); $attributes = $this->entity->expose_attributes(); $this->AssertEqual($attributes['guid'], $guid); $this->AssertIdentical($ENTITY_CACHE[$guid], $this->entity); - + // check metadata $metadata = $this->entity->expose_metadata(); $this->AssertFalse(in_array('non_existent', $metadata)); $this->AssertEqual($this->entity->get('non_existent'), 'testing'); - + // clean up with delete $this->assertTrue($this->entity->delete()); } - + public function testElggEntityDisableAndEnable() { global $CONFIG; - + // ensure enabled $this->assertTrue($this->entity->isEnabled()); - + // false on disable $this->assertFalse($this->entity->disable()); - + // save and disable $this->save_entity(); $this->assertTrue($this->entity->disable()); - + // ensure disabled by comparing directly with database $entity = get_data_row("SELECT * FROM {$CONFIG->dbprefix}entities WHERE guid = '{$this->entity->guid}'"); $this->assertIdentical($entity->enabled, 'no'); - + // re-enable for deletion to work $this->assertTrue($this->entity->enable()); $this->assertTrue($this->entity->delete()); } - + public function testElggEntityExportables() { $exportables = array( 'guid', @@ -204,7 +205,7 @@ class ElggCoreEntityTest extends ElggCoreUnitTest { 'owner_guid', 'site_guid' ); - + $this->assertIdentical($exportables, $this->entity->getExportableValues()); } @@ -220,11 +221,11 @@ class ElggEntityTest extends ElggEntity { public function __construct() { $this->initialise_attributes(); } - + public function expose_attributes() { return $this->attributes; } - + public function expose_metadata() { return $this->temp_metadata; } diff --git a/engine/tests/objects/objects.php b/engine/tests/objects/objects.php index dd4beb075..171566661 100644 --- a/engine/tests/objects/objects.php +++ b/engine/tests/objects/objects.php @@ -49,6 +49,7 @@ class ElggCoreObjectTest extends ElggCoreUnitTest { $attributes['access_id'] = ACCESS_PRIVATE; $attributes['time_created'] = ''; $attributes['time_updated'] = ''; + $attributes['last_action'] = ''; $attributes['enabled'] = 'yes'; $attributes['tables_split'] = 2; $attributes['tables_loaded'] = 0; @@ -57,30 +58,30 @@ class ElggCoreObjectTest extends ElggCoreUnitTest { $this->assertIdentical($this->entity->expose_attributes(), $attributes); } - + public function testElggObjectSave() { // new object $this->AssertEqual($this->entity->getGUID(), 0); $guid = $this->entity->save(); $this->AssertNotEqual($guid, 0); - + $entity_row = $this->get_entity_row($guid); $this->assertIsA($entity_row, 'stdClass'); - + // update existing object $this->entity->title = 'testing'; $this->entity->description = 'ElggObject'; $this->assertEqual($this->entity->save(), $guid); - + $object_row = $this->get_object_row($guid); $this->assertIsA($object_row, 'stdClass'); $this->assertIdentical($object_row->title, 'testing'); $this->assertIdentical($object_row->description, 'ElggObject'); - + // clean up $this->entity->delete(); } - + public function testElggObjectLoad() { // fail on wrong type try { @@ -92,18 +93,18 @@ class ElggCoreObjectTest extends ElggCoreUnitTest { $this->assertIdentical($e->getMessage(), $message); } } - + public function testElggObjectConstructorByGUID() { $guid = $this->entity->save(); - + // load a new object using guid $entity = new ElggObjectTest($guid); $this->assertIdentical($this->entity, $entity); - + // clean up $this->entity->delete(); } - + public function testElggObjectClone() { $this->entity->title = 'testing'; $this->entity->description = 'ElggObject'; @@ -111,54 +112,54 @@ class ElggCoreObjectTest extends ElggCoreUnitTest { $this->entity->var2 = 1; $this->entity->var3 = true; $this->entity->save(); - + // add tag array $tag_string = 'tag1, tag2, tag3'; $tagarray = string_to_tag_array($tag_string); $this->entity->tags = $tagarray; - + // a cloned ElggEntity has the guid reset $object = clone $this->entity; $this->assertIdentical(0, (int)$object->guid); - + // make sure attributes were copied over $this->assertIdentical($object->title, 'testing'); $this->assertIdentical($object->description, 'ElggObject'); - + $guid = $object->save(); $this->assertTrue($guid !== 0); $this->assertTrue($guid !== $this->entity->guid); - + // test that metadata was transfered $this->assertIdentical($this->entity->var1, $object->var1); $this->assertIdentical($this->entity->var2, $object->var2); $this->assertIdentical($this->entity->var3, $object->var3); $this->assertIdentical($this->entity->tags, $object->tags); - + // clean up $object->delete(); $this->entity->delete(); } - + public function testElggObjectContainer() { $this->assertEqual($this->entity->getContainer(), get_loggedin_userid()); - + // fals when container not a group $this->assertFalse($this->entity->getContainerEntity()); - + // create and save to group $group = new ElggGroup(); $guid = $group->save(); $this->assertTrue($this->entity->setContainer($guid)); - + // check container $this->assertEqual($this->entity->getContainer(), $guid); $this->assertIdentical($group, $this->entity->getContainerEntity()); - + // clean up $group->delete(); } - + public function testElggObjectExportables() { $exportables = array( 'guid', @@ -172,16 +173,16 @@ class ElggCoreObjectTest extends ElggCoreUnitTest { 'title', 'description' ); - + $this->assertIdentical($exportables, $this->entity->getExportableValues()); } - public function xtestElggObjectAccessOverrides() { - // set entity to private access with no owner. - $entity = $this->entity; - $entity->access_id = ACCESS_PRIVATE; + public function xtestElggObjectAccessOverrides() { + // set entity to private access with no owner. + $entity = $this->entity; + $entity->access_id = ACCESS_PRIVATE; $entity->owner_guid = 0; - $this->assertTrue($entity->save()); + $this->assertTrue($entity->save()); $guid = $entity->getGUID(); var_dump($guid); @@ -191,16 +192,16 @@ class ElggCoreObjectTest extends ElggCoreUnitTest { var_dump($entity); $this->assertFalse($entity); - $old = elgg_set_ignore_access(true); + $old = elgg_set_ignore_access(true); } - - + + protected function get_object_row($guid) { global $CONFIG; return get_data_row("SELECT * FROM {$CONFIG->dbprefix}objects_entity WHERE guid='$guid'"); } - + protected function get_entity_row($guid) { global $CONFIG; return get_data_row("SELECT * FROM {$CONFIG->dbprefix}entities WHERE guid='$guid'"); diff --git a/engine/tests/objects/sites.php b/engine/tests/objects/sites.php index 696ae3da1..5e23c99ca 100644 --- a/engine/tests/objects/sites.php +++ b/engine/tests/objects/sites.php @@ -52,6 +52,7 @@ class ElggCoreSiteTest extends ElggCoreUnitTest { $attributes['access_id'] = ACCESS_PRIVATE; $attributes['time_created'] = ''; $attributes['time_updated'] = ''; + $attributes['last_action'] = ''; $attributes['enabled'] = 'yes'; $attributes['tables_split'] = 2; $attributes['tables_loaded'] = 0; @@ -61,7 +62,7 @@ class ElggCoreSiteTest extends ElggCoreUnitTest { $this->assertIdentical($this->site->expose_attributes(), $attributes); } - + public function testElggSiteSaveAndDelete() { $this->assertTrue($this->site->save()); $this->assertTrue($this->site->delete()); diff --git a/engine/tests/objects/users.php b/engine/tests/objects/users.php index d6d73a37b..81f02af5b 100644 --- a/engine/tests/objects/users.php +++ b/engine/tests/objects/users.php @@ -57,6 +57,7 @@ class ElggCoreUserTest extends ElggCoreUnitTest { $attributes['access_id'] = ACCESS_PRIVATE; $attributes['time_created'] = ''; $attributes['time_updated'] = ''; + $attributes['last_action'] = ''; $attributes['enabled'] = 'yes'; $attributes['tables_split'] = 2; $attributes['tables_loaded'] = 0; |