]> source.dussan.org Git - nextcloud-server.git/commitdiff
testing update and delete
authorThomas Müller <thomas.mueller@tmit.eu>
Thu, 31 Oct 2013 10:09:52 +0000 (11:09 +0100)
committertomneedham <tom@owncloud.com>
Tue, 18 Feb 2014 17:53:16 +0000 (17:53 +0000)
tests/lib/ocs/privatedata.php

index 423bb2c96b6280c47d0c69f4209ea58b6abfb759..ea8413734f17ce916ba906b7e16dafa331af0113 100644 (file)
@@ -55,6 +55,30 @@ class Test_OC_OCS_Privatedata extends PHPUnit_Framework_TestCase
                $this->assertOcsResult(1, $result);
        }
 
+       public function testSetExisting() {
+               $_POST = array('value' => 123456789);
+               $params = array('app' => $this->appKey, 'key' => 'k-10');
+               $result = OC_OCS_Privatedata::set($params);
+               $this->assertEquals(100, $result->getStatusCode());
+
+               $result = OC_OCS_Privatedata::get($params);
+               $this->assertOcsResult(1, $result);
+               $data = $result->getData();
+               $data = $data[0];
+               $this->assertEquals('123456789', $data['value']);
+
+               $_POST = array('value' => 'updated');
+               $params = array('app' => $this->appKey, 'key' => 'k-10');
+               $result = OC_OCS_Privatedata::set($params);
+               $this->assertEquals(100, $result->getStatusCode());
+
+               $result = OC_OCS_Privatedata::get($params);
+               $this->assertOcsResult(1, $result);
+               $data = $result->getData();
+               $data = $data[0];
+               $this->assertEquals('updated', $data['value']);
+       }
+
        public function testSetMany() {
                $_POST = array('value' => 123456789);
 
@@ -74,6 +98,21 @@ class Test_OC_OCS_Privatedata extends PHPUnit_Framework_TestCase
                $this->assertOcsResult(2, $result);
        }
 
+       public function testDelete() {
+               $_POST = array('value' => 123456789);
+
+               // set key 'k-1'
+               $params = array('app' => $this->appKey, 'key' => 'k-3');
+               $result = OC_OCS_Privatedata::set($params);
+               $this->assertEquals(100, $result->getStatusCode());
+
+               $result = OC_OCS_Privatedata::delete($params);
+               $this->assertEquals(100, $result->getStatusCode());
+
+               $result = OC_OCS_Privatedata::get($params);
+               $this->assertOcsResult(0, $result);
+       }
+
        /**
         * @dataProvider deleteWithEmptyKeysProvider
         */