@@ -108,6 +108,59 @@ public function testInsertIntoPrefixedUri()
108108 );
109109 }
110110
111+ /**
112+ * Tests handling of rdf:type and a, in context of ":foo a owl:Ontology".
113+ */
114+ public function testInsertIntoRdfTypeAndA ()
115+ {
116+ // test data
117+ $ query = '
118+ PREFIX ex: <http://ex/>
119+ INSERT INTO <http://ex> {
120+ <http://foo> rdf:type ex:Person .
121+ <http://bar> a ex:Person .
122+ }
123+ ' ;
124+ $ this ->subjectUnderTest ->query ($ query );
125+
126+ $ res = $ this ->subjectUnderTest ->query ('SELECT * WHERE {?s ?p ?o.} ' );
127+ $ this ->assertEquals (
128+ [
129+ [
130+ 's ' => 'http://foo ' ,
131+ 's type ' => 'uri ' ,
132+ 'p ' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type ' ,
133+ 'p type ' => 'uri ' ,
134+ 'o ' => 'http://ex/Person ' ,
135+ 'o type ' => 'uri ' ,
136+ ],
137+ [
138+ 's ' => 'http://bar ' ,
139+ 's type ' => 'uri ' ,
140+ // a was translated to rdf:type on insertion
141+ 'p ' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type ' ,
142+ 'p type ' => 'uri ' ,
143+ 'o ' => 'http://ex/Person ' ,
144+ 'o type ' => 'uri ' ,
145+ ],
146+ ],
147+ $ res ['result ' ]['rows ' ]
148+ );
149+
150+ // asking for resources via a ...
151+ $ res = $ this ->subjectUnderTest ->query ('SELECT ?iri WHERE {?iri a <http://ex/Person>} ' );
152+ $ this ->assertEquals (
153+ [['iri ' => 'http://foo ' , 'iri type ' => 'uri ' ], ['iri ' => 'http://bar ' , 'iri type ' => 'uri ' ],],
154+ $ res ['result ' ]['rows ' ]
155+ );
156+ // and rdf:type ...
157+ $ res = $ this ->subjectUnderTest ->query ('SELECT ?iri WHERE {?iri rdf:type <http://ex/Person>} ' );
158+ $ this ->assertEquals (
159+ [['iri ' => 'http://foo ' , 'iri type ' => 'uri ' ], ['iri ' => 'http://bar ' , 'iri type ' => 'uri ' ],],
160+ $ res ['result ' ]['rows ' ]
161+ );
162+ }
163+
111164 public function testInsertIntoNumbers ()
112165 {
113166 // test data
0 commit comments