/** * @covers Islandora\Fedora\Chullo::copyResource * @uses GuzzleHttp\Client * @expectedException GuzzleHttp\Exception\ServerException */ public function testThrowsExceptionOn502() { $mock = new MockHandler([new Response(502)]); $handler = HandlerStack::create($mock); $guzzle = new Client(['handler' => $handler, 'base_uri' => 'http://localhost:8080/fcrepo/rest']); $client = new Chullo($guzzle); $result = $client->copyResource("", ""); }
/** * @covers Islandora\Fedora\Chullo::saveGraph * @uses GuzzleHttp\Client * @expectedException GuzzleHttp\Exception\ClientException */ public function testThrowsExceptionOn409() { $mock = new MockHandler([new Response(409)]); $handler = HandlerStack::create($mock); $guzzle = new Client(['handler' => $handler, 'base_uri' => 'http://localhost:8080/fcrepo/rest']); $client = new Chullo($guzzle); $result = $client->saveGraph("", new \EasyRdf_Graph()); }
/** * @covers Islandora\Fedora\Chullo::commitTransaction * @uses GuzzleHttp\Client * @expectedException GuzzleHttp\Exception\ClientException */ public function testThrowsExceptionOn410() { $mock = new MockHandler([new Response(410)]); $handler = HandlerStack::create($mock); $guzzle = new Client(['handler' => $handler, 'base_uri' => 'http://localhost:8080/fcrepo/rest']); $client = new Chullo($guzzle); $result = $client->commitTransaction("tx:abc-123"); }
/** * @covers Islandora\Fedora\Chullo::getResourceOptions * @uses GuzzleHttp\Client */ public function testReturnsHeadersOn200() { $mock = new MockHandler([new Response(200, ['Status: 200 OK', 'Accept-Patch: application/sparql-update', 'Allow: MOVE,COPY,DELETE,POST,HEAD,GET,PUT,PATCH,OPTIONS', 'Accept-Post: text/turtle,text/rdf+n3,application/n3,text/n3,application/rdf+xml,application/n-triples,multipart/form-data,application/sparql-update'])]); $handler = HandlerStack::create($mock); $guzzle = new Client(['handler' => $handler, 'base_uri' => 'http://localhost:8080/fcrepo/rest']); $client = new Chullo($guzzle); $result = $client->getResourceOptions(""); $this->assertSame((array) $result, [['Status: 200 OK'], ['Accept-Patch: application/sparql-update'], ['Allow: MOVE,COPY,DELETE,POST,HEAD,GET,PUT,PATCH,OPTIONS'], ['Accept-Post: text/turtle,text/rdf+n3,application/n3,text/n3,application/rdf+xml,application/n-triples,multipart/form-data,application/sparql-update']]); }
/** * @covers Islandora\Fedora\Chullo::createTransaction * @uses GuzzleHttp\Client */ public function testReturnsIdOn201() { $mock = new MockHandler([new Response(201, ['Location' => "http://localhost:8080/fcrepo/rest/tx:abc-123"])]); $handler = HandlerStack::create($mock); $guzzle = new Client(['handler' => $handler, 'base_uri' => 'http://localhost:8080/fcrepo/rest']); $client = new Chullo($guzzle); $result = $client->createTransaction(); $this->assertSame($result, "tx:abc-123"); }
/** * @covers Islandora\Fedora\Chullo::extendTransaction * @uses GuzzleHttp\Client */ public function testReturnsFalseOtherwise() { $mock = new MockHandler([new Response(410)]); $handler = HandlerStack::create($mock); $guzzle = new Client(['handler' => $handler]); $api = new FedoraApi($guzzle); $client = new Chullo($api); $result = $client->extendTransaction("tx:abc-123"); $this->assertFalse($result); }
/** * @covers Islandora\Fedora\Chullo::deleteResource * @uses GuzzleHttp\Client */ public function testReturnsFalseOtherwise() { $mock = new MockHandler([new Response(404)]); $handler = HandlerStack::create($mock); $guzzle = new Client(['handler' => $handler]); $api = new FedoraApi($guzzle); $client = new Chullo($api); $result = $client->deleteResource(""); $this->assertFalse($result); }
/** * @covers Islandora\Fedora\Chullo::moveResource * @uses GuzzleHttp\Client */ public function testReturnsNullOtherwise() { $mock = new MockHandler([new Response(404), new Response(409), new Response(502)]); $handler = HandlerStack::create($mock); $guzzle = new Client(['handler' => $handler]); $api = new FedoraApi($guzzle); $client = new Chullo($api); foreach ($mock as $response) { $result = $client->moveResource("", ""); $this->assertNull($result); } }
/** * @covers Islandora\Fedora\Chullo::saveGraph * @uses GuzzleHttp\Client */ public function testReturnsFalseOtherwise() { $mock = new MockHandler([new Response(412), new Response(409)]); $handler = HandlerStack::create($mock); $guzzle = new Client(['handler' => $handler]); $api = new FedoraApi($guzzle); $client = new Chullo($api); foreach ($mock as $response) { $result = $client->saveGraph("", new \EasyRdf_Graph()); $this->assertFalse($result); } }