Skip to content

Commit f409055

Browse files
committed
Added node autocreate test
1 parent 91db0ad commit f409055

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

fixtures/10_Writing/add.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,4 +201,9 @@
201201
<sv:value>nt:unstructured</sv:value>
202202
</sv:property>
203203
</sv:node>
204+
<sv:node sv:name="testAddNodeWithAutoCreatedNode">
205+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
206+
<sv:value>nt:unstructured</sv:value>
207+
</sv:property>
208+
</sv:node>
204209
</sv:node>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<test = "http://liip.to/jackalope">
2+
3+
[test:testautocreate]
4+
+ autocreatedwithchild (test:testAutoCreateChild) = test:testAutoCreateChild autocreated
5+
+ autocreated (nt:unstructured) = nt:unstructured autocreated
6+
7+
[test:testAutoCreateChild]
8+
+ foo (nt:unstructured) = nt:unstructured autocreated

tests/10_Writing/AddMethodsTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,4 +383,31 @@ public function testAddPropertyWithUnregisteredNamespace()
383383
//save the changes
384384
$this->saveAndRenewSession();
385385
}
386+
387+
public function testAddNodeWithAutoCreatedNode()
388+
{
389+
$workspace = $this->session->getWorkspace();
390+
$cnd = file_get_contents(__DIR__.'/../../fixtures/10_Writing/add_auto_create.cnd');
391+
$workspace->getNodeTypeManager()->registerNodeTypesCnd($cnd, true);
392+
$this->node->addNode('foo', 'test:testautocreate');
393+
$this->session->save();
394+
395+
$childNode = $this->session->getNode($this->node->getPath() . '/foo');
396+
$this->assertNotNull($childNode);
397+
398+
$childNode = $this->session->getNode($this->node->getPath() . '/foo/autocreated');
399+
$this->assertNotNull($childNode);
400+
$primaryType = $childNode->getPrimaryNodeType();
401+
$this->assertEquals('nt:unstructured', $primaryType->getName());
402+
403+
$childNode = $this->session->getNode($this->node->getPath() . '/foo/autocreatedwithchild');
404+
$this->assertNotNull($childNode);
405+
$primaryType = $childNode->getPrimaryNodeType();
406+
$this->assertEquals('test:testAutoCreateChild', $primaryType->getName());
407+
408+
$childNode = $this->session->getNode($this->node->getPath() . '/foo/autocreatedwithchild/foo');
409+
$this->assertNotNull($childNode);
410+
$primaryType = $childNode->getPrimaryNodeType();
411+
$this->assertEquals('nt:unstructured', $primaryType->getName());
412+
}
386413
}

0 commit comments

Comments
 (0)