1010 PHPCR \Util \CND \Reader \BufferReader ,
1111 PHPCR \Util \CND \Parser \CndParser ,
1212 PHPCR \Util \CND \Scanner \GenericScanner ,
13- PHPCR \Util \CND \Scanner \Context ;
13+ PHPCR \Util \CND \Scanner \Context ,
14+ PHPCR \PropertyType ,
15+ PHPCR \Version \OnParentVersionAction ;
1416
1517/**
1618 * Test for PHPCR\Util\QOM\QomToSql2QueryConverter
1719 */
1820class CndParserTest extends \PHPCR \Test \BaseCase
1921{
20- function testGenerator ()
21- {
22- $ cnd = <<<EOT
22+ function testGenerator ()
23+ {
24+ $ cnd = <<<EOT
2325/* An example node type definition */
2426<ns ='http://namespace.com/ns'>
2527[ns:NodeType] > ns:ParentType1, ns:ParentType2
@@ -34,31 +36,47 @@ function testGenerator()
3436 mandatory autocreated protected VERSION
3537EOT ;
3638
37- $ reader = new BufferReader ($ cnd );
38- $ scanner = new GenericScanner (new Context \DefaultScannerContextWithoutSpacesAndComments ());
39- $ queue = $ scanner ->scan ($ reader );
39+ $ reader = new BufferReader ($ cnd );
40+ $ scanner = new GenericScanner (new Context \DefaultScannerContextWithoutSpacesAndComments ());
41+ $ queue = $ scanner ->scan ($ reader );
4042
41- //define('DEBUG', true);
43+ //define('DEBUG', true);
4244
43- $ parser = new CndParser ($ queue );
45+ $ parser = new CndParser ($ queue );
4446
45- $ generator = new NodeTypeGenerator (
46- $ this ->sharedFixture ['session ' ]->getWorkspace (),
47- $ parser ->parse ()
48- );
47+ $ generator = new NodeTypeGenerator (
48+ $ this ->sharedFixture ['session ' ]->getWorkspace (),
49+ $ parser ->parse ()
50+ );
4951
50- $ res = $ generator ->generate ();
51- $ def = reset ($ res ['nodeTypes ' ]);
52+ $ res = $ generator ->generate ();
53+ $ def = reset ($ res ['nodeTypes ' ]);
5254
53- $ this ->assertEquals (array ('ns ' => 'http://namespace.com/ns ' ), $ res ['namespaces ' ]);
55+ $ this ->assertEquals (array ('ns ' => 'http://namespace.com/ns ' ), $ res ['namespaces ' ]);
5456
55- $ this ->assertInstanceOf ('\PHPCR\NodeType\NodeTypeTemplateInterface ' , $ def );
56- $ this ->assertEquals ('ns:NodeType ' , $ def ->getName ());
57- $ this ->assertEquals (array ('ns:ParentType1 ' , 'ns:ParentType2 ' ), $ def ->getDeclaredSuperTypeNames ());
58- $ this ->assertTrue ($ def ->hasOrderableChildNodes ());
59- $ this ->assertTrue ($ def ->isMixin ());
60- $ this ->assertFalse ($ def ->isQueryable ());
61- $ this ->assertFalse ($ def ->isAbstract ());
62- }
57+ $ this ->assertInstanceOf ('\PHPCR\NodeType\NodeTypeTemplateInterface ' , $ def );
58+ $ this ->assertEquals ('ns:NodeType ' , $ def ->getName ());
59+ $ this ->assertEquals (array ('ns:ParentType1 ' , 'ns:ParentType2 ' ), $ def ->getDeclaredSuperTypeNames ());
60+ $ this ->assertTrue ($ def ->hasOrderableChildNodes ());
61+ $ this ->assertTrue ($ def ->isMixin ());
62+ $ this ->assertFalse ($ def ->isQueryable ());
63+ $ this ->assertFalse ($ def ->isAbstract ());
64+ $ this ->assertEquals (1 , count ($ def ->getPropertyDefinitionTemplates ()));
65+
66+ $ prop = $ def ->getPropertyDefinitionTemplates ()->getIterator ()->current ();
67+
68+ $ this ->assertEquals ('ex:property ' , $ prop ->getName ());
69+ $ this ->assertEquals (PropertyType::STRING , $ prop ->getRequiredType ());
70+ $ this ->assertEquals (array ('default1 ' , 'default2 ' ), $ prop ->getDefaultValues ());
71+ $ this ->assertEquals (array ('constraint1 ' , 'constraint2 ' ), $ prop ->getValueConstraints ());
72+ $ this ->assertTrue ($ prop ->isAutoCreated ());
73+ $ this ->assertTrue ($ prop ->isMandatory ());
74+ $ this ->assertTrue ($ prop ->isProtected ());
75+ $ this ->assertTrue ($ prop ->isMultiple ());
76+ $ this ->assertEquals (OnParentVersionAction::VERSION , $ prop ->getOnParentVersion ());
77+ $ this ->assertEquals (array (), $ prop ->getAvailableQueryOperators ());
78+ $ this ->assertTrue ($ prop ->isFullTextSearchable ()); // True because there was no "nofulltext" attribute
79+ $ this ->assertTrue ($ prop ->isQueryOrderable ()); // True because there was no "noqueryorder" attribute
80+ }
6381
6482}
0 commit comments