84 |
84 |
85 $documentRepository->startTransaction(); |
85 $documentRepository->startTransaction(); |
86 |
86 |
87 $this->assertCount(1, $container, 'One request'); |
87 $this->assertCount(1, $container, 'One request'); |
88 $req = $container[0]['request']; |
88 $req = $container[0]['request']; |
89 $this->assertEquals("$this->sesameRepository/transactions", (string)$req->getUri(), "url must be ok"); |
89 $this->assertEquals("$this->sesameRepository/transactions?isolation-level=http%3A%2F%2Fwww.openrdf.org%2Fschema%2Fsesame%23SNAPSHOT_READ", (string)$req->getUri(), "url must be ok"); |
90 $this->assertEquals('POST', $container[0]['request']->getMethod(), "methos is POST"); |
90 $this->assertEquals('POST', $container[0]['request']->getMethod(), "methos is POST"); |
91 } |
91 } |
92 |
92 |
93 public function testRollbackTransaction() { |
93 public function testRollbackTransaction() { |
94 $responses = [ |
94 $responses = [ |
178 |
178 |
179 $req = $container[1]['request']; |
179 $req = $container[1]['request']; |
180 |
180 |
181 $this->assertEquals($this->transactionUrl."?action=UPDATE", (string)$req->getUri(), "uri must be the transaction url"); |
181 $this->assertEquals($this->transactionUrl."?action=UPDATE", (string)$req->getUri(), "uri must be the transaction url"); |
182 $this->assertEquals('PUT', $req->getMethod(), "Method must be PUT"); |
182 $this->assertEquals('PUT', $req->getMethod(), "Method must be PUT"); |
183 $this->assertEquals(['application/x-www-form-urlencoded'], $req->getHeader('Content-type'), "content type must be form urlencoded"); |
183 $this->assertEquals(['application/sparql-update; charset=utf-8'], $req->getHeader('Content-type'), "content type must be form urlencoded"); |
184 |
184 |
185 $data = []; |
185 $body = (string)$req->getBody(); |
186 parse_str($req->getBody(), $data); |
186 |
187 |
187 $this->assertContains('INSERT DATA {', $body, 'update parameter must contain INSERT'); |
188 $this->assertArrayHasKey('update', $data, "Submitted data must have updarte parameter"); |
188 $this->assertContains('GRAPH <'.$this->addGraph->getUri().'> {', $body, 'update parameter must contain GRAPH id'); |
189 $this->assertContains('INSERT DATA {', $data['update'], 'update parameter must contain INSERT'); |
189 $this->assertContains('<http://cocoon.huma-num.fr/data/ala/ALA_608_22km.wav> <http://purl.org/dc/elements/1.1/type> "dialogue"^^<http://www.language-archives.org/OLAC/1.1/discourse-type>', $body, 'update parameter must contain dialogue'); |
190 $this->assertContains('GRAPH <'.$this->addGraph->getUri().'> {', $data['update'], 'update parameter must contain GRAPH id'); |
190 $this->assertContains('<http://cocoon.huma-num.fr/data/ala/ALA_608_22km.wav> <http://purl.org/dc/elements/1.1/type> "drama"^^<http://www.language-archives.org/OLAC/1.1/discourse-type> .', $body, 'update parameter must contain drama'); |
191 $this->assertContains('<http://cocoon.huma-num.fr/data/ala/ALA_608_22km.wav> <http://purl.org/dc/elements/1.1/type> "dialogue"^^<http://www.language-archives.org/OLAC/1.1/discourse-type>', $data['update'], 'update parameter must contain dialogue'); |
|
192 $this->assertContains('<http://cocoon.huma-num.fr/data/ala/ALA_608_22km.wav> <http://purl.org/dc/elements/1.1/type> "drama"^^<http://www.language-archives.org/OLAC/1.1/discourse-type> .', $data['update'], 'update parameter must contain drama'); |
|
193 } |
191 } |
194 |
192 |
195 public function testDelete() { |
193 public function testDelete() { |
196 $responses = [ |
194 $responses = [ |
197 new Response(201, ['Location' => "$this->transactionUrl"]), |
195 new Response(201, ['Location' => "$this->transactionUrl"]), |
211 |
209 |
212 $req = $container[1]['request']; |
210 $req = $container[1]['request']; |
213 |
211 |
214 $this->assertEquals($this->transactionUrl."?action=UPDATE", (string)$req->getUri(), "uri must be the transaction url"); |
212 $this->assertEquals($this->transactionUrl."?action=UPDATE", (string)$req->getUri(), "uri must be the transaction url"); |
215 $this->assertEquals('PUT', $req->getMethod(), "Method must be PUT"); |
213 $this->assertEquals('PUT', $req->getMethod(), "Method must be PUT"); |
216 $this->assertEquals(['application/x-www-form-urlencoded'], $req->getHeader('Content-type'), "content type must be form urlencoded"); |
214 $this->assertEquals(['application/sparql-update; charset=utf-8'], $req->getHeader('Content-type'), "content type must be form urlencoded"); |
217 |
215 |
218 $data = []; |
216 $body = (string)$req->getBody(); |
219 parse_str($req->getBody(), $data); |
217 |
220 |
218 $this->assertContains('DELETE DATA {', $body, 'update parameter must contain DELETE'); |
221 $this->assertArrayHasKey('update', $data, "Submitted data must have updarte parameter"); |
219 $this->assertContains('GRAPH <'.$this->addGraph->getUri().'> {', $body, 'update parameter must contain GRAPH id'); |
222 $this->assertContains('DELETE DATA {', $data['update'], 'update parameter must contain DELETE'); |
220 $this->assertContains('<http://cocoon.huma-num.fr/data/ala/ALA_608_22km.wav> <http://purl.org/dc/elements/1.1/type> "dialogue"^^<http://www.language-archives.org/OLAC/1.1/discourse-type>', $body, 'update parameter must contain GRAPH id'); |
223 $this->assertContains('GRAPH <'.$this->addGraph->getUri().'> {', $data['update'], 'update parameter must contain GRAPH id'); |
|
224 $this->assertContains('<http://cocoon.huma-num.fr/data/ala/ALA_608_22km.wav> <http://purl.org/dc/elements/1.1/type> "dialogue"^^<http://www.language-archives.org/OLAC/1.1/discourse-type>', $data['update'], 'update parameter must contain GRAPH id'); |
|
225 |
221 |
226 } |
222 } |
227 |
223 |
228 } |
224 } |