From 1c0bda3d9868cf62788eaf88317af35326e0b4e7 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Tue, 8 Nov 2011 06:45:18 -0500 Subject: it is GPL General Public License not GPL Public License --- engine/tests/api/plugins.php | 16 ++++++++-------- engine/tests/test_files/plugin_17/manifest.xml | 4 ++-- engine/tests/test_files/plugin_18/manifest.xml | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'engine/tests') diff --git a/engine/tests/api/plugins.php b/engine/tests/api/plugins.php index 8f5f5dd1e..a0faaff0e 100644 --- a/engine/tests/api/plugins.php +++ b/engine/tests/api/plugins.php @@ -68,8 +68,8 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest { 'blurb' => 'A concise description.', 'description' => 'A longer, more interesting description.', 'website' => 'http://www.elgg.org/', - 'copyright' => '(C) Elgg 2010', - 'license' => 'GNU Public License version 2', + 'copyright' => '(C) Elgg Foundation 2011', + 'license' => 'GNU General Public License version 2', 'requires' => array( array('type' => 'elgg_version', 'version' => '3009030802', 'comparison' => 'lt'), @@ -117,8 +117,8 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest { 'version' => '1.0', 'description' => 'A 1.7-style manifest.', 'website' => 'http://www.elgg.org/', - 'copyright' => '(C) Elgg 2010', - 'license' => 'GNU Public License version 2', + 'copyright' => '(C) Elgg Foundation 2011', + 'license' => 'GNU General Public License version 2', 'elgg_version' => '2009030702', 'name' => 'Plugin Test 17', ); @@ -165,13 +165,13 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest { } public function testElggPluginManifestGetCopyright() { - $this->assertEqual($this->manifest18->getCopyright(), '(C) Elgg 2010'); - $this->assertEqual($this->manifest18->getCopyright(), '(C) Elgg 2010'); + $this->assertEqual($this->manifest18->getCopyright(), '(C) Elgg Foundation 2011'); + $this->assertEqual($this->manifest18->getCopyright(), '(C) Elgg Foundation 2011'); } public function testElggPluginManifestGetLicense() { - $this->assertEqual($this->manifest18->getLicense(), 'GNU Public License version 2'); - $this->assertEqual($this->manifest17->getLicense(), 'GNU Public License version 2'); + $this->assertEqual($this->manifest18->getLicense(), 'GNU General Public License version 2'); + $this->assertEqual($this->manifest17->getLicense(), 'GNU General Public License version 2'); } diff --git a/engine/tests/test_files/plugin_17/manifest.xml b/engine/tests/test_files/plugin_17/manifest.xml index bb178ab93..706734265 100644 --- a/engine/tests/test_files/plugin_17/manifest.xml +++ b/engine/tests/test_files/plugin_17/manifest.xml @@ -4,7 +4,7 @@ - - + + \ No newline at end of file diff --git a/engine/tests/test_files/plugin_18/manifest.xml b/engine/tests/test_files/plugin_18/manifest.xml index 445a41c2e..e0776ffc1 100644 --- a/engine/tests/test_files/plugin_18/manifest.xml +++ b/engine/tests/test_files/plugin_18/manifest.xml @@ -6,8 +6,8 @@ A concise description. A longer, more interesting description. http://www.elgg.org/ - (C) Elgg 2010 - GNU Public License version 2 + (C) Elgg Foundation 2011 + GNU General Public License version 2 elgg_version -- cgit v1.2.3 From 1403d4978bd0f9944aabc86520d49815c0fdce29 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Thu, 17 Nov 2011 07:49:25 -0500 Subject: Fixes #4094, #4095 fixes casting issues in unit tests - thanks to andres.fortier --- engine/tests/objects/entities.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'engine/tests') diff --git a/engine/tests/objects/entities.php b/engine/tests/objects/entities.php index c13b4c731..e010a3fa7 100644 --- a/engine/tests/objects/entities.php +++ b/engine/tests/objects/entities.php @@ -89,21 +89,21 @@ class ElggCoreEntityTest extends ElggCoreUnitTest { $this->assertFalse(isset($this->entity->non_existent)); // create metadata - $this->assertTrue($this->entity->non_existent = 'testing'); + $this->entity->existent = 'testing'; + $this->assertIdentical($this->entity->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'); + $this->assertTrue(isset($this->entity->existent)); + $this->assertIdentical($this->entity->getMetaData('existent'), 'testing'); // check internal metadata array $metadata = $this->entity->expose_metadata(); - $this->assertIdentical($metadata['non_existent'], 'testing'); + $this->assertIdentical($metadata['existent'], 'testing'); } public function testElggEnityGetAndSetAnnotations() { $this->assertFalse(array_key_exists('non_existent', $this->entity->expose_annotations())); - $this->assertFalse($this->entity->getAnnotations('non_existent')); + $this->assertIdentical($this->entity->getAnnotations('non_existent'), array()); // set and check temp annotation $this->assertTrue($this->entity->annotate('non_existent', 'testing')); -- cgit v1.2.3 From 1dc08335584dac4630fd7fdf638bb6c6e0d85cb3 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Thu, 17 Nov 2011 22:18:42 -0500 Subject: Fixes #4120 metadata tests now check for the correct types --- engine/tests/api/metadata.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engine/tests') diff --git a/engine/tests/api/metadata.php b/engine/tests/api/metadata.php index 7897b8d47..f5b615ca8 100644 --- a/engine/tests/api/metadata.php +++ b/engine/tests/api/metadata.php @@ -58,11 +58,11 @@ class ElggCoreMetadataAPITest extends ElggCoreUnitTest { $this->create_metastring('tested'); // create_metadata returns id of metadata on success - $this->assertTrue(create_metadata($this->object->guid, 'metaUnitTest', 'tested')); + $this->assertNotEqual(false, create_metadata($this->object->guid, 'metaUnitTest', 'tested')); // check value with improper case $options = array('metadata_names' => 'metaUnitTest', 'metadata_values' => 'Tested', 'limit' => 10, 'metadata_case_sensitive' => TRUE); - $this->assertFalse(elgg_get_entities_from_metadata($options)); + $this->assertIdentical(array(), elgg_get_entities_from_metadata($options)); // compare forced case with ignored case $options = array('metadata_names' => 'metaUnitTest', 'metadata_values' => 'tested', 'limit' => 10, 'metadata_case_sensitive' => TRUE); -- cgit v1.2.3 From d792a0987ef0c3f292c038effded241793b32b73 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Fri, 18 Nov 2011 06:25:25 -0500 Subject: Fixes #4114 checking type for acl test --- engine/tests/api/access_collections.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engine/tests') diff --git a/engine/tests/api/access_collections.php b/engine/tests/api/access_collections.php index 0c37fa779..7875b1409 100644 --- a/engine/tests/api/access_collections.php +++ b/engine/tests/api/access_collections.php @@ -76,7 +76,7 @@ class ElggCoreAccessCollectionsTest extends ElggCoreUnitTest { $q = "SELECT * FROM {$this->dbPrefix}access_collections WHERE id = $acl_id"; $data = get_data($q); - $this->assertFalse($data); + $this->assertIdentical(array(), $data); } } -- cgit v1.2.3 From e1b2cf3b9499f0a5a649e4695f7a26d3a3bf6ddb Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Fri, 18 Nov 2011 06:33:17 -0500 Subject: Fixes #4104, #4105 fixed casting in testElggEntityMetadata() --- engine/tests/objects/entities.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'engine/tests') diff --git a/engine/tests/objects/entities.php b/engine/tests/objects/entities.php index e010a3fa7..06bc80a4a 100644 --- a/engine/tests/objects/entities.php +++ b/engine/tests/objects/entities.php @@ -230,24 +230,26 @@ class ElggCoreEntityTest extends ElggCoreUnitTest { // let's delete a non-existent metadata $this->assertFalse($this->entity->deleteMetadata('important')); - // let's add the meatadata - $this->assertTrue($this->entity->important = 'indeed!'); - $this->assertTrue($this->entity->less_important = 'true, too!'); + // let's add the metadata + $this->entity->important = 'indeed!'; + $this->assertIdentical('indeed!', $this->entity->important); + $this->entity->less_important = 'true, too!'; + $this->assertIdentical('true, too!', $this->entity->less_important); $this->save_entity(); // test deleting incorrectly // @link http://trac.elgg.org/ticket/2273 - $this->assertFalse($this->entity->deleteMetadata('impotent')); + $this->assertNull($this->entity->deleteMetadata('impotent')); $this->assertEqual($this->entity->important, 'indeed!'); // get rid of one metadata $this->assertEqual($this->entity->important, 'indeed!'); $this->assertTrue($this->entity->deleteMetadata('important')); - $this->assertEqual($this->entity->important, ''); + $this->assertNull($this->entity->important); // get rid of all metadata $this->assertTrue($this->entity->deleteMetadata()); - $this->assertEqual($this->entity->less_important, ''); + $this->assertNull($this->entity->less_important); // clean up database $this->assertTrue($this->entity->delete()); -- cgit v1.2.3 From 51e2a993373b9f39c1c2b7f308dd308d320feb0a Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Fri, 18 Nov 2011 06:42:45 -0500 Subject: Fixes #4108 delete() returns bool now and updated unit tests --- engine/lib/entities.php | 2 +- engine/tests/objects/entities.php | 2 +- engine/tests/objects/sites.php | 6 ++++-- engine/tests/objects/users.php | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) (limited to 'engine/tests') diff --git a/engine/lib/entities.php b/engine/lib/entities.php index fd2b0e9f9..d8db88462 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -1563,7 +1563,7 @@ function delete_entity($guid, $recursive = true) { } } - return $res; + return (bool)$res; } } } diff --git a/engine/tests/objects/entities.php b/engine/tests/objects/entities.php index 06bc80a4a..1772f7c1a 100644 --- a/engine/tests/objects/entities.php +++ b/engine/tests/objects/entities.php @@ -178,7 +178,7 @@ class ElggCoreEntityTest extends ElggCoreUnitTest { $this->AssertEqual($this->entity->get('non_existent'), 'testing'); // clean up with delete - $this->assertTrue($this->entity->delete()); + $this->assertIdentical(true, $this->entity->delete()); } public function testElggEntityDisableAndEnable() { diff --git a/engine/tests/objects/sites.php b/engine/tests/objects/sites.php index e5acbb3f9..a05074c59 100644 --- a/engine/tests/objects/sites.php +++ b/engine/tests/objects/sites.php @@ -66,8 +66,10 @@ class ElggCoreSiteTest extends ElggCoreUnitTest { } public function testElggSiteSaveAndDelete() { - $this->assertTrue($this->site->save()); - $this->assertTrue($this->site->delete()); + $guid = $this->site->save(); + $this->assertIsA($guid, 'int'); + $this->assertTrue($guid > 0); + $this->assertIdentical(true, $this->site->delete()); } } diff --git a/engine/tests/objects/users.php b/engine/tests/objects/users.php index d1533c3d2..901d76ac0 100644 --- a/engine/tests/objects/users.php +++ b/engine/tests/objects/users.php @@ -138,7 +138,7 @@ class ElggCoreUserTest extends ElggCoreUnitTest { $guid = $this->user->save(); // delete object - $this->assertTrue($this->user->delete()); + $this->assertIdentical(true, $this->user->delete()); // check GUID not in database $this->assertFalse($this->fetchUser($guid)); -- cgit v1.2.3 From a77a8f5c4a1e76aa9beb18a2b3c938b3082fa4a8 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Fri, 18 Nov 2011 06:46:03 -0500 Subject: Fixes #4109 remove inaccurate comment due to copy & paste --- engine/tests/api/metastrings.php | 6 ------ engine/tests/objects/sites.php | 3 --- engine/tests/objects/users.php | 3 --- engine/tests/test_skeleton.php | 3 --- 4 files changed, 15 deletions(-) (limited to 'engine/tests') diff --git a/engine/tests/api/metastrings.php b/engine/tests/api/metastrings.php index 9b5d7ee4e..0a008c6ce 100644 --- a/engine/tests/api/metastrings.php +++ b/engine/tests/api/metastrings.php @@ -68,9 +68,6 @@ class ElggCoreMetastringsTest extends ElggCoreUnitTest { parent::__destruct(); } - /** - * A basic test that will be called and fail. - */ public function testDeleteByID() { $db_prefix = elgg_get_config('dbprefix'); $annotations = $this->createAnnotations(1); @@ -101,9 +98,6 @@ class ElggCoreMetastringsTest extends ElggCoreUnitTest { } } - /** - * A basic test that will be called and fail. - */ public function testEnableDisableByID() { $db_prefix = elgg_get_config('dbprefix'); $annotations = $this->createAnnotations(1); diff --git a/engine/tests/objects/sites.php b/engine/tests/objects/sites.php index a05074c59..a01a661e3 100644 --- a/engine/tests/objects/sites.php +++ b/engine/tests/objects/sites.php @@ -36,9 +36,6 @@ class ElggCoreSiteTest extends ElggCoreUnitTest { parent::__destruct(); } - /** - * A basic test that will be called and fail. - */ public function testElggSiteConstructor() { $attributes = array(); $attributes['guid'] = NULL; diff --git a/engine/tests/objects/users.php b/engine/tests/objects/users.php index 901d76ac0..a3573acb6 100644 --- a/engine/tests/objects/users.php +++ b/engine/tests/objects/users.php @@ -41,9 +41,6 @@ class ElggCoreUserTest extends ElggCoreUnitTest { parent::__destruct(); } - /** - * A basic test that will be called and fail. - */ public function testElggUserConstructor() { $attributes = array(); $attributes['guid'] = NULL; diff --git a/engine/tests/test_skeleton.php b/engine/tests/test_skeleton.php index e5ff557e5..5a5de89bb 100644 --- a/engine/tests/test_skeleton.php +++ b/engine/tests/test_skeleton.php @@ -49,9 +49,6 @@ class ElggCoreSkeletonTest extends ElggCoreUnitTest { parent::__destruct(); } - /** - * A basic test that will be called and fail. - */ public function testFailure() { $this->assertTrue(FALSE); } -- cgit v1.2.3 From 3a9198cc650ce3d55fa6227de21b63d327c4e62f Mon Sep 17 00:00:00 2001 From: cash Date: Fri, 18 Nov 2011 17:35:32 -0500 Subject: Fixes #4122, #4123, #4124 testing for empty arrays and added some documentation for the sanity of future developers --- engine/tests/api/entity_getter_functions.php | 63 ++++++++++++++++++---------- 1 file changed, 41 insertions(+), 22 deletions(-) (limited to 'engine/tests') diff --git a/engine/tests/api/entity_getter_functions.php b/engine/tests/api/entity_getter_functions.php index e7906d3c8..a548a8e52 100644 --- a/engine/tests/api/entity_getter_functions.php +++ b/engine/tests/api/entity_getter_functions.php @@ -175,9 +175,10 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { } /** + * Get a mix of valid and invalid types * - * @param unknown_type $num - * @return unknown_type + * @param int $num + * @return array */ public function getRandomMixedTypes($num = 2) { $have_valid = $have_invalid = false; @@ -196,8 +197,8 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { * Get random mix of valid and invalid subtypes for types given. * * @param array $types - * @param unknown_type $num - * @return unknown_type + * @param int $num + * @return array */ public function getRandomMixedSubtypes(array $types, $num = 2) { $types_c = count($types); @@ -230,8 +231,8 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { /** * Creates random annotations on $entity * - * @param unknown_type $entity - * @param unknown_type $max + * @param ElggEntity $entity + * @param int $max */ public function createRandomAnnotations($entity, $max = 1) { $annotations = array(); @@ -563,7 +564,9 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { * TYPE_SUBTYPE_PAIRS ***************************/ - + /** + * Valid type, valid subtype pairs + */ public function testElggAPIGettersTSPValidTypeValidSubtype() { $type_num = 1; $subtype_num = 1; @@ -586,6 +589,9 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { } } + /** + * Valid type, multiple valid subtypes + */ public function testElggAPIGettersTSPValidTypeValidPluralSubtype() { $type_num = 1; $subtype_num = 3; @@ -608,6 +614,9 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { } } + /** + * Valid type, both valid and invalid subtypes + */ public function testElggAPIGettersTSPValidTypeMixedPluralSubtype() { $type_num = 1; $valid_subtype_num = 2; @@ -635,9 +644,6 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { } - - - /**************************** * FALSE-RETURNING TESTS **************************** @@ -652,8 +658,8 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { */ - /* - * Test invalid types. + /** + * Test invalid types with singular 'type'. */ public function testElggApiGettersInvalidTypeUsingType() { $type_arr = $this->getRandomInvalids(); @@ -667,7 +673,9 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $this->assertFalse($es); } - + /** + * Test invalid types with plural 'types'. + */ public function testElggApiGettersInvalidTypeUsingTypesAsString() { $type_arr = $this->getRandomInvalids(); $type = $type_arr[0]; @@ -680,8 +688,11 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $this->assertFalse($es); } + /** + * Test invalid types with plural 'types' and an array of a single type + */ public function testElggApiGettersInvalidTypeUsingTypesAsArray() { - $type_arr = $this->getRandomInvalids(); + $type_arr = $this->getRandomInvalids(1); $options = array( 'types' => $type_arr @@ -691,6 +702,9 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $this->assertFalse($es); } + /** + * Test invalid types with plural 'types' and an array of a two types + */ public function testElggApiGettersInvalidTypes() { $type_arr = $this->getRandomInvalids(2); @@ -1053,7 +1067,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $entities = elgg_get_entities_from_metadata($options); - $this->assertFalse($entities); + $this->assertIdentical(array(), $entities); $e->delete(); } @@ -1081,7 +1095,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $entities = elgg_get_entities_from_metadata($options); - $this->assertFalse($entities); + $this->assertIdentical(array(), $entities); $e->delete(); } @@ -1214,7 +1228,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { } } - function testElggApiGettersEntityMetadatavalueInvalidSingle() { + function testElggApiGettersEntityMetadataValueInvalidSingle() { $subtypes = $this->getRandomValidSubtypes(array('object'), 1); $subtype = $subtypes[0]; $md_name = 'test_metadata_name_' . rand(); @@ -1235,7 +1249,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $entities = elgg_get_entities_from_metadata($options); - $this->assertFalse($entities); + $this->assertIdentical(array(), $entities); $e->delete(); } @@ -1263,7 +1277,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $entities = elgg_get_entities_from_metadata($options); - $this->assertFalse($entities); + $this->assertIdentical(array(), $entities); $e->delete(); } @@ -1641,6 +1655,9 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { } } + /** + * Name value pair with valid name and invalid value + */ function testElggApiGettersEntityMetadataNVPValidNInvalidV() { $subtypes = $this->getRandomValidSubtypes(array('object'), 1); $subtype = $subtypes[0]; @@ -1676,7 +1693,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $entities = elgg_get_entities_from_metadata($options); - $this->assertFalse($entities); + $this->assertIdentical(array(), $entities); foreach ($guids as $guid) { if ($e = get_entity($guid)) { @@ -1685,7 +1702,9 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { } } - + /** + * Name value pair with invalid name and valid value + */ function testElggApiGettersEntityMetadataNVPInvalidNValidV() { $subtypes = $this->getRandomValidSubtypes(array('object'), 1); $subtype = $subtypes[0]; @@ -1721,7 +1740,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $entities = elgg_get_entities_from_metadata($options); - $this->assertFalse($entities); + $this->assertIdentical(array(), $entities); foreach ($guids as $guid) { if ($e = get_entity($guid)) { -- cgit v1.2.3 From afba00a6f029366be6ce0972042832dd3b9adaf8 Mon Sep 17 00:00:00 2001 From: cash Date: Fri, 18 Nov 2011 17:39:55 -0500 Subject: Fixes #4125 checking count correctly --- engine/tests/api/entity_getter_functions.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engine/tests') diff --git a/engine/tests/api/entity_getter_functions.php b/engine/tests/api/entity_getter_functions.php index a548a8e52..7b977da61 100644 --- a/engine/tests/api/entity_getter_functions.php +++ b/engine/tests/api/entity_getter_functions.php @@ -2102,7 +2102,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $es = elgg_get_entities_from_relationship($options); $this->assertTrue(is_array($es)); - $this->assertTrue(count($es), 1); + $this->assertIdentical(count($es), 1); foreach ($es as $e) { $this->assertEqual($guids[1], $e->guid); @@ -2134,7 +2134,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $es = elgg_get_entities_from_relationship($options); $this->assertTrue(is_array($es)); - $this->assertTrue(count($es), 1); + $this->assertIdentical(count($es), 1); foreach ($es as $e) { $this->assertEqual($guids[1], $e->guid); @@ -2170,7 +2170,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $es = elgg_get_entities_from_relationship($options); $this->assertTrue(is_array($es)); - $this->assertTrue(count($es), 1); + $this->assertIdentical(count($es), 1); foreach ($es as $e) { $this->assertEqual($guids[1], $e->guid); -- cgit v1.2.3 From 15f02eea51f0f0eb92e427b627324d58af166e5e Mon Sep 17 00:00:00 2001 From: cash Date: Fri, 18 Nov 2011 17:44:45 -0500 Subject: Fixes #4115 returning bool from remove_user_from_access_collection() --- engine/lib/access.php | 2 +- engine/tests/api/access_collections.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'engine/tests') diff --git a/engine/lib/access.php b/engine/lib/access.php index ba3820f46..08b9283cd 100644 --- a/engine/lib/access.php +++ b/engine/lib/access.php @@ -717,7 +717,7 @@ function remove_user_from_access_collection($user_guid, $collection_id) { WHERE access_collection_id = {$collection_id} AND user_guid = {$user_guid}"; - return delete_data($q); + return (bool)delete_data($q); } /** diff --git a/engine/tests/api/access_collections.php b/engine/tests/api/access_collections.php index 7875b1409..bea995a6e 100644 --- a/engine/tests/api/access_collections.php +++ b/engine/tests/api/access_collections.php @@ -88,7 +88,7 @@ class ElggCoreAccessCollectionsTest extends ElggCoreUnitTest { if ($result) { $result = remove_user_from_access_collection($this->user->guid, $acl_id); - $this->assertTrue($result); + $this->assertIdentical(true, $result); } delete_access_collection($acl_id); -- cgit v1.2.3 From c872edbb476cf0a0c742c6e7a987096e15464f00 Mon Sep 17 00:00:00 2001 From: cash Date: Fri, 18 Nov 2011 17:53:29 -0500 Subject: Fixes #4126 fixed test for checking relationship existence --- engine/tests/api/entity_getter_functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engine/tests') diff --git a/engine/tests/api/entity_getter_functions.php b/engine/tests/api/entity_getter_functions.php index 7b977da61..9db248de9 100644 --- a/engine/tests/api/entity_getter_functions.php +++ b/engine/tests/api/entity_getter_functions.php @@ -2597,7 +2597,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { foreach ($fan_entities as $fan_entity) { $this->assertTrue(in_array($fan_entity->guid, $relationships[$e->guid])); - $this->assertTrue(check_entity_relationship($fan_entity->guid, $relationship_name, $e->guid)); + $this->assertNotIdentical(false, check_entity_relationship($fan_entity->guid, $relationship_name, $e->guid)); } } } -- cgit v1.2.3 From ff907019418cd1635cba8b1c225827a20eedfe2c Mon Sep 17 00:00:00 2001 From: cash Date: Fri, 18 Nov 2011 17:59:50 -0500 Subject: Fixes #4129 fixed priority list tests --- engine/tests/api/helpers.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engine/tests') diff --git a/engine/tests/api/helpers.php b/engine/tests/api/helpers.php index f48f91faf..8896fc33f 100644 --- a/engine/tests/api/helpers.php +++ b/engine/tests/api/helpers.php @@ -351,7 +351,7 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest { $test_elements = $pl->getElements(); // make sure it's gone. - $this->assertTrue(2, count($test_elements)); + $this->assertEqual(2, count($test_elements)); $this->assertIdentical($elements[0], $test_elements[0]); $this->assertIdentical($elements[2], $test_elements[2]); } @@ -369,7 +369,7 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest { $pl->add($element, $priority); } - $this->assertTrue($pl->move($elements[-5], 10)); + $this->assertEqual($pl->move($elements[-5], 10), 10); // check it's at the new place $this->assertIdentical($elements[-5], $pl->getElement(10)); -- cgit v1.2.3 From f3b50d11966eb75c648e317ab11045913e28e56a Mon Sep 17 00:00:00 2001 From: cash Date: Fri, 18 Nov 2011 18:02:39 -0500 Subject: Fixes #4131 elgg_delete_metastring_based_object_by_id() should return a bool --- engine/lib/metastrings.php | 2 +- engine/tests/api/metastrings.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'engine/tests') diff --git a/engine/lib/metastrings.php b/engine/lib/metastrings.php index 9dccec700..9fe9b4bff 100644 --- a/engine/lib/metastrings.php +++ b/engine/lib/metastrings.php @@ -810,7 +810,7 @@ function elgg_delete_metastring_based_object_by_id($id, $type) { } if (($obj->canEdit()) && (elgg_trigger_event('delete', $type, $obj))) { - return delete_data("DELETE from $table where id=$id"); + return (bool)delete_data("DELETE from $table where id=$id"); } } diff --git a/engine/tests/api/metastrings.php b/engine/tests/api/metastrings.php index 0a008c6ce..f6870d34b 100644 --- a/engine/tests/api/metastrings.php +++ b/engine/tests/api/metastrings.php @@ -80,7 +80,7 @@ class ElggCoreMetastringsTest extends ElggCoreUnitTest { $test = get_data($q); $this->assertEqual($test[0]->id, $id); - $this->assertTrue(elgg_delete_metastring_based_object_by_id($id, $type)); + $this->assertIdentical(true, elgg_delete_metastring_based_object_by_id($id, $type)); $this->assertFalse(get_data($q)); } } -- cgit v1.2.3 From 079a7bd1cf925b2b624d0af491347f997e863d0b Mon Sep 17 00:00:00 2001 From: cash Date: Fri, 18 Nov 2011 18:05:36 -0500 Subject: Fixes #4132 fixed metastring delete by id test --- engine/tests/api/metastrings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engine/tests') diff --git a/engine/tests/api/metastrings.php b/engine/tests/api/metastrings.php index f6870d34b..a96388217 100644 --- a/engine/tests/api/metastrings.php +++ b/engine/tests/api/metastrings.php @@ -81,7 +81,7 @@ class ElggCoreMetastringsTest extends ElggCoreUnitTest { $this->assertEqual($test[0]->id, $id); $this->assertIdentical(true, elgg_delete_metastring_based_object_by_id($id, $type)); - $this->assertFalse(get_data($q)); + $this->assertIdentical(array(), get_data($q)); } } -- cgit v1.2.3 From 4a5856e451b95bc85a2f3e80d76aebbd37ec39b1 Mon Sep 17 00:00:00 2001 From: cash Date: Fri, 18 Nov 2011 18:24:27 -0500 Subject: Fixes #4133 updated type in plugin manifest test --- engine/classes/ElggPluginManifest.php | 2 +- engine/tests/api/plugins.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'engine/tests') diff --git a/engine/classes/ElggPluginManifest.php b/engine/classes/ElggPluginManifest.php index eacc16455..7592eb667 100644 --- a/engine/classes/ElggPluginManifest.php +++ b/engine/classes/ElggPluginManifest.php @@ -553,7 +553,7 @@ class ElggPluginManifest { } /** - * Returns the admin interface to use. + * Should this plugin be activated when Elgg is installed * * @return bool */ diff --git a/engine/tests/api/plugins.php b/engine/tests/api/plugins.php index a0faaff0e..ac38f34ea 100644 --- a/engine/tests/api/plugins.php +++ b/engine/tests/api/plugins.php @@ -105,7 +105,8 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest { array('type' => 'plugin', 'name' => 'facebook_connect', 'version' => 1.0), ), - 'activate_on_install' => true + // string because we are reading from a file + 'activate_on_install' => 'true', ); $this->assertEqual($this->manifest18->getManifest(), $manifest_array); -- cgit v1.2.3 From af8415b62ef7eede3666e6a050b5f1e292d7d54e Mon Sep 17 00:00:00 2001 From: cash Date: Fri, 18 Nov 2011 21:31:21 -0500 Subject: Fixes #4134 improved plugin manifest tests by using assertIdentical more --- engine/tests/api/plugins.php | 46 +++++++++++++------------- engine/tests/test_files/plugin_18/manifest.xml | 4 +-- 2 files changed, 25 insertions(+), 25 deletions(-) (limited to 'engine/tests') diff --git a/engine/tests/api/plugins.php b/engine/tests/api/plugins.php index ac38f34ea..8ecb0a46c 100644 --- a/engine/tests/api/plugins.php +++ b/engine/tests/api/plugins.php @@ -93,23 +93,23 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest { ), 'conflicts' => array( - array('type' => 'plugin', 'name' => 'profile_api', 'version' => 1.0) + array('type' => 'plugin', 'name' => 'profile_api', 'version' => '1.0') ), 'provides' => array( - array('type' => 'plugin', 'name' => 'profile_api', 'version' => 1.3), - array('type' => 'php_extension', 'name' => 'big_math', 'version' => 1.0) + array('type' => 'plugin', 'name' => 'profile_api', 'version' => '1.3'), + array('type' => 'php_extension', 'name' => 'big_math', 'version' => '1.0') ), 'suggests' => array( - array('type' => 'plugin', 'name' => 'facebook_connect', 'version' => 1.0), + array('type' => 'plugin', 'name' => 'facebook_connect', 'version' => '1.0'), ), // string because we are reading from a file 'activate_on_install' => 'true', ); - $this->assertEqual($this->manifest18->getManifest(), $manifest_array); + $this->assertIdentical($this->manifest18->getManifest(), $manifest_array); } public function testElggPluginManifest17() { @@ -124,7 +124,7 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest { 'name' => 'Plugin Test 17', ); - $this->assertEqual($this->manifest17->getManifest(), $manifest_array); + $this->assertIdentical($this->manifest17->getManifest(), $manifest_array); } @@ -181,7 +181,7 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest { array('type' => 'elgg_version', 'version' => '3009030802', 'comparison' => 'lt'), array('type' => 'elgg_release', 'version' => '1.8-svn', 'comparison' => 'ge'), array('type' => 'php_extension', 'name' => 'gd', 'version' => '', 'comparison' => '='), - array('type' => 'php_ini', 'name' => 'short_open_tag', 'value' => 'off', 'comparison' => '='), + array('type' => 'php_ini', 'name' => 'short_open_tag', 'value' => 0, 'comparison' => '='), array('type' => 'php_extension', 'name' => 'made_up', 'version' => '1.0', 'comparison' => '='), array('type' => 'plugin', 'name' => 'fake_plugin', 'version' => '1.0', 'comparison' => 'ge'), array('type' => 'plugin', 'name' => 'profile', 'version' => '1.0', 'comparison' => 'ge'), @@ -189,13 +189,13 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest { array('type' => 'priority', 'priority' => 'after', 'plugin' => 'profile'), ); - $this->assertEqual($this->package18->getManifest()->getRequires(), $requires); + $this->assertIdentical($this->package18->getManifest()->getRequires(), $requires); $requires = array( array('type' => 'elgg_version', 'version' => '2009030702', 'comparison' => 'ge') ); - $this->assertEqual($this->package17->getManifest()->getRequires(), $requires); + $this->assertIdentical($this->package17->getManifest()->getRequires(), $requires); } public function testElggPluginManifestGetSuggests() { @@ -203,11 +203,11 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest { array('type' => 'plugin', 'name' => 'facebook_connect', 'version' => '1.0', 'comparison' => 'ge'), ); - $this->assertEqual($this->package18->getManifest()->getSuggests(), $suggests); + $this->assertIdentical($this->package18->getManifest()->getSuggests(), $suggests); $suggests = array(); - $this->assertEqual($this->package17->getManifest()->getSuggests(), $suggests); + $this->assertIdentical($this->package17->getManifest()->getSuggests(), $suggests); } public function testElggPluginManifestGetDescription() { @@ -220,8 +220,8 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest { 'Admin', 'ServiceAPI' ); - $this->assertEqual($this->package18->getManifest()->getCategories(), $categories); - $this->assertEqual($this->package17->getManifest()->getCategories(), array()); + $this->assertIdentical($this->package18->getManifest()->getCategories(), $categories); + $this->assertIdentical($this->package17->getManifest()->getCategories(), array()); } public function testElggPluginManifestGetScreenshots() { @@ -230,25 +230,25 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest { array('description' => 'Fun things to do 2', 'path' => 'graphics/plugin_ss2.png'), ); - $this->assertEqual($this->package18->getManifest()->getScreenshots(), $screenshots); - $this->assertEqual($this->package17->getManifest()->getScreenshots(), array()); + $this->assertIdentical($this->package18->getManifest()->getScreenshots(), $screenshots); + $this->assertIdentical($this->package17->getManifest()->getScreenshots(), array()); } public function testElggPluginManifestGetProvides() { $provides = array( - array('type' => 'plugin', 'name' => 'profile_api', 'version' => 1.3), - array('type' => 'php_extension', 'name' => 'big_math', 'version' => 1.0), - array('type' => 'plugin', 'name' => 'plugin_18', 'version' => 1.0) + array('type' => 'plugin', 'name' => 'profile_api', 'version' => '1.3'), + array('type' => 'php_extension', 'name' => 'big_math', 'version' => '1.0'), + array('type' => 'plugin', 'name' => 'plugin_18', 'version' => '1.0') ); - $this->assertEqual($this->package18->getManifest()->getProvides(), $provides); + $this->assertIdentical($this->package18->getManifest()->getProvides(), $provides); $provides = array( array('type' => 'plugin', 'name' => 'plugin_17', 'version' => '1.0') ); - $this->assertEqual($this->package17->getManifest()->getProvides(), $provides); + $this->assertIdentical($this->package17->getManifest()->getProvides(), $provides); } public function testElggPluginManifestGetConflicts() { @@ -261,12 +261,12 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest { ) ); - $this->assertEqual($this->manifest18->getConflicts(), $conflicts); - $this->assertEqual($this->manifest17->getConflicts(), array()); + $this->assertIdentical($this->manifest18->getConflicts(), $conflicts); + $this->assertIdentical($this->manifest17->getConflicts(), array()); } public function testElggPluginManifestGetActivateOnInstall() { - $this->assertEqual($this->manifest18->getActivateOnInstall(), true); + $this->assertIdentical($this->manifest18->getActivateOnInstall(), true); } // ElggPluginPackage diff --git a/engine/tests/test_files/plugin_18/manifest.xml b/engine/tests/test_files/plugin_18/manifest.xml index e0776ffc1..9654b6422 100644 --- a/engine/tests/test_files/plugin_18/manifest.xml +++ b/engine/tests/test_files/plugin_18/manifest.xml @@ -34,8 +34,6 @@ ServiceAPI - true - php_extension gd @@ -102,4 +100,6 @@ 1.0 + true + -- cgit v1.2.3 From 0aacda8b1fa77999f4e00d73e9fd1c416d75f920 Mon Sep 17 00:00:00 2001 From: cash Date: Fri, 18 Nov 2011 21:32:11 -0500 Subject: Fixes #4128 better test of null passed to registering external files --- engine/tests/api/helpers.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engine/tests') diff --git a/engine/tests/api/helpers.php b/engine/tests/api/helpers.php index 8896fc33f..77205138d 100644 --- a/engine/tests/api/helpers.php +++ b/engine/tests/api/helpers.php @@ -127,7 +127,7 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest { $this->assertIdentical('http://test1.com', $item->url); // send a bad url - $result = @elgg_register_js('bad'); + $result = elgg_register_js('bad', null); $this->assertFalse($result); } -- cgit v1.2.3 From 6ca01c470d695c8ae309ea3475899c14cc34dd73 Mon Sep 17 00:00:00 2001 From: cash Date: Mon, 28 Nov 2011 20:41:59 -0500 Subject: forgot this unit test from a previous commit --- engine/tests/api/river.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 engine/tests/api/river.php (limited to 'engine/tests') diff --git a/engine/tests/api/river.php b/engine/tests/api/river.php new file mode 100644 index 000000000..55ddbfeec --- /dev/null +++ b/engine/tests/api/river.php @@ -0,0 +1,21 @@ +assertIdentical($result, "((rv.type = 'object') AND (rv.subtype = 'blog'))"); + + $types = array('object'); + $subtypes = array('blog', 'file'); + $result = elgg_get_river_type_subtype_where_sql('rv', $types, $subtypes, null); + $this->assertIdentical($result, "((rv.type = 'object') AND ((rv.subtype = 'blog') OR (rv.subtype = 'file')))"); + } +} -- cgit v1.2.3 From 6cc08f83225237d0cd57e0a5c0ebec0a8327aa30 Mon Sep 17 00:00:00 2001 From: cash Date: Mon, 28 Nov 2011 21:24:42 -0500 Subject: Fixes #3496 finished up this ticket by updating unit test and using more parantheses to make it clear how the OR/AND gets applied --- engine/lib/river.php | 5 +++-- engine/tests/api/river.php | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'engine/tests') diff --git a/engine/lib/river.php b/engine/lib/river.php index 02d52dea1..421813441 100644 --- a/engine/lib/river.php +++ b/engine/lib/river.php @@ -207,6 +207,8 @@ function elgg_delete_river(array $options = array()) { /** * Get river items * + * @note If using types and subtypes in a query, they are joined with an AND. + * * @param array $options * ids => INT|ARR River item id(s) * subject_guids => INT|ARR Subject guid(s) @@ -430,7 +432,6 @@ function elgg_river_get_access_sql() { * * @internal This is a simplified version of elgg_get_entity_type_subtype_where_sql() * which could be used for all queries once the subtypes have been denormalized. - * FYI: It allows types and subtypes to not be paired. * * @param string $table 'rv' * @param NULL|array $types Array of types or NULL if none. @@ -477,7 +478,7 @@ function elgg_get_river_type_subtype_where_sql($table, $types, $subtypes, $pairs } if (is_array($subtypes_wheres) && count($subtypes_wheres)) { - $subtypes_wheres = array(implode(' OR ', $subtypes_wheres)); + $subtypes_wheres = array('(' . implode(' OR ', $subtypes_wheres) . ')'); } $wheres = array(implode(' AND ', array_merge($types_wheres, $subtypes_wheres))); diff --git a/engine/tests/api/river.php b/engine/tests/api/river.php index 55ddbfeec..6931b9f41 100644 --- a/engine/tests/api/river.php +++ b/engine/tests/api/river.php @@ -11,7 +11,7 @@ class ElggCoreRiverAPITest extends ElggCoreUnitTest { $types = array('object'); $subtypes = array('blog'); $result = elgg_get_river_type_subtype_where_sql('rv', $types, $subtypes, null); - $this->assertIdentical($result, "((rv.type = 'object') AND (rv.subtype = 'blog'))"); + $this->assertIdentical($result, "((rv.type = 'object') AND ((rv.subtype = 'blog')))"); $types = array('object'); $subtypes = array('blog', 'file'); -- cgit v1.2.3 From 87e274201939458768808d3728a8fef9ef23e0d9 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sun, 4 Dec 2011 13:04:02 -0500 Subject: removed some usage of deprecated methods --- engine/tests/regression/trac_bugs.php | 2 +- mod/blog/actions/blog/auto_save_revision.php | 2 +- mod/blog/actions/blog/save.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'engine/tests') diff --git a/engine/tests/regression/trac_bugs.php b/engine/tests/regression/trac_bugs.php index 2bfc37558..99cf81774 100644 --- a/engine/tests/regression/trac_bugs.php +++ b/engine/tests/regression/trac_bugs.php @@ -45,7 +45,7 @@ class ElggCoreRegressionBugsTest extends ElggCoreUnitTest { /** * #1558 */ - public function testElggObjectClearAnnotations() { + public function testElggObjectDeleteAnnotations() { $this->entity = new ElggObject(); $guid = $this->entity->save(); diff --git a/mod/blog/actions/blog/auto_save_revision.php b/mod/blog/actions/blog/auto_save_revision.php index 1acf3b31b..66b65c5fd 100644 --- a/mod/blog/actions/blog/auto_save_revision.php +++ b/mod/blog/actions/blog/auto_save_revision.php @@ -63,7 +63,7 @@ if ($title && $description) { if (!$auto_save) { $annotation_id = $blog->annotate('blog_auto_save', $description); } elseif ($auto_save instanceof ElggAnnotation && $auto_save->value != $description) { - $blog->clearAnnotations('blog_auto_save'); + $blog->deleteAnnotations('blog_auto_save'); $annotation_id = $blog->annotate('blog_auto_save', $description); } elseif ($auto_save instanceof ElggAnnotation && $auto_save->value == $description) { // this isn't an error because we have an up to date annotation. diff --git a/mod/blog/actions/blog/save.php b/mod/blog/actions/blog/save.php index 8be67ec6c..8ca8ce846 100644 --- a/mod/blog/actions/blog/save.php +++ b/mod/blog/actions/blog/save.php @@ -131,10 +131,10 @@ if (!$error) { elgg_clear_sticky_form('blog'); // remove autosave draft if exists - $blog->clearAnnotations('blog_auto_save'); + $blog->deleteAnnotations('blog_auto_save'); // no longer a brand new post. - $blog->clearMetadata('new_post'); + $blog->deleteMetadata('new_post'); // if this was an edit, create a revision annotation if (!$new_post && $revision_text) { -- cgit v1.2.3