diff --git a/tests/ImplementationLoader.php b/tests/ImplementationLoader.php index 63ea69f5..9da991c8 100644 --- a/tests/ImplementationLoader.php +++ b/tests/ImplementationLoader.php @@ -53,11 +53,6 @@ protected function __construct(Connection $connection, $fixturePath) 'Query\\XPath', // Query language 'xpath' not implemented. 'Query\\Sql1', // Query language 'sql' is legacy and only makes sense with jackrabbit 'Writing\\CloneMethodsTest', // TODO: Support for workspace->clone, node->update, node->getCorrespondingNodePath - - // TODO fully implement versioning - 'Versioning\\VersionHistoryTest', - 'Versioning\\VersionManagerTest', - 'Versioning\\VersionTest', ); $this->unsupportedTests = array( @@ -87,6 +82,15 @@ protected function __construct(Connection $connection, $fixturePath) // TODO: implement creating workspace with source 'WorkspaceManagement\\WorkspaceManagementTest::testCreateWorkspaceWithSource', 'WorkspaceManagement\\WorkspaceManagementTest::testCreateWorkspaceWithInvalidSource', + + // TODO: implement remove version + 'Versioning\\VersionHistoryTest::testDeleteVersion', + 'Versioning\\VersionHistoryTest::testDeleteLatestVersion', + 'Versioning\\VersionHistoryTest::testDeleteUnexistingVersion', + 'Versioning\\VersionManagerTest::testRestoreByPathAndName', + 'Versioning\\VersionManagerTest::testRestoreByVersionObject', + 'Versioning\\VersionManagerTest::testRestoreRootVersion', + 'Versioning\\VersionManagerTest::testWriteNotCheckedOutVersion', ); if ($connection->getDatabasePlatform() instanceof Doctrine\DBAL\Platforms\SqlitePlatform) { diff --git a/tests/Jackalope/Test/Fixture/DBUnitFixtureXML.php b/tests/Jackalope/Test/Fixture/DBUnitFixtureXML.php index 671fdfb3..c8330d9b 100644 --- a/tests/Jackalope/Test/Fixture/DBUnitFixtureXML.php +++ b/tests/Jackalope/Test/Fixture/DBUnitFixtureXML.php @@ -54,10 +54,10 @@ public function __construct($file, $options = null) { parent::__construct($file, $options); - $this->tables = array(); - $this->ids = array(); - $this->references = array(); - $this->expectedNodes = array(); + $this->tables = array(); + $this->ids = array(); + $this->references = array(); + $this->expectedNodes = array(); } public function addDataset() @@ -132,31 +132,31 @@ public function addRootNode($workspaceName = 'default') $this->ids[$uuid] = self::$idCounter++; return $this->addRow('phpcr_nodes', array( - 'id' => $this->ids[$uuid], - 'path' => '/', - 'parent' => '', - 'local_name' => '', - 'namespace' => '', - 'workspace_name'=> $workspaceName, - 'identifier' => $uuid, - 'type' => 'nt:unstructured', - 'props' => '' - . '', - 'depth' => 0, - 'sort_order' => 0, + 'id' => $this->ids[$uuid], + 'path' => '/', + 'parent' => '', + 'local_name' => '', + 'namespace' => '', + 'workspace_name' => $workspaceName, + 'identifier' => $uuid, + 'type' => 'nt:unstructured', + 'props' => '' + . '', + 'depth' => 0, + 'sort_order' => 0, )); } @@ -189,8 +189,8 @@ public function addNode($workspaceName, \DOMElement $node) list ($parentPath, $childPath) = $this->getPath($node); - $namespace = ''; - $name = $node->getAttributeNS($this->namespaces['sv'], 'name'); + $namespace = ''; + $name = $node->getAttributeNS($this->namespaces['sv'], 'name'); if (count($parts = explode(':', $name, 2)) == 2) { list($namespace, $name) = $parts; } @@ -206,21 +206,21 @@ public function addNode($workspaceName, \DOMElement $node) if (isset($properties['jcr:mixinTypes']) && in_array('mix:versionable', $properties['jcr:mixinTypes']['value']) ) { - $this->addVersioningProperties($dom, $phpcrNode, $workspaceName, $id); + $this->addVersioningProperties($dom, $phpcrNode, $workspaceName, $id, $uuid); } $this->addRow('phpcr_nodes', array( - 'id' => $id, - 'path' => $childPath, - 'parent' => $parentPath, - 'local_name' => $name, - 'namespace' => $namespace, - 'workspace_name'=> $workspaceName, - 'identifier' => $uuid, - 'type' => $properties['jcr:primaryType']['value'][0], - 'props' => $dom->saveXML(), - 'depth' => PathHelper::getPathDepth($childPath), - 'sort_order' => $id - 2, + 'id' => $id, + 'path' => $childPath, + 'parent' => $parentPath, + 'local_name' => $name, + 'namespace' => $namespace, + 'workspace_name' => $workspaceName, + 'identifier' => $uuid, + 'type' => $properties['jcr:primaryType']['value'][0], + 'props' => $dom->saveXML(), + 'depth' => PathHelper::getPathDepth($childPath), + 'sort_order' => $id - 2, )); return $this; @@ -329,9 +329,9 @@ public function createValueNodeByType($workspaceName, $type, $value, $id, $prope } // do not repeat references $this->references[$type][$value][$id . $propertyName . $targetId] = array( - 'source_id' => $id, - 'source_property_name' => $propertyName, - 'target_id' => $targetId, + 'source_id' => $id, + 'source_property_name' => $propertyName, + 'target_id' => $targetId, ); break; } @@ -360,7 +360,7 @@ public function createValueNode($value, \DOMDocument $dom, $length) public function getPath(\DOMElement $node) { - $childPath = ''; + $childPath = ''; $parent = $node; do { @@ -392,11 +392,11 @@ public function addBinaryNode($id, $propertyName, $workspaceName, $idx, $data) $data = base64_decode($data); $this->addRow('phpcr_binarydata', array( - 'node_id' => $id, - 'property_name' => $propertyName, - 'workspace_name' => $workspaceName, - 'idx' => $idx, - 'data' => $data, + 'node_id' => $id, + 'property_name' => $propertyName, + 'workspace_name' => $workspaceName, + 'idx' => $idx, + 'data' => $data, )); return strlen($data); @@ -435,7 +435,7 @@ protected function ensureTableExists($tableName, $columns) return $this; } - private function addVersioningProperties(\DOMDocument $dom, \DOMElement $node, $workspaceName, $id) + private function addVersioningProperties(\DOMDocument $dom, \DOMElement $node, $workspaceName, $id, $uuid) { $node->appendChild( $this->createPropertyNode( @@ -447,6 +447,7 @@ private function addVersioningProperties(\DOMDocument $dom, \DOMElement $node, $ ) ); + // version node in version storage $versionNodeUuid = UUIDHelper::generateUUID(); $versionParentPath = '/jcr:system/jcr:versionStorage'; $versionPath = $versionParentPath . '/' . $versionNodeUuid; @@ -462,12 +463,39 @@ private function addVersioningProperties(\DOMDocument $dom, \DOMElement $node, $ 'identifier' => $versionNodeUuid, 'type' => 'nt:unstructured', 'props' => '' - . '', + . '' + . '' + . '' . $versionNodeUuid . '' + . '' + . '' + . '' . $uuid . '' + . '' + . '', 'depth' => PathHelper::getPathDepth($versionPath), 'sort_order' => $id - 2, ) ); + $this->addRow( + 'phpcr_nodes_references', + array( + 'source_id' => $id, + 'source_property_name' => 'jcr:versionHistory', + 'target_id' => self::$idCounter - 1 + ) + ); + + $node->appendChild( + $this->createPropertyNode( + $workspaceName, + 'jcr:versionHistory', + array('type' => 'reference', 'value' => array($versionNodeUuid), 'multiValued' => false), + $id, + $dom + ) + ); + + // root version $rootVersionPath = $versionPath . '/jcr:rootVersion'; $rootVersionUuid = UUIDHelper::generateUUID(); $this->addRow( @@ -482,7 +510,13 @@ private function addVersioningProperties(\DOMDocument $dom, \DOMElement $node, $ 'identifier' => $rootVersionUuid, 'type' => 'nt:version', 'props' => '' - . '', + . '' + . '' + . '' . $rootVersionUuid . '' + . '' + . '' + . '' + . '', 'depth' => PathHelper::getPathDepth($rootVersionPath), 'sort_order' => $id - 2, ) @@ -491,8 +525,8 @@ private function addVersioningProperties(\DOMDocument $dom, \DOMElement $node, $ $node->appendChild( $this->createPropertyNode( $workspaceName, - 'jcr:versionHistory', - array('type' => 'reference', 'value' => array($versionNodeUuid), 'multiValued' => false), + 'jcr:baseVersion', + array('type' => 'reference', 'value' => array($rootVersionUuid), 'multiValued' => false), $id, $dom ) @@ -507,5 +541,30 @@ private function addVersioningProperties(\DOMDocument $dom, \DOMElement $node, $ $dom ) ); + + // frozen node for root version + $rootVersionFrozenNodePath = $rootVersionPath . '/jcr:frozenNode'; + $rootVersionFrozenNodeUuid = UUIDHelper::generateUUID(); + $this->addRow( + 'phpcr_nodes', + array( + 'id' => self::$idCounter++, + 'path' => $rootVersionFrozenNodePath, + 'parent' => $rootVersionPath, + 'local_name' => 'jcr:rootVersion', + 'namespace' => '', + 'workspace_name' => $workspaceName, + 'identifier' => $rootVersionFrozenNodeUuid, + 'type' => 'nt:version', + 'props' => '' + . '' + . '' + . '' . $rootVersionFrozenNodeUuid . '' + . '' + . '', + 'depth' => PathHelper::getPathDepth($rootVersionFrozenNodePath), + 'sort_order' => $id - 2, + ) + ); } }