]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Closes #3202 'count' already supported, added unit tests
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sat, 26 Mar 2011 14:31:14 +0000 (14:31 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sat, 26 Mar 2011 14:31:14 +0000 (14:31 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@8840 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/lib/annotations.php
engine/lib/metadata.php
engine/tests/api/annotations.php [new file with mode: 0644]
engine/tests/api/metadata.php [moved from engine/tests/objects/metadata.php with 85% similarity]

index 130ab37abcbb0106b642fe0d3e8c1985b214fb94..0e446c94984f628da85d7df622f487d727b78b3a 100644 (file)
@@ -536,3 +536,14 @@ function elgg_register_annotation_url_handler($extender_name = "all", $function_
 
 /** Register the hook */
 elgg_register_plugin_hook_handler("export", "all", "export_annotation_plugin_hook", 2);
+
+elgg_register_plugin_hook_handler('unit_test', 'system', 'annotations_test');
+
+/**
+ * Register annotation unit tests
+ */
+function annotations_test($hook, $type, $value, $params) {
+       global $CONFIG;
+       $value[] = $CONFIG->path . 'engine/tests/api/annotations.php';
+       return $value;
+}
index 3182ed07776e6967b475870dcf0d7f65c5abe11d..cc9212711e02b5bbe807c0bc8e1e31390de3899f 100644 (file)
@@ -900,6 +900,6 @@ elgg_register_plugin_hook_handler('unit_test', 'system', 'metadata_test');
  */
 function metadata_test($hook, $type, $value, $params) {
        global $CONFIG;
-       $value[] = $CONFIG->path . 'engine/tests/objects/metadata.php';
+       $value[] = $CONFIG->path . 'engine/tests/api/metadata.php';
        return $value;
 }
\ No newline at end of file
diff --git a/engine/tests/api/annotations.php b/engine/tests/api/annotations.php
new file mode 100644 (file)
index 0000000..d7551a0
--- /dev/null
@@ -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();
+       }
+}
similarity index 85%
rename from engine/tests/objects/metadata.php
rename to engine/tests/api/metadata.php
index b5b9aba02a04746891bdcc57a752bc72721d3dbf..d9113b68a1503369f4f5e7118a6bc65a697f0f8c 100644 (file)
@@ -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;