ConnectorTest
extends TestCase
in package
Uses
FixtureTrait, WithConsecutiveTrait
Unit tests for SOLR connector.
Tags
Table of Contents
- $response : string
- Current response.
- testBadRequestError() : void
- Test RequestErrorException is thrown on a remote 4xx error.
- testCaching() : void
- Test caching.
- testCallWithHttpOptions() : void
- Test callWithHttpOptions.
- testClientCreation() : void
- Test that making a request calls the HTTP client factory
- testGetters() : void
- Test simple getters.
- testInternalServerError() : void
- Test RemoteErrorException is thrown on a remote 5xx error.
- testRetrieve() : void
- Test record retrieval.
- testRetrieveMissingRecord() : void
- Test retrieving a non-existent record returns a response.
- testWriteCSV() : void
- Test writing a CSV document.
- testWriteJSON() : void
- Test writing a JSON document.
- createClient() : Client
- Set up HTTP client using test adapter with prepared response.
- createConnector() : Connector
- Create connector with fixture file.
- expectConsecutiveCalls() : InvocationStubber
- Expect consecutive calls to a mock.
- getConnectorMock() : Connector
- Return connector mock.
- getFixture() : string
- Load a fixture file.
- getFixtureDir() : string
- Get the base directory containing fixtures.
- getFixturePath() : string
- Resolve fixture path.
- getJsonFixture() : array<string|int, mixed>
- Load a JSON fixture from file (using associative array return type).
Properties
$response
Current response.
protected
string
$response
Methods
testBadRequestError()
Test RequestErrorException is thrown on a remote 4xx error.
public
testBadRequestError() : void
Return values
void —testCaching()
Test caching.
public
testCaching() : void
Return values
void —testCallWithHttpOptions()
Test callWithHttpOptions.
public
testCallWithHttpOptions() : void
Return values
void —testClientCreation()
Test that making a request calls the HTTP client factory
public
testClientCreation() : void
Return values
void —testGetters()
Test simple getters.
public
testGetters() : void
Return values
void —testInternalServerError()
Test RemoteErrorException is thrown on a remote 5xx error.
public
testInternalServerError() : void
Return values
void —testRetrieve()
Test record retrieval.
public
testRetrieve() : void
Return values
void —testRetrieveMissingRecord()
Test retrieving a non-existent record returns a response.
public
testRetrieveMissingRecord() : void
Return values
void —testWriteCSV()
Test writing a CSV document.
public
testWriteCSV() : void
Return values
void —testWriteJSON()
Test writing a JSON document.
public
testWriteJSON() : void
Return values
void —createClient()
Set up HTTP client using test adapter with prepared response.
protected
createClient() : Client
Return values
Client —createConnector()
Create connector with fixture file.
protected
createConnector([string $fixture = null ][, Client $client = null ]) : Connector
Parameters
- $fixture : string = null
-
Fixture file
- $client : Client = null
-
HTTP client
Tags
Return values
Connector —expectConsecutiveCalls()
Expect consecutive calls to a mock.
protected
expectConsecutiveCalls(MockObject $mock, string $method, array<string|int, mixed> $expectedCalls[, mixed $returnValues = null ]) : InvocationStubber
Parameters
- $mock : MockObject
-
Mock object
- $method : string
-
Method expecting calls
- $expectedCalls : array<string|int, mixed>
-
Expected input parameters
- $returnValues : mixed = null
-
Return values to mock (either an array indexed parallel to $expectedCalls to return different values, or a single value to always return the same thing)
Return values
InvocationStubber —getConnectorMock()
Return connector mock.
protected
getConnectorMock([array<string|int, mixed> $mock = [] ][, Client $client = null ]) : Connector
Parameters
- $mock : array<string|int, mixed> = []
-
Functions to mock
- $client : Client = null
-
HTTP Client (optional)
Return values
Connector —getFixture()
Load a fixture file.
protected
getFixture(string $filename[, string $module = 'VuFind' ]) : string
Parameters
- $filename : string
-
Filename relative to fixture directory.
- $module : string = 'VuFind'
-
Module containing fixture.
Tags
Return values
string —getFixtureDir()
Get the base directory containing fixtures.
protected
getFixtureDir([string $module = 'VuFind' ]) : string
Parameters
- $module : string = 'VuFind'
-
Module containing fixture.
Return values
string —getFixturePath()
Resolve fixture path.
protected
getFixturePath(string $filename[, string $module = 'VuFind' ]) : string
Parameters
- $filename : string
-
Filename relative to fixture directory.
- $module : string = 'VuFind'
-
Module containing fixture.
Tags
Return values
string —getJsonFixture()
Load a JSON fixture from file (using associative array return type).
protected
getJsonFixture(string $filename[, string $module = 'VuFind' ]) : array<string|int, mixed>
Parameters
- $filename : string
-
Filename relative to fixture directory.
- $module : string = 'VuFind'
-
Module containing fixture.