diff options
author | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-03-26 14:31:14 +0000 |
---|---|---|
committer | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-03-26 14:31:14 +0000 |
commit | f48bd5099f033cc148f9c1e3f781f8c932bda891 (patch) | |
tree | c8bb185a0dd5fa3923aebae7b2d72a0bb9991c78 /engine/tests | |
parent | 962164b97ca11d9ce155bde60f198d226ff060d3 (diff) | |
download | elgg-f48bd5099f033cc148f9c1e3f781f8c932bda891.tar.gz elgg-f48bd5099f033cc148f9c1e3f781f8c932bda891.tar.bz2 |
Closes #3202 'count' already supported, added unit tests
git-svn-id: http://code.elgg.org/elgg/trunk@8840 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/tests')
-rw-r--r-- | engine/tests/api/annotations.php | 46 | ||||
-rw-r--r-- | engine/tests/api/metadata.php (renamed from engine/tests/objects/metadata.php) | 23 |
2 files changed, 67 insertions, 2 deletions
diff --git a/engine/tests/api/annotations.php b/engine/tests/api/annotations.php new file mode 100644 index 000000000..d7551a0fa --- /dev/null +++ b/engine/tests/api/annotations.php @@ -0,0 +1,46 @@ +<?php +/** + * Elgg Test annotation api + * + * @package Elgg + * @subpackage Test + */ +class ElggCoreAnnotationAPITest extends ElggCoreUnitTest { + protected $metastrings; + + /** + * Called before each test method. + */ + public function setUp() { + $this->object = new ElggObject(); + } + + /** + * Called after each test method. + */ + public function tearDown() { + // do not allow SimpleTest to interpret Elgg notices as exceptions + $this->swallowErrors(); + + unset($this->object); + } + + public function testElggGetAnnotationsCount() { + $this->object->title = 'Annotation Unit Test'; + $this->object->save(); + + $guid = $this->object->getGUID(); + create_annotation($guid, 'tested', 'tested1', 'text', 0, ACCESS_PUBLIC); + create_annotation($guid, 'tested', 'tested2', 'text', 0, ACCESS_PUBLIC); + + $count = (int)elgg_get_annotations(array( + 'annotation_names' => array('tested'), + 'guid' => $guid, + 'count' => true, + )); + + $this->assertIdentical($count, 2); + + $this->object->delete(); + } +} diff --git a/engine/tests/objects/metadata.php b/engine/tests/api/metadata.php index b5b9aba02..d9113b68a 100644 --- a/engine/tests/objects/metadata.php +++ b/engine/tests/api/metadata.php @@ -1,11 +1,11 @@ <?php /** - * Elgg Test ElggMetadata + * Elgg Test metadata API * * @package Elgg * @subpackage Test */ -class ElggCoreMetadataTest extends ElggCoreUnitTest { +class ElggCoreMetadataAPITest extends ElggCoreUnitTest { protected $metastrings; /** @@ -87,6 +87,25 @@ class ElggCoreMetadataTest extends ElggCoreUnitTest { $this->object->delete(); } + public function testElggGetMetadataCount() { + $this->object->title = 'Meta Unit Test'; + $this->object->save(); + + $guid = $this->object->getGUID(); + create_metadata($guid, 'tested', 'tested1', 'text', 0, ACCESS_PUBLIC, true); + create_metadata($guid, 'tested', 'tested2', 'text', 0, ACCESS_PUBLIC, true); + + $count = (int)elgg_get_metadata(array( + 'metadata_names' => array('tested'), + 'guid' => $guid, + 'count' => true, + )); + + $this->assertIdentical($count, 2); + + $this->object->delete(); + } + protected function create_metastring($string) { global $CONFIG, $METASTRINGS_CACHE, $METASTRINGS_DEADNAME_CACHE; |