public function testHistory()
 {
     $this->assertEquals(2, $this->history->count());
     $requests = $this->history->getRequests();
     $this->assertEquals('http://lom.dv/web/app_dev.php/api/sword/2.0/sd-iri', $requests[0]->getUrl());
     $this->assertEquals('http://lom.dv/AA84-E1C03A83A206', $requests[1]->getUrl());
 }
Пример #2
0
 public function testHistory()
 {
     $this->assertEquals(2, $this->history->count());
     $requests = $this->history->getRequests();
     $this->assertEquals('http://example.com/path/to/receipt', $requests[0]->getUrl());
     $this->assertEquals('http://lom.dv/DB416EBE1887/state', $requests[1]->getUrl());
 }
Пример #3
0
 public function testHarvest()
 {
     $this->commandTester->execute(array('command' => $this->getCommandName()));
     $this->assertCount(0, $this->em->getRepository('AppBundle:Deposit')->findBy(array('state' => 'harvest-error')));
     $this->assertCount(2, $this->em->getRepository('AppBundle:Deposit')->findBy(array('state' => 'harvested')));
     $this->assertCount(2, $this->history);
     $requests = $this->history->getRequests();
     $this->assertEquals('HEAD', $requests[0]->getMethod());
     $this->assertEquals('GET', $requests[1]->getMethod());
     $content = file_get_contents('test/data/received/C0A65967-32BD-4EE8-96DE-C469743E563A/D38E7ECB-7D7E-408D-94B0-B00D434FDBD2.zip');
     $this->assertEquals('absclksd', $content);
 }
 public function testHarvest()
 {
     $this->commandTester->execute(array('command' => $this->getCommandName()));
     $deposits = $this->em->getRepository('AppBundle:Deposit')->findBy(array('state' => 'harvest-error'));
     $this->assertCount(2, $this->history);
     $requests = $this->history->getRequests();
     $this->assertEquals('HEAD', $requests[0]->getMethod());
     $this->assertEquals('GET', $requests[1]->getMethod());
     $this->assertCount(1, $deposits);
     $this->assertContains('Expected file size', implode(' ', $deposits[0]->getErrorLog()));
     $this->assertFileExists('test/data/received/C0A65967-32BD-4EE8-96DE-C469743E563A/D38E7ECB-7D7E-408D-94B0-B00D434FDBD2.zip');
 }
Пример #5
0
 public function testLogsConnectionErrors()
 {
     $request = new Request('GET', '/');
     $t = new Transaction(new Client(), $request);
     $e = new RequestException('foo', $request);
     $ev = new ErrorEvent($t, $e);
     $h = new History();
     $h->onError($ev);
     $this->assertEquals([$request], $h->getRequests());
 }
 protected function authentication()
 {
     // Setting for the WSClient
     $url = 'http://www.example.com';
     $config = ['auth' => ['username' => 'system', 'accesskey' => 'TkDShdBqAnav2EhG'], 'testing' => ['client' => $this->client]];
     $mock = new Mock([new Response(200, [], Stream::factory(fopen('./tests/mock/body-response-challenge.txt', 'r+'))), new Response(200, [], Stream::factory(fopen('./tests/mock/body-response-login.txt', 'r+')))]);
     $this->client->getEmitter()->attach($mock);
     // Create the WSClient
     $this->wsclient = new WSClient($url, $config);
     $requests = $this->history->getRequests();
     // Operation getchallenge
     $this->assertEquals('http://www.example.com/webservice.php?operation=getchallenge&username=system', $requests[0]->getUrl());
     $this->assertEquals('GET', $requests[0]->getMethod());
     // Operation login
     $this->assertEquals('http://www.example.com/webservice.php', $requests[1]->getUrl());
     $this->assertEquals('POST', $requests[1]->getMethod());
     $this->assertEquals('operation=login&username=system&accessKey=452e4d2f10d60e481c2056ef2e12ed48', (string) $requests[1]->getBody());
     // Detaching subscriber
     $this->client->getEmitter()->detach($mock);
 }
Пример #7
0
 public function testAddsForErrorEvent()
 {
     $request = new Request('GET', '/');
     $response = new Response(400);
     $t = new Transaction(new Client(), $request);
     $t->setResponse($response);
     $e = new RequestException('foo', $request, $response);
     $ev = new ErrorEvent($t, $e);
     $h = new History(2);
     $h->onError($ev);
     $this->assertEquals([$request], $h->getRequests());
 }
Пример #8
0
 public function testHistory()
 {
     $this->assertEquals(1, $this->history->count());
     $requests = $this->history->getRequests();
     $this->assertEquals('http://example.com/path/to/receipt', $requests[0]->getUrl());
 }