0010106: rename resource does not update container name
authorMichael Spahn <m.spahn@metaways.de>
Tue, 29 Jul 2014 15:24:40 +0000 (17:24 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 31 Jul 2014 08:19:39 +0000 (10:19 +0200)
* clears container cache entry on update

https://forge.tine20.org/mantisbt/view.php?id=10106

Change-Id: Ie2e10107853d03ed930f4f4cb102a441dde8c52f
Reviewed-on: http://gerrit.tine20.com/customers/912
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Michael Spahn <m.spahn@metaways.de>
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
Tested-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/Calendar/Controller/ResourceTest.php
tine20/Tinebase/Container.php

index 0874b92..342338b 100644 (file)
@@ -4,16 +4,11 @@
  * 
  * @package     Calendar
  * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
- * @copyright   Copyright (c) 2010 Metaways Infosystems GmbH (http://www.metaways.de)
+ * @copyright   Copyright (c) 2010-2014 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Cornelius Weiss <c.weiss@metaways.de>
  */
 
 /**
- * Test helper
- */
-require_once dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'TestHelper.php';
-
-/**
  * Test class for Resources related stuff
  * 
  * @package     Calendar
@@ -58,6 +53,33 @@ class Calendar_Controller_ResourceTest extends Calendar_TestCase
         return $resource;
     }
     
+    /**
+     * testRenameResource
+     * 
+     * @see 0010106: rename resource does not update container name
+     */
+    public function testRenameResource()
+    {
+        $resource = $this->_getResource();
+        $createResource = Calendar_Controller_Resource::getInstance()->create($resource);
+        
+        $calenderFrontend = new Calendar_Frontend_Json();
+        $resourceArrayFromDB = $calenderFrontend->getResource($createResource->getId());
+        $resourceArrayFromDB['name'] = 'Other Room';
+        
+        $calenderFrontend->saveResource($resourceArrayFromDB);
+        
+        $containerFrontend = new Tinebase_Frontend_Json_Container();
+        $result = $containerFrontend->getContainer('Calendar', Tinebase_Model_Container::TYPE_SHARED, '');
+        
+        foreach($result as $container) {
+            if ($container['id'] != $createResource->container_id) {
+                continue;
+            }
+            $this->assertEquals($container['name'], 'Other Room');
+        }
+    }
+    
     public function testResourceConfict()
     {
         $resource = $this->testCreateResource();
index 869fded..2ed8a76 100644 (file)
@@ -1606,4 +1606,17 @@ class Tinebase_Container extends Tinebase_Backend_Sql_Abstract
         
         return $newContainer;
     }
+
+    /**
+     * Updates existing container and clears the cache entry of the container
+     *
+     * @param Tinebase_Record_Interface $_record
+     * @return Tinebase_Record_Interface Record|NULL
+     */
+    public function update(Tinebase_Record_Interface $_record)
+    {
+        $this->_clearCache($_record);
+        
+        return parent::update($_record);
+    }
 }