@@ -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