@@ -12,7 +12,7 @@ use RDF::Trine::Graph;
12
12
use Scalar::Util qw/ blessed/ ;
13
13
14
14
use base ' Test::Builder::Module' ;
15
- our @EXPORT = qw/ are_subgraphs is_rdf is_valid_rdf isomorph_graphs has_subject has_predicate has_object_uri has_uri hasnt_uri has_literal hasnt_literal pattern_target pattern_ok pattern_fail/ ;
15
+ our @EXPORT = qw/ are_subgraphs is_rdf is_valid_rdf isomorph_graphs has_subject has_predicate has_object_uri has_type has_uri hasnt_uri has_literal hasnt_literal pattern_target pattern_ok pattern_fail/ ;
16
16
17
17
18
18
=head1 NAME
@@ -41,6 +41,7 @@ our $VERSION = '1.20';
41
41
has_subject($uri_string, $model, 'Subject URI is found');
42
42
has_predicate($uri_string, $model, 'Predicate URI is found');
43
43
has_object_uri($uri_string, $model, 'Object URI is found');
44
+ has_type($uri_string, $model, 'Class URI is found');
44
45
has_literal($string, $language, $datatype, $model, 'Literal is found');
45
46
hasnt_literal($string, $language, $datatype, $model, 'Literal is not found');
46
47
pattern_target($model);
@@ -226,6 +227,26 @@ sub has_object_uri {
226
227
return _single_uri_tests($count , $name );
227
228
}
228
229
230
+
231
+ =head2 has_type
232
+
233
+ Check if the string URI passed as first argument is an RDF class
234
+ instance in any of the statements given in the model given as second
235
+ argument.
236
+
237
+ =cut
238
+
239
+ sub has_type {
240
+ my ($uri , $model , $name ) = @_ ;
241
+ confess ' No valid model given in test' unless (blessed($model ) && $model -> isa(' RDF::Trine::Model' ));
242
+ my $resource = _resource_uri_checked($uri , $name );
243
+ return $resource unless ($resource );
244
+ my $count = $model -> count_statements(undef ,
245
+ RDF::Trine::Node::Resource-> new(' http://www.w3.org/1999/02/22-rdf-syntax-ns#type' ),
246
+ $resource );
247
+ return _single_uri_tests($count , $name );
248
+ }
249
+
229
250
=head2 has_literal
230
251
231
252
Check if the string passed as first argument, with corresponding
0 commit comments