/**
  * @covers            Islandora\Fedora\Chullo::createResource
  * @uses              GuzzleHttp\Client
  */
 public function testReturnsNullOtherwise()
 {
     $mock = new MockHandler([new Response(404), new Response(409)]);
     $handler = HandlerStack::create($mock);
     $guzzle = new Client(['handler' => $handler]);
     $api = new FedoraApi($guzzle);
     $client = new Chullo($api);
     // 404
     $result = $client->createResource("");
     $this->assertNull($result);
     // 409
     $result = $client->createResource("");
     $this->assertNull($result);
 }
Exemple #2
0
 /**
  * @covers            Islandora\Fedora\Chullo::createResource
  * @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->createResource("");
 }
 /**
  * @covers            Islandora\Fedora\Chullo::saveResource
  * @uses              GuzzleHttp\Client
  */
 public function testReturnsFalseOtherwise()
 {
     $mock = new MockHandler([new Response(409), new Response(412)]);
     $handler = HandlerStack::create($mock);
     $guzzle = new Client(['handler' => $handler]);
     $api = new FedoraApi($guzzle);
     $client = new Chullo($api);
     foreach ($mock as $response) {
         $result = $client->createResource("");
         $this->assertFalse($result);
     }
 }