TestHarness
extends AbstractBase
in package
Test harness for simulating record drivers (ignore outside of test suite!)
Tags
Table of Contents
- $dbServiceManager : PluginManager
- Database service plugin manager
- $extraDetails : array<string|int, mixed>
- For storing extra data with record
- $fields : array<string|int, mixed>
- Raw data
- $labels : array<string|int, mixed>
- Labels for the record
- $mainConfig : Config
- Main VuFind configuration
- $ratingCache : array<string|int, mixed>
- Cache for rating data
- $recordConfig : Config
- Record-specific configuration
- $searchBackendIdentifier : string
- Used for identifying the search backend used to find the record
- $sourceIdentifier : string
- Used for identifying record source backend
- $tableManager : PluginManager
- Database table plugin manager
- $translator : TranslatorInterface
- Translator
- __call() : mixed
- Magic method to set/retrieve fields.
- __construct() : mixed
- Constructor
- addLabel() : void
- Add a label for the record
- addOrUpdateRating() : void
- Add or update user's rating for the record.
- addTags() : void
- Add tags to the record.
- deleteTags() : void
- Remove tags from the record.
- getBreadcrumb() : string
- Get text that can be displayed to represent this record in breadcrumbs.
- getCitationFormats() : array<string|int, mixed>
- Get an array of supported, user-activated citation formats.
- getComments() : array<string|int, mixed>
- Get comments associated with this record.
- getContainingLists() : array<string|int, mixed>
- Get a list of lists containing this record.
- getDbService() : T
- Get a database service object.
- getDbServiceManager() : PluginManager
- Get the service plugin manager. Throw an exception if it is missing.
- getDbTable() : Gateway
- Get a database table object.
- getDbTableManager() : PluginManager
- Get the table plugin manager. Throw an exception if it is missing.
- getExtraDetail() : mixed
- Retrieve a piece of supplemental information stored using setExtraDetail().
- getLabels() : array<string|int, mixed>
- Return all labels for the record
- getListNotes() : array<string|int, mixed>
- Get notes associated with this record in user lists.
- getRatingBreakdown() : array<string|int, mixed>
- Get rating breakdown for this record.
- getRatingData() : array<string|int, mixed>
- Get rating information for this record.
- getRawData() : mixed
- Retrieve raw data from object (primarily for use in staff view and autocomplete; avoid using whenever possible).
- getSearchBackendIdentifier() : string
- Return the search backend identifier used to find the record.
- getSortTitle() : string
- Get a sortable title for the record (i.e. no leading articles).
- getSourceIdentifier() : string
- Return the source backend identifier.
- getTags() : array<string|int, mixed>
- Get tags associated with this record.
- getTranslator() : TranslatorInterface
- Get translator object.
- getTranslatorLocale() : string
- Get the locale from the translator.
- getUniqueID() : string
- Return the unique identifier of this record for retrieving additional information (like tags and user comments) from the external MySQL database.
- isRatingAllowed() : bool
- Check if rating the record is allowed.
- setDbServiceManager() : void
- Set the service plugin manager.
- setDbTableManager() : void
- Set the table plugin manager.
- setExtraDetail() : void
- Store a piece of supplemental information in the record driver.
- setLabels() : void
- Set the labels for the record
- setRawData() : void
- Set raw data to initialize the object.
- setSourceIdentifier() : void
- Set the record source backend identifier.
- setSourceIdentifiers() : void
- Set the source backend identifiers.
- setTranslator() : TranslatorAwareInterface
- Set a translator
- supportsAjaxStatus() : bool
- Returns true if the record supports real-time AJAX status lookups.
- supportsCoinsOpenUrl() : bool
- Checks the current record if it's supported for generating COinS-OpenURLs.
- supportsOpenUrl() : bool
- Checks the current record if it's supported for generating OpenURLs.
- translate() : string
- Translate a string (or string-castable object)
- translateWithPrefix() : string
- Translate a string (or string-castable object) using a prefix, or without the prefix if a prefixed translation is not found.
- tryMethod() : mixed
- Try to call the requested method and return null if it is unavailable; this is useful for checking for the existence of get methods for particular types of data without causing fatal errors.
- extractTextDomain() : array<string|int, mixed>
- Given a translation string with or without a text domain, return an array with the raw string and the text domain separated.
- getDebugTranslation() : string
- Build a debug-mode translation
- getSupportedCitationFormats() : array<string|int, mixed>
- Get an array of strings representing citation formats supported by this record's data (empty if none). For possible legal values, see /application/themes/root/helpers/Citation.php.
- sanitizeTranslationKey() : string
- Make sure there are not any illegal characters in the translation key that might prevent successful lookup in language files.
- translateString() : string
- Get translation for a string
Properties
$dbServiceManager
Database service plugin manager
protected
PluginManager
$dbServiceManager
$extraDetails
For storing extra data with record
protected
array<string|int, mixed>
$extraDetails
= []
$fields
Raw data
protected
array<string|int, mixed>
$fields
= []
$labels
Labels for the record
protected
array<string|int, mixed>
$labels
= []
$mainConfig
Main VuFind configuration
protected
Config
$mainConfig
$ratingCache
Cache for rating data
protected
array<string|int, mixed>
$ratingCache
= []
$recordConfig
Record-specific configuration
protected
Config
$recordConfig
$searchBackendIdentifier
Used for identifying the search backend used to find the record
protected
string
$searchBackendIdentifier
= ''
$sourceIdentifier
Used for identifying record source backend
protected
string
$sourceIdentifier
= ''
$tableManager
Database table plugin manager
protected
PluginManager
$tableManager
$translator
Translator
protected
TranslatorInterface
$translator
= null
Methods
__call()
Magic method to set/retrieve fields.
public
__call(string $method, array<string|int, mixed> $params) : mixed
Parameters
- $method : string
-
Method name being called.
- $params : array<string|int, mixed>
-
Parameters passed to method.
Return values
mixed —__construct()
Constructor
public
__construct() : mixed
Return values
mixed —addLabel()
Add a label for the record
public
addLabel(string $label, string $class) : void
Parameters
- $label : string
-
Label, may be a translation key
- $class : string
-
Label class
Return values
void —addOrUpdateRating()
Add or update user's rating for the record.
public
addOrUpdateRating(int $userId, int|null $rating) : void
Parameters
- $userId : int
-
ID of the user posting the rating
- $rating : int|null
-
The user-provided rating, or null to clear any existing rating
Tags
Return values
void —addTags()
Add tags to the record.
public
addTags(UserEntityInterface $user, array<string|int, mixed> $tags) : void
Parameters
- $user : UserEntityInterface
-
The user posting the tag
- $tags : array<string|int, mixed>
-
The user-provided tags
Tags
Return values
void —deleteTags()
Remove tags from the record.
public
deleteTags(UserEntityInterface $user, array<string|int, mixed> $tags) : void
Parameters
- $user : UserEntityInterface
-
The user posting the tag
- $tags : array<string|int, mixed>
-
The user-provided tags
Tags
Return values
void —getBreadcrumb()
Get text that can be displayed to represent this record in breadcrumbs.
public
getBreadcrumb() : string
Return values
string —Breadcrumb text to represent this record.
getCitationFormats()
Get an array of supported, user-activated citation formats.
public
getCitationFormats() : array<string|int, mixed>
Return values
array<string|int, mixed> —Strings representing citation formats.
getComments()
Get comments associated with this record.
public
getComments() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —getContainingLists()
Get a list of lists containing this record.
public
getContainingLists([int $user_id = null ]) : array<string|int, mixed>
Parameters
- $user_id : int = null
-
ID of user to load tags from (null for all users)
Tags
Return values
array<string|int, mixed> —getDbService()
Get a database service object.
public
getDbService(class-string<\VuFind\Db\Service\T> $name) : T
Parameters
- $name : class-string<\VuFind\Db\Service\T>
-
Name of service to retrieve
Tags
Return values
T —getDbServiceManager()
Get the service plugin manager. Throw an exception if it is missing.
public
getDbServiceManager() : PluginManager
Tags
Return values
PluginManager —getDbTable()
Get a database table object.
public
getDbTable(string $table) : Gateway
Parameters
- $table : string
-
Table to load.
Return values
Gateway —getDbTableManager()
Get the table plugin manager. Throw an exception if it is missing.
public
getDbTableManager() : PluginManager
Tags
Return values
PluginManager —getExtraDetail()
Retrieve a piece of supplemental information stored using setExtraDetail().
public
getExtraDetail(string $key) : mixed
Parameters
- $key : string
-
Name of stored information
Return values
mixed —getLabels()
Return all labels for the record
public
getLabels() : array<string|int, mixed>
Return values
array<string|int, mixed> —An array of associative arrays with keys 'label' and 'class'
getListNotes()
Get notes associated with this record in user lists.
public
getListNotes([int $list_id = null ][, int $user_id = null ]) : array<string|int, mixed>
Parameters
- $list_id : int = null
-
ID of list to load tags from (null for all lists)
- $user_id : int = null
-
ID of user to load tags from (null for all users)
Tags
Return values
array<string|int, mixed> —getRatingBreakdown()
Get rating breakdown for this record.
public
getRatingBreakdown(array<string|int, mixed> $groups) : array<string|int, mixed>
Returns an array with the following keys:
rating - average rating (0-100) count - count of ratings groups - grouped counts
Parameters
- $groups : array<string|int, mixed>
-
Group definition (key => [min, max])
Tags
Return values
array<string|int, mixed> —getRatingData()
Get rating information for this record.
public
getRatingData([int|null $userId = null ]) : array<string|int, mixed>
Returns an array with the following keys:
rating - average rating (0-100) count - count of ratings
Parameters
- $userId : int|null = null
-
User ID, or null for all users
Tags
Return values
array<string|int, mixed> —getRawData()
Retrieve raw data from object (primarily for use in staff view and autocomplete; avoid using whenever possible).
public
getRawData() : mixed
Return values
mixed —getSearchBackendIdentifier()
Return the search backend identifier used to find the record.
public
getSearchBackendIdentifier() : string
Return values
string —getSortTitle()
Get a sortable title for the record (i.e. no leading articles).
public
getSortTitle() : string
Return values
string —getSourceIdentifier()
Return the source backend identifier.
public
getSourceIdentifier() : string
Return values
string —getTags()
Get tags associated with this record.
public
getTags([int $list_id = null ][, int $user_id = null ][, string $sort = 'count' ][, int $ownerId = null ]) : array<string|int, mixed>
Parameters
- $list_id : int = null
-
ID of list to load tags from (null for all lists)
- $user_id : int = null
-
ID of user to load tags from (null for all users)
- $sort : string = 'count'
-
Sort type ('count' or 'tag')
- $ownerId : int = null
-
ID of user to check for ownership
Tags
Return values
array<string|int, mixed> —getTranslator()
Get translator object.
public
getTranslator() : TranslatorInterface
Return values
TranslatorInterface —getTranslatorLocale()
Get the locale from the translator.
public
getTranslatorLocale([string $default = 'en' ]) : string
Parameters
- $default : string = 'en'
-
Default to use if translator absent.
Return values
string —getUniqueID()
Return the unique identifier of this record for retrieving additional information (like tags and user comments) from the external MySQL database.
public
getUniqueID() : string
Return values
string —Unique identifier.
isRatingAllowed()
Check if rating the record is allowed.
public
isRatingAllowed() : bool
Return values
bool —setDbServiceManager()
Set the service plugin manager.
public
setDbServiceManager(PluginManager $manager) : void
Parameters
- $manager : PluginManager
-
Plugin manager
Return values
void —setDbTableManager()
Set the table plugin manager.
public
setDbTableManager(PluginManager $manager) : void
Parameters
- $manager : PluginManager
-
Plugin manager
Return values
void —setExtraDetail()
Store a piece of supplemental information in the record driver.
public
setExtraDetail(string $key, mixed $val) : void
Parameters
- $key : string
-
Name of stored information
- $val : mixed
-
Information to store
Return values
void —setLabels()
Set the labels for the record
public
setLabels(array<string|int, mixed> $labels) : void
Parameters
- $labels : array<string|int, mixed>
-
An array of associative arrays with keys 'label' and 'class'
Return values
void —setRawData()
Set raw data to initialize the object.
public
setRawData(mixed $data) : void
Parameters
- $data : mixed
-
Raw data representing the record; Record Model objects are normally constructed by Record Driver objects using data passed in from a Search Results object. The exact nature of the data may vary depending on the data source -- the important thing is that the Record Driver + Search Results objects work together correctly.
Return values
void —setSourceIdentifier()
Set the record source backend identifier.
public
setSourceIdentifier(string $identifier) : void
Parameters
- $identifier : string
-
Record source identifier
Tags
Return values
void —setSourceIdentifiers()
Set the source backend identifiers.
public
setSourceIdentifiers(string $recordSourceId[, string $searchBackendId = '' ]) : void
Parameters
- $recordSourceId : string
-
Record source identifier
- $searchBackendId : string = ''
-
Search backend identifier (if different from $recordSourceId)
Return values
void —setTranslator()
Set a translator
public
setTranslator(TranslatorInterface $translator) : TranslatorAwareInterface
Parameters
- $translator : TranslatorInterface
-
Translator
Return values
TranslatorAwareInterface —supportsAjaxStatus()
Returns true if the record supports real-time AJAX status lookups.
public
supportsAjaxStatus() : bool
Return values
bool —supportsCoinsOpenUrl()
Checks the current record if it's supported for generating COinS-OpenURLs.
public
supportsCoinsOpenUrl() : bool
Return values
bool —supportsOpenUrl()
Checks the current record if it's supported for generating OpenURLs.
public
supportsOpenUrl() : bool
Return values
bool —translate()
Translate a string (or string-castable object)
public
translate(string|object|array<string|int, mixed> $target[, array<string|int, mixed> $tokens = [] ][, string $default = null ][, bool $useIcuFormatter = false ][, array<string|int, string> $fallbackDomains = [] ]) : string
Parameters
- $target : string|object|array<string|int, mixed>
-
String to translate or an array of text domain and string to translate
- $tokens : array<string|int, mixed> = []
-
Tokens to inject into the translated string
- $default : string = null
-
Default value to use if no translation is found (null for no default).
- $useIcuFormatter : bool = false
-
Should we use an ICU message formatter instead of the default behavior?
- $fallbackDomains : array<string|int, string> = []
-
Text domains to check if no match is found in the domain specified in $target
Return values
string —translateWithPrefix()
Translate a string (or string-castable object) using a prefix, or without the prefix if a prefixed translation is not found.
public
translateWithPrefix(string $prefix, string|object|array<string|int, mixed> $target[, array<string|int, mixed> $tokens = [] ][, string $default = null ][, bool $useIcuFormatter = false ][, array<string|int, string> $fallbackDomains = [] ]) : string
Parameters
- $prefix : string
-
Translation key prefix
- $target : string|object|array<string|int, mixed>
-
String to translate or an array of text domain and string to translate
- $tokens : array<string|int, mixed> = []
-
Tokens to inject into the translated string
- $default : string = null
-
Default value to use if no translation is found (null for no default).
- $useIcuFormatter : bool = false
-
Should we use an ICU message formatter instead of the default behavior?
- $fallbackDomains : array<string|int, string> = []
-
Text domains to check if no match is found in the domain specified in $target
Return values
string —tryMethod()
Try to call the requested method and return null if it is unavailable; this is useful for checking for the existence of get methods for particular types of data without causing fatal errors.
public
tryMethod(string $method[, array<string|int, mixed> $params = [] ][, mixed $default = null ]) : mixed
Parameters
- $method : string
-
Name of method to call.
- $params : array<string|int, mixed> = []
-
Array of parameters to pass to method.
- $default : mixed = null
-
A default value to return if the method is not callable
Return values
mixed —extractTextDomain()
Given a translation string with or without a text domain, return an array with the raw string and the text domain separated.
protected
extractTextDomain(string|object|array<string|int, mixed> $target) : array<string|int, mixed>
Parameters
- $target : string|object|array<string|int, mixed>
-
String to translate or an array of text domain and string to translate
Return values
array<string|int, mixed> —getDebugTranslation()
Build a debug-mode translation
protected
getDebugTranslation(string $domain, string $str, array<string|int, mixed> $tokens) : string
Parameters
- $domain : string
-
Text domain
- $str : string
-
String to translate
- $tokens : array<string|int, mixed>
-
Tokens to inject into the translated string
Return values
string —getSupportedCitationFormats()
Get an array of strings representing citation formats supported by this record's data (empty if none). For possible legal values, see /application/themes/root/helpers/Citation.php.
protected
getSupportedCitationFormats() : array<string|int, mixed>
Return values
array<string|int, mixed> —Strings representing citation formats.
sanitizeTranslationKey()
Make sure there are not any illegal characters in the translation key that might prevent successful lookup in language files.
protected
sanitizeTranslationKey(string $key) : string
Parameters
- $key : string
-
Key to sanitize
Return values
string —Sanitized key
translateString()
Get translation for a string
protected
translateString(string $rawStr[, array<string|int, mixed> $tokens = [] ][, string $default = null ][, string $domain = 'default' ][, bool $useIcuFormatter = false ]) : string
Parameters
- $rawStr : string
-
String to translate
- $tokens : array<string|int, mixed> = []
-
Tokens to inject into the translated string
- $default : string = null
-
Default value to use if no translation is found (null for no default).
- $domain : string = 'default'
-
Text domain (omit for default)
- $useIcuFormatter : bool = false
-
Should we use an ICU message formatter instead of the default behavior?