11<?php
22
3- namespace PHPCR \Tests \NodeTypeManagement \CND ;
4-
5- // TODO: fix coding style
3+ namespace PHPCR \Tests \PhpcrUtils ;
64
75require_once (__DIR__ . '/../../inc/BaseCase.php ' );
86
9- use PHPCR \Util \CND \Helper \NodeTypeGenerator ,
10- PHPCR \Util \CND \Reader \BufferReader ,
11- PHPCR \Util \CND \Parser \CndParser ,
12- PHPCR \Util \CND \Scanner \GenericScanner ,
13- PHPCR \Util \CND \Scanner \Context ,
14- PHPCR \PropertyType ,
15- PHPCR \Version \OnParentVersionAction ;
7+ use PHPCR \PropertyType ;
8+ use PHPCR \NodeType \PropertyDefinitionTemplateInterface ;
9+ use PHPCR \Version \OnParentVersionAction ;
10+
11+ use PHPCR \Util \CND \Helper \NodeTypeGenerator ;
12+ use PHPCR \Util \CND \Reader \BufferReader ;
13+ use PHPCR \Util \CND \Parser \CndParser ;
14+ use PHPCR \Util \CND \Scanner \GenericScanner ;
15+ use PHPCR \Util \CND \Scanner \Context \DefaultScannerContextWithoutSpacesAndComments ;
1616
17- /**
18- * Test for PHPCR\Util\QOM\QomToSql2QueryConverter
19- */
2017class CndParserTest extends \PHPCR \Test \BaseCase
2118{
2219 function testGenerator ()
2320 {
21+ // the worst case example from http://jackrabbit.apache.org/node-type-notation.html
2422 $ cnd = <<<EOT
25- /* An example node type definition */
23+ /** An example node type definition */
2624<ns ='http://namespace.com/ns'>
2725[ns:NodeType] > ns:ParentType1, ns:ParentType2
2826 orderable mixin
@@ -36,20 +34,12 @@ function testGenerator()
3634 mandatory autocreated protected VERSION
3735EOT ;
3836
39- $ reader = new BufferReader ($ cnd );
40- $ scanner = new GenericScanner (new Context \DefaultScannerContextWithoutSpacesAndComments ());
41- $ queue = $ scanner ->scan ($ reader );
42-
4337 //define('DEBUG', true);
4438
45- $ parser = new CndParser ($ queue );
39+ $ parser = new CndParser ($ this -> sharedFixture [ ' session ' ]-> getWorkspace ()-> getNodeTypeManager () );
4640
47- $ generator = new NodeTypeGenerator (
48- $ this ->sharedFixture ['session ' ]->getWorkspace (),
49- $ parser ->parse ()
50- );
41+ $ res = $ parser ->parseString ($ cnd );
5142
52- $ res = $ generator ->generate ();
5343 $ def = reset ($ res ['nodeTypes ' ]);
5444
5545 $ this ->assertEquals (array ('ns ' => 'http://namespace.com/ns ' ), $ res ['namespaces ' ]);
@@ -63,6 +53,7 @@ function testGenerator()
6353 $ this ->assertFalse ($ def ->isAbstract ());
6454 $ this ->assertEquals (1 , count ($ def ->getPropertyDefinitionTemplates ()));
6555
56+ /** @var $prop PropertyDefinitionTemplateInterface */
6657 $ prop = $ def ->getPropertyDefinitionTemplates ()->getIterator ()->current ();
6758
6859 $ this ->assertEquals ('ex:property ' , $ prop ->getName ());
@@ -79,4 +70,12 @@ function testGenerator()
7970 $ this ->assertTrue ($ prop ->isQueryOrderable ()); // True because there was no "noqueryorder" attribute
8071 }
8172
73+ public function testBigFile ()
74+ {
75+ $ cnd = file_get_contents (__DIR__ . '/resources/jackrabbit_nodetypes.cnd ' );
76+ $ parser = new CndParser ($ this ->sharedFixture ['session ' ]->getWorkspace ()->getNodeTypeManager ());
77+
78+ $ res = $ parser ->parseString ($ cnd );
79+ // TODO: compare with the types we get from the repository
80+ }
8281}
0 commit comments