VuFind API Documentation

BackendTest extends TestCase
in package
Uses FixtureTrait, WithConsecutiveTrait

Unit tests for Blender backend.

Tags
category

VuFind

author

Ere Maijala ere.maijala@helsinki.fi

license

http://opensource.org/licenses/gpl-2.0.php GNU General Public License

link
https://vufind.org

Table of Contents

$config  : array<string|int, mixed>
Blender config
$mappings  : array<string|int, mixed>
Mappings
$sharedEventManager  : SharedEventManager
Event manager
getInvalidBlockSizes()  : array<string|int, mixed>
Data provider for testInvalidAdaptiveBlockSize
getSearchTestData()  : array<string|int, mixed>
Data provider for testSearch
setUp()  : void
Standard setup method.
testArrayFacetFormat()  : void
Test search with array facet format
testEmptyCollectionArray()  : void
Test initialization of an empty collection array
testEvents()  : void
Test event handling
testGetRecordCollectionFactory()  : void
Test getRecordCollectionFactory.
testInvalidAdaptiveBlockSize()  : void
Test invalid adaptive block size configuration.
testInvalidFilter()  : void
Test invalid backend filter.
testNonDelimitedBlenderBackendFacet()  : void
Test non-delimited blender_backend facet field.
testRetrieve()  : void
Test retrieve.
testSearch()  : void
Test search.
testSearchCollectionError()  : void
Test search with a error returned in a collection
testSearchLimit()  : void
Test limits used for search requests
testSearchPartialFailure()  : void
Test search with a partial failure
testSearchTotalFailure()  : void
Test search with a total failure
expectConsecutiveCalls()  : InvocationStubber
Expect consecutive calls to a mock.
getBackend()  : Backend
Return Blender backend.
getBackendForFacetsAndErrors()  : object
Create a backend that returns the given values for facets and errors
getEDSBackendMock()  : object
Return EDS backend mock.
getEDSRecordCollectionFactory()  : RecordCollectionFactory
Return EDS record collection factory.
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).
getSearchParams()  : ParamBag
Return search params
getSolrBackend()  : Backend
Return Solr backend.
getSolrConnector()  : object
Return Solr connector mock.
getSolrRecordCollectionFactory()  : RecordCollectionFactory
Return Solr record collection factory.

Properties

$config

Blender config

protected static array<string|int, mixed> $config = ['Backends' => ['Solr' => 'Local', 'EDS' => 'Electronic Stuff'], 'Blending' => ['initialResults' => ['Solr', 'Solr', 'EDS', 'EDS'], 'blockSize' => 7], 'Advanced_Settings' => ['delimiter' => '::', 'delimited_facets' => ['blender_backend']]]

$mappings

Mappings

protected array<string|int, mixed> $mappings = ['Facets' => ['Fields' => ['building' => ['Mappings' => ['Solr' => ['Field' => 'building'], 'EDS' => ['Field' => 'ContentProvider', 'Unmapped' => 'drop', 'Hierarchical' => true, 'Values' => ['Business Source Premier' => 'Main', 'Communication Abstracts' => '1/Main/Sub/', 'EconLit with Full Text' => '1/Econlit/Foo/']]]], 'format' => ['Mappings' => ['Solr' => ['Field' => 'format'], 'EDS' => ['Field' => 'SourceType', 'Values' => ['Academic Journals' => 'Journal', 'Magazines' => 'Article', 'Books' => 'Book', 'Conference Materials' => 'Conference Proceeding', 'Reviews' => 'Review', 'Trade Publications' => 'Trade Publications', 'Reports' => 'Report', 'Electronic Resources' => 'Electronic', 'eBooks' => 'eBook', 'Non-print Resources' => 'Text', 'Biographies' => 'Biography', 'Dissertations' => 'Thesis', 'Audio' => 'Audio', 'Music Scores' => 'Music Score', 'Video' => 'Video', 'Primary Source Documents' => 'Primary Source Document', 'Maps' => 'Map', 'Research Starters' => 'Research Starter', 'Audiobooks' => 'Audiobook', 'News' => '']]]], 'fulltext' => ['Type' => 'boolean', 'Mappings' => ['Solr' => ['Field' => 'fulltext_boolean'], 'Primo' => ['Field' => 'pcAvailability', 'Values' => ['false' => '1'], 'DefaultValue' => 'true'], 'EDS' => ['Field' => 'LIMIT|FT', 'Values' => ['y' => '1']]]], 'language' => ['Mappings' => ['EDS' => ['Field' => '']]]]], 'Search' => ['Fields' => ['AllFields' => ['Mappings' => ['Solr' => 'AllFields', 'Primo' => 'AllFields', 'EDS' => 'AllFields']], 'Title' => ['Mappings' => ['Solr' => 'Title', 'Primo' => 'Title', 'EDS' => 'TI']]]], 'Sorting' => ['Fields' => ['relevance' => ['Mappings' => ['Solr' => 'relevance', 'Primo' => 'relevance', 'EDS' => 'relevance']], 'year' => ['Mappings' => ['Solr' => 'year', 'Primo' => 'scdate', 'EDS' => 'date']]]]]

