Exemplo n.º 1
0
 /**
  * Create connector with fixture file.
  *
  * @param string $fixture Fixture file
  *
  * @return Connector
  *
  * @throws InvalidArgumentException Fixture file does not exist
  */
 protected function createConnector($fixture = null)
 {
     $adapter = new TestAdapter();
     if ($fixture) {
         $file = realpath(__DIR__ . '/../../../../../../tests/fixtures/daia/response/' . $fixture);
         if (!is_string($file) || !file_exists($file) || !is_readable($file)) {
             throw new InvalidArgumentException(sprintf('Unable to load fixture file: %s ', $file));
         }
         $response = file_get_contents($file);
         $responseObj = HttpResponse::fromString($response);
         $adapter->setResponse($responseObj);
     }
     $service = new \VuFindHttp\HttpService();
     $service->setDefaultAdapter($adapter);
     $conn = new DAIA(new \VuFind\Date\Converter());
     $conn->setHttpService($service);
     return $conn;
 }
Exemplo n.º 2
0
 /**
  * Create connector with fixture file.
  *
  * @param string $fixture Fixture file
  *
  * @return Connector
  *
  * @throws InvalidArgumentException Fixture file does not exist
  */
 protected function createMockConnector($fixture = null)
 {
     $adapter = new TestAdapter();
     if ($fixture) {
         $file = realpath(__DIR__ . '/../../../../../../tests/fixtures/paia/response/' . $fixture);
         if (!is_string($file) || !file_exists($file) || !is_readable($file)) {
             throw new InvalidArgumentException(sprintf('Unable to load fixture file: %s ', $file));
         }
         $response = file_get_contents($file);
         $responseObj = HttpResponse::fromString($response);
         $adapter->setResponse($responseObj);
     }
     $service = new \VuFindHttp\HttpService();
     $service->setDefaultAdapter($adapter);
     $conn = $this->getMockBuilder('VuFind\\ILS\\Driver\\PAIA')->setConstructorArgs([new \VuFind\Date\Converter(), new \Zend\Session\SessionManager()])->setMethods(['getScope'])->getMock();
     $conn->expects($this->any())->method('getScope')->will($this->returnValue(['write_items']));
     $conn->setHttpService($service);
     $conn->setConfig($this->validConfig);
     $conn->init();
     return $conn;
 }