Fixes for CMIUS-652 and CMIS-691
git-svn-id: https://svn.apache.org/repos/asf/chemistry/phpclient/trunk@1502932 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/README-atom b/README-atom
index ee31847..18417aa 100644
--- a/README-atom
+++ b/README-atom
@@ -49,6 +49,9 @@
The docs were built with the following command
phpdoc -t docs/atom -d atom
+Testing
+php ../utils/phpunit.phar <classname>
+php -e -d display_errors=On ../utils/phpunit.phar --debug -v <classname>
==============
Adding Calls that mimick the domain model
diff --git a/atom/cmis/cmis_service.php b/atom/cmis/cmis_service.php
index 0443dac..ede78a6 100644
--- a/atom/cmis/cmis_service.php
+++ b/atom/cmis/cmis_service.php
@@ -248,7 +248,7 @@
* @internal
*/
function getLink($objectId, $linkName) {
- if ($this->_link_cache[$objectId][$linkName]) {
+ if (isset($this->_link_cache[$objectId][$linkName])) {
return $this->_link_cache[$objectId][$linkName];
}
$obj = $this->getObject($objectId);
@@ -475,7 +475,7 @@
$myURL = $this->getLink($folderId, LINK_UP);
//TODO: Need GenURLQueryString Utility
$ret = $this->doGet($myURL);
- $obj = $this->extractObjectEntry($ret->body);
+ $obj = CMISRepositoryWrapper::extractObject($ret->body);
$this->cacheObjectInfo($obj);
return $obj;
}
@@ -989,7 +989,7 @@
} else {
$hash_values = array ();
}
- if ($this->_changeToken_cache[$objectId] != null) {
+ if (isset($this->_changeToken_cache[$objectId])) {
$properties['cmis:changeToken'] = $this->_changeToken_cache[$objectId];
}
@@ -1001,6 +1001,9 @@
}
$hash_values["PROPERTIES"] = $properties_xml;
$hash_values["SUMMARY"] = CMISService :: getSummaryTemplate();
+ if (isset($properties["cmis:name"])) {
+ $objectName=$properties["cmis:name"];
+ }
if (!isset ($hash_values['title'])) {
$hash_values['title'] = $objectName;
}
@@ -1008,7 +1011,6 @@
$hash_values['summary'] = $objectName;
}
$put_value = CMISRepositoryWrapper :: processTemplate($entry_template, $hash_values);
- // print $put_value; // RRM DEBUG
$ret = $this->doPut($obj_url, $put_value, MIME_ATOM_XML_ENTRY);
$obj = $this->extractObject($ret->body);
$this->cacheObjectInfo($obj);
diff --git a/test/atom/AlfrescoH2CMISTest.php b/test/atom/AlfrescoH2CMISTest.php
index 0f16b14..f1ead51 100644
--- a/test/atom/AlfrescoH2CMISTest.php
+++ b/test/atom/AlfrescoH2CMISTest.php
@@ -9,26 +9,61 @@
require_once('../../atom/cmis-lib.php');
class AlfrescoCMISH2Test extends PHPUnit_Framework_TestCase
{
- protected $client;
- protected function setUp() {
+ protected static $client;
+ protected static $unitTestFolder;
+ public static function setUpBeforeClass() {
+ echo "Set Up Before Class";
$repo_url = "http://localhost:8080/alfresco/cmisatom";
$repo_username = "admin";
$repo_password = "admin";
- $this->client = new CMISService($repo_url, $repo_username, $repo_password);
+ AlfrescoCMISH2Test::$client = new CMISService($repo_url, $repo_username, $repo_password);
+ $rootFolder = AlfrescoCMISH2Test::$client->getObjectByPath("/");
+ $unitTestFolderHome = null;
+ try {
+ $unitTestFolderHome = AlfrescoCMISH2Test::$client->getObjectByPath("/UnitTest");
+ } catch (CmisObjectNotFoundException $x) {
+ $unitTestFolderHome = AlfrescoCMISH2Test::$client->createFolder($rootFolder->id,"UnitTest");
+ }
+ AlfrescoCMISH2Test::$unitTestFolder = AlfrescoCMISH2Test::$client->createFolder($unitTestFolderHome->id,base_convert(time(),10,36));
+ }
+ protected function setUp() {
}
public function testGetFolder() {
/*
* This test gets an known folder and tests the ability to retreive know properties
*/
- $folder = $this->client->getObjectByPath("/Sites");
+ $folder = AlfrescoCMISH2Test::$client->getObjectByPath("/Sites");
$this->assertEquals("F:st:sites",$folder->properties["cmis:objectTypeId"]);
$this->assertEquals("cmis:folder",$folder->properties["cmis:baseTypeId"]);
}
+ public function testGetFolderParent() {
+ /*
+ * This test gets an known folder and tests the ability to retreive know properties
+ */
+ $folder = AlfrescoCMISH2Test::$client->getObjectByPath("/Sites");
+ $parentFolder = AlfrescoCMISH2Test::$client->getFolderParent($folder->id);
+ $rootFolder = AlfrescoCMISH2Test::$client->getObjectByPath("/");
+ $this->assertEquals($parentFolder->id,$rootFolder->id);
+ }
/**
* @expectedException CmisObjectNotFoundException
*/
public function testInvalidCreateFolder() {
- $folder = $this->client->getObjectByPath("/x");
- $folder = $this->client->createFolder($folder->id,"TEST");
+ $folder = AlfrescoCMISH2Test::$client->getObjectByPath("/x");
+ $folder = AlfrescoCMISH2Test::$client->createFolder($folder->id,"TEST");
}
+
+ /**
+ * Create a Folder and change its name
+ * This will only work in an Alfresco Repository
+ */
+ public function testRenameFolder() {
+ $folder = AlfrescoCMISH2Test::$client->createFolder(AlfrescoCMISH2Test::$unitTestFolder->id,"TEST",array("cmis:objectTypeId" => "F:cmiscustom:folder","cmiscustom:folderprop_string" => "Original Value"));
+ $newProps = array( "cmis:name" => "Renamed Test","cmiscustom:folderprop_string" => "New Value");
+ $this->assertEquals("Original Value",$folder->properties["cmiscustom:folderprop_string"]);
+ $folder = AlfrescoCMISH2Test::$client->updateProperties($folder->id,$newProps);
+ $this->assertEquals("Renamed Test",$folder->properties["cmis:name"]);
+ $this->assertEquals("New Value",$folder->properties["cmiscustom:folderprop_string"]);
+ }
+
}
\ No newline at end of file