$sharedEventManager

Event manager

protected SharedEventManager $sharedEventManager = null

Methods

getInvalidBlockSizes()

Data provider for testInvalidAdaptiveBlockSize

public static getInvalidBlockSizes() : array<string|int, mixed>
Return values
array<string|int, mixed>

getSearchTestData()

Data provider for testSearch

public static getSearchTestData() : array<string|int, mixed>
Return values
array<string|int, mixed>

setUp()

Standard setup method.

public setUp() : void
Return values
void

testArrayFacetFormat()

Test search with array facet format

public testArrayFacetFormat() : void
Return values
void

testEmptyCollectionArray()

Test initialization of an empty collection array

public testEmptyCollectionArray() : void
Return values
void

testEvents()

Test event handling

public testEvents() : void
Return values
void

testGetRecordCollectionFactory()

Test getRecordCollectionFactory.

public testGetRecordCollectionFactory() : void
Return values
void

testInvalidAdaptiveBlockSize()

Test invalid adaptive block size configuration.

public testInvalidAdaptiveBlockSize(array<string|int, mixed> $blockSizes) : void
Parameters
$blockSizes : array<string|int, mixed>

Adaptive block size configuration

Tags
dataProvider

getInvalidBlockSizes

Return values
void

testInvalidFilter()

Test invalid backend filter.

public testInvalidFilter() : void
Return values
void

testNonDelimitedBlenderBackendFacet()

Test non-delimited blender_backend facet field.

public testNonDelimitedBlenderBackendFacet() : void
Return values
void

testRetrieve()

Test retrieve.

public testRetrieve() : void
Return values
void

testSearch()

Test search.

public testSearch(int $start, int $limit, array<string|int, mixed> $expectedRecords[, array<string|int, mixed>|null $config = null ][, array<string|int, mixed> $filters = [] ][, int $expectedSolr = 240 ][, int $expectedEDS = 65924 ][, Query $query = null ]) : void
Parameters
$start : int

Start position

$limit : int

Result limit

$expectedRecords : array<string|int, mixed>

Expected records

$config : array<string|int, mixed>|null = null

Blender configuration, overrides defaults

$filters : array<string|int, mixed> = []

Filters

$expectedSolr : int = 240

Expected Solr count

$expectedEDS : int = 65924

Expected EDS count

$query : Query = null

Override query

Tags
dataProvider

getSearchTestData

Return values
void

testSearchCollectionError()

Test search with a error returned in a collection

public testSearchCollectionError() : void
Return values
void

testSearchLimit()

Test limits used for search requests

public testSearchLimit() : void
Return values
void

testSearchPartialFailure()

Test search with a partial failure

public testSearchPartialFailure() : void
Return values
void

testSearchTotalFailure()

Test search with a total failure

public testSearchTotalFailure() : void
Return values
void

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

getBackend()

Return Blender backend.

protected getBackend([array<string|int, mixed> $config = null ][, array<string|int, mixed> $mappings = null ][, array<string|int, mixed> $backends = [] ]) : Backend
Parameters
$config : array<string|int, mixed> = null

Blender configuration, overrides defaults

$mappings : array<string|int, mixed> = null

Blender mappings, overrides defaults

$backends : array<string|int, mixed> = []

Actual backends, overrides defaults

Return values
Backend

getBackendForFacetsAndErrors()

Create a backend that returns the given values for facets and errors

protected getBackendForFacetsAndErrors(array<string|int, mixed> $facets, array<string|int, mixed> $errors) : object
Parameters
$facets : array<string|int, mixed>

Facet data

$errors : array<string|int, mixed>

Error data

Return values
object

getEDSBackendMock()

Return EDS backend mock.

protected getEDSBackendMock([string $fixture = null ]) : object
Parameters
$fixture : string = null

Fixture to use for results, overrides default. Use empty string for failure.

Return values
object

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
throws
RuntimeException
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
throws
RuntimeException
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.

Return values
array<string|int, mixed>

getSearchParams()

Return search params

protected getSearchParams(array<string|int, mixed> $filters[, Query $query = null ]) : ParamBag
Parameters
$filters : array<string|int, mixed>

Blender filters

$query : Query = null

Query

Return values
ParamBag

getSolrBackend()

Return Solr backend.

protected getSolrBackend([string $fixture = null ]) : Backend
Parameters
$fixture : string = null

Fixture to use for results, overrides default. Use empty string for failure.

Return values
Backend

getSolrConnector()

Return Solr connector mock.

protected getSolrConnector([string $fixture = null ]) : object
Parameters
$fixture : string = null

Fixture to use for results, overrides default. Use empty string for failure.

Return values
object

Search results