26
26
27
27
namespace quickRdfIo ;
28
28
29
- use quickRdf \DataFactory ;
29
+ use quickRdf \DataFactory as DF ;
30
30
use quickRdf \Dataset ;
31
31
32
32
/**
@@ -42,7 +42,7 @@ class JsonLdTest extends \PHPUnit\Framework\TestCase {
42
42
private JsonLdSerializer $ serializer ;
43
43
44
44
public function setUp (): void {
45
- $ this ->df = new DataFactory ();
45
+ $ this ->df = new DF ();
46
46
$ this ->refParser = new NQuadsParser ($ this ->df , false , NQuadsParser::MODE_QUADS );
47
47
$ this ->parser = new JsonLdParser ($ this ->df );
48
48
$ this ->serializer = new JsonLdSerializer (null );
@@ -71,4 +71,22 @@ public function testBig(): void {
71
71
$ this ->assertEquals ($ ref ->count (), $ dataset ->count ());
72
72
$ this ->assertTrue ($ ref ->equals ($ dataset ));
73
73
}
74
+
75
+ /**
76
+ * https://github.com/sweetrdf/quickRdfIo/issues/10
77
+ */
78
+ public function testBom (): void {
79
+ $ ref = new Dataset ();
80
+ $ quad = DF ::quad (df::namedNode ('http://foo ' ), DF ::namedNode ('http://bar ' ), DF ::namedNode ('http://baz ' ));
81
+ $ ref ->add ($ quad );
82
+ $ output = tmpfile ();
83
+ fwrite ($ output , "\xEF\xBB\xBF" );
84
+ $ this ->serializer ->serializeStream ($ output , $ ref );
85
+
86
+ fseek ($ output , 0 );
87
+ $ dataset = new Dataset ();
88
+ $ dataset ->add ($ this ->parser ->parseStream ($ output ));
89
+ $ this ->assertCount (1 , $ dataset );
90
+ $ this ->assertTrue ($ quad ->equals ($ dataset [0 ]));
91
+ }
74
92
}
0 commit comments