New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] child version cascade tests (fails) #85
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,6 +87,16 @@ public static function setupBeforeClass($fixtures = 'general/base') | |
|
||
self::$staticSharedFixture['ie'] = self::$loader->getFixtureLoader(); | ||
if ($fixtures) { | ||
$ntm = self::$loader->getSession()->getWorkspace()->getNodeTypeManager(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hope it doesn't cause a problem getting the session here? (see comment on L102) |
||
if (! $ntm->hasNodeType('phpcr:versionCascade')) { | ||
$cnd = <<<END_CND | ||
[phpcr:versionCascade] > nt:unstructured | ||
- copy | ||
+ * copy | ||
END_CND; | ||
$ntm->registerNodeTypesCnd($cnd, false); | ||
} | ||
|
||
self::$staticSharedFixture['ie']->import($fixtures); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ class VersionTest extends \PHPCR\Test\BaseCase | |
private $vm; | ||
/** a versioned node */ | ||
private $version; | ||
/** a versioned child node */ | ||
private $childVersion; | ||
|
||
static public function setupBeforeClass($fixtures = '15_Versioning/base') | ||
{ | ||
|
@@ -23,15 +25,24 @@ static public function setupBeforeClass($fixtures = '15_Versioning/base') | |
$vm = self::$staticSharedFixture['session']->getWorkspace()->getVersionManager(); | ||
|
||
$node = self::$staticSharedFixture['session']->getNode('/tests_version_base/versioned'); | ||
$childNode = self::$staticSharedFixture['session']->getNode('/tests_version_base/versioned/version_child'); | ||
self::$staticSharedFixture['session']->save(); | ||
|
||
$vm->checkpoint('/tests_version_base/versioned'); | ||
$node->setProperty('foo', 'bar'); | ||
$childNode->setProperty('foo_c', 'bar_c'); | ||
self::$staticSharedFixture['session']->save(); | ||
|
||
$vm->checkpoint('/tests_version_base/versioned'); | ||
$node->setProperty('foo', 'bar2'); | ||
$childNode->setProperty('foo_c', 'bar2_c'); | ||
self::$staticSharedFixture['session']->save(); | ||
|
||
$vm->checkpoint('/tests_version_base/versioned'); | ||
$node->setProperty('foo', 'bar3'); | ||
$childNode->setProperty('foo_c', 'bar3_c'); | ||
self::$staticSharedFixture['session']->save(); | ||
|
||
$vm->checkin('/tests_version_base/versioned'); | ||
self::$staticSharedFixture['session'] = self::$loader->getSession(); //reset the session | ||
} | ||
|
@@ -43,6 +54,7 @@ public function setUp() | |
$this->vm = $this->sharedFixture['session']->getWorkspace()->getVersionManager(); | ||
|
||
$this->version = $this->vm->getBaseVersion('/tests_version_base/versioned'); | ||
$this->childVersion = $this->vm->getBaseVersion('/tests_version_base/versioned/version_child'); | ||
|
||
$this->assertInstanceOf('PHPCR\Version\VersionInterface', $this->version); | ||
} | ||
|
@@ -52,6 +64,11 @@ public function testGetContainingHistory() | |
$this->assertSame($this->vm->getVersionHistory('/tests_version_base/versioned'), $this->version->getContainingHistory()); | ||
} | ||
|
||
public function testGetContainingChildHistory() | ||
{ | ||
$this->assertSame($this->vm->getVersionHistory('/tests_version_base/versioned/version_child'), $this->childVersion->getContainingHistory()); | ||
} | ||
|
||
public function testGetCreated() | ||
{ | ||
$date = $this->version->getCreated(); | ||
|
@@ -71,6 +88,18 @@ public function testGetFrozenNode() | |
$this->assertEquals('bar2', $frozen2->getPropertyValue('foo')); | ||
} | ||
|
||
public function testGetFrozenChildNode() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. all the asserts here will currently fail |
||
{ | ||
$frozen = $this->childVersion->getFrozenNode(); | ||
$this->assertTrue($frozen->hasProperty('foo_c')); | ||
$this->assertEquals('bar3_c', $frozen->getPropertyValue('foo_c')); | ||
|
||
$predecessors = $this->childVersion->getPredecessors(); | ||
$frozen2 = reset($predecessors)->getFrozenNode(); | ||
$this->assertTrue($frozen2->hasProperty('foo_c')); | ||
$this->assertEquals('bar2_c', $frozen2->getPropertyValue('foo_c')); | ||
} | ||
|
||
/** | ||
* @expectedException PHPCR\NodeType\ConstraintViolationException | ||
* @depends testGetFrozenNode | ||
|
@@ -82,6 +111,17 @@ public function testFrozenNode() | |
self::$staticSharedFixture['session']->save(); | ||
} | ||
|
||
/** | ||
* @expectedException PHPCR\NodeType\ConstraintViolationException | ||
* @depends testGetFrozenNode | ||
*/ | ||
public function testFrozenChildNode() | ||
{ | ||
$frozen = $this->childVersion->getFrozenNode(); | ||
$frozen->setProperty('foo_c', 'should not work'); | ||
self::$staticSharedFixture['session']->save(); | ||
} | ||
|
||
public function testGetLinearPredecessorSuccessor() | ||
{ | ||
$pred = $this->version->getLinearPredecessor(); | ||
|
@@ -90,19 +130,40 @@ public function testGetLinearPredecessorSuccessor() | |
$this->assertSame($this->version, $succ); | ||
} | ||
|
||
public function testGetChildLinearPredecessorSuccessor() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. currently fails |
||
{ | ||
$pred = $this->childVersion->getLinearPredecessor(); | ||
$this->assertInstanceOf('PHPCR\Version\VersionInterface', $pred); | ||
$succ = $pred->getLinearSuccessor(); | ||
$this->assertSame($this->childVersion, $succ); | ||
} | ||
|
||
public function testGetLinearPredecessorNull() | ||
{ | ||
$rootVersion = $this->vm->getVersionHistory('/tests_version_base/versioned')->getRootVersion(); | ||
// base version is at end of chain | ||
$this->assertNull($rootVersion->getLinearPredecessor()); | ||
} | ||
|
||
public function testGetChildLinearPredecessorNull() | ||
{ | ||
$rootVersion = $this->vm->getVersionHistory('/tests_version_base/versioned/version_child')->getRootVersion(); | ||
// base version is at end of chain | ||
$this->assertNull($rootVersion->getLinearPredecessor()); | ||
} | ||
|
||
public function testGetLinearSuccessorNull() | ||
{ | ||
// base version is at end of chain | ||
$this->assertNull($this->version->getLinearSuccessor()); | ||
} | ||
|
||
public function testGetChildLinearSuccessorNull() | ||
{ | ||
// base version is at end of chain | ||
$this->assertNull($this->childVersion->getLinearSuccessor()); | ||
} | ||
|
||
public function testGetPredecessors() | ||
{ | ||
$versions = $this->version->getPredecessors(); | ||
|
@@ -114,12 +175,29 @@ public function testGetPredecessors() | |
$this->assertSame($this->version, $versions[0]); | ||
} | ||
|
||
public function testGetChildPredecessors() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. currently fails |
||
{ | ||
$versions = $this->childVersion->getPredecessors(); | ||
$this->assertEquals(1, count($versions)); | ||
$pred = $versions[0]; | ||
$this->assertInstanceOf('PHPCR\Version\VersionInterface', $pred); | ||
$versions = $pred->getSuccessors(); | ||
$this->assertEquals(1, count($versions), 'expected a successor of our predecessor'); | ||
$this->assertSame($this->childVersion, $versions[0]); | ||
} | ||
|
||
public function testGetSuccessors() | ||
{ | ||
$versions = $this->version->getSuccessors(); | ||
$this->assertEquals(0, count($versions)); | ||
} | ||
|
||
public function testGetChildSuccessors() | ||
{ | ||
$versions = $this->childVersion->getSuccessors(); | ||
$this->assertEquals(0, count($versions)); | ||
} | ||
|
||
/** | ||
* Check $version->remove() is not possible. This must go through VersionHistory::remove | ||
* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The child can probably can be nt:unstructured rather than phpcr:versionCascade...