Open Journal Systems  3.3.0
PKPTestCase Class Reference
Inheritance diagram for PKPTestCase:
ArticleSearchIndexTest ArticleSearchTest AuthorizationPolicyTest CitationListTokenizerFilterTest ClassTypeDescriptionTest ConfigTest CoreTest DatabaseTestCase DataObjectTest DispatcherTest FileCacheTest FilterHelperTest FilterTest FormValidatorArrayCustomTest FormValidatorArrayTest FormValidatorBooleanTest FormValidatorControlledVocabTest FormValidatorCustomTest FormValidatorEmailTest FormValidatorInSetTest FormValidatorLengthTest FormValidatorLocaleEmailTest FormValidatorLocaleTest FormValidatorPostTest FormValidatorRegExpTest FormValidatorTest FormValidatorUrlTest FormValidatorUsernameTest JSONTest MedraWebserviceTest MetadataDescriptionTest MetadataPropertyTest O4DOIObjectCacheTest OAIMetadataFormat_DCTest PersistableFilterTest PKPLocaleTest PKPNotificationManagerTest PKPRequestTest PKPRouterTestCase PluginTest PolicySetTest PolicyTestCase PrimitiveTypeDescriptionTest PublicationTest PubObjectCacheTest ScheduledTaskHelperTest TypeDescriptionFactoryTest UsageStatsLoaderTest ValidatorControlledVocabTest ValidatorEmailTest ValidatorISSNTest ValidatorORCIDTest ValidatorTypeDescriptionTest ValidatorUrlTest XMLTypeDescriptionTest

Public Member Functions

 getActualOutput ()
 

Data Fields

 $mockedRegistryKeys = array()
 
 $registryBackup = array()
 

Protected Member Functions

 getMockedDAOs ()
 
 getMockedRegistryKeys ()
 
 mockRequest ($path='index/test-page/test-op', $userId=null)
 
 setTestConfiguration ($config, $configPath='config')
 
 setUp ()
 
 tearDown ()
 

Detailed Description

Class that implements functionality common to all PKP unit test cases.

NB: PHPUnit 3.x requires PHP 5.2 or later so we can use PHP5 constructs.

Definition at line 27 of file PKPTestCase.inc.php.

Member Function Documentation

◆ getActualOutput()

PKPTestCase::getActualOutput ( )

Definition at line 98 of file PKPTestCase.inc.php.

◆ getMockedDAOs()

PKPTestCase::getMockedDAOs ( )
protected

Override this method if you want to backup/restore DAOs before/after the test.

Returns
array A list of DAO names to backup and restore.

Reimplemented in PKPNotificationManagerTest, ArticleSearchTest, OAIMetadataFormat_DCTest, ArticleSearchIndexTest, ValidatorControlledVocabTest, and FormValidatorControlledVocabTest.

Definition at line 38 of file PKPTestCase.inc.php.

Referenced by setUp(), and tearDown().

◆ getMockedRegistryKeys()

PKPTestCase::getMockedRegistryKeys ( )
protected

Override this method if you want to backup/restore registry entries before/after the test.

Returns
array A list of registry keys to backup and restore.

Reimplemented in OAIMetadataFormat_DCTest, PolicyTestCase, PluginTestCase, and DispatcherTest.

Definition at line 47 of file PKPTestCase.inc.php.

References $mockedRegistryKeys.

Referenced by setUp(), and tearDown().

◆ mockRequest()

PKPTestCase::mockRequest (   $path = 'index/test-page/test-op',
  $userId = null 
)
protected

Mock a web request.

For correct timing you have to call this method in the setUp() method of a test after calling parent::setUp() or in a test method. You can also call this method as many times as necessary from within your test and you're guaranteed to receive a fresh request whenever you call it.

And make sure that you merge any additional mocked registry keys with the ones returned from this class.

Parameters
$pathstring
$userIdint
Returns
Request

Definition at line 143 of file PKPTestCase.inc.php.

References $application, Registry\delete(), Registry\get(), and PKPApplication\get().

◆ setTestConfiguration()

PKPTestCase::setTestConfiguration (   $config,
  $configPath = 'config' 
)
protected

Set a non-default test configuration

Parameters
$configstring the id of the configuration to use
$configPathstring (optional) where to find the config file, default: 'config'
$dbConnect(optional) whether to try to re-connect the data base, default: true

Definition at line 113 of file PKPTestCase.inc.php.

References Config\getConfigFileName(), and Config\setConfigFileName().

Referenced by PKPRequestTest\testGetBaseUrl(), PKPRequestTest\testGetBaseUrlWithHostDetection(), PKPRouterTestCase\testGetIndexUrl(), PKPRouterTestCase\testGetIndexUrlRestful(), PKPRequestTest\testGetRequestPath(), PKPRequestTest\testGetRequestPathRestful(), PKPRequestTest\testGetRequestPathWithoutPathinfo(), PKPRequestTest\testGetRequestPathWithPathinfo(), DBConnectionTest\testInitCustomDBConnection(), DBConnectionTest\testInitPostgresDBConnection(), PKPPageRouterTest\testIsCacheableNotInstalled(), PKPPageRouterTest\testIsCacheableWithoutPathinfo(), PKPPageRouterTest\testIsCacheableWithoutPathinfoSuccess(), PKPPageRouterTest\testIsCacheableWithPathinfo(), PKPPageRouterTest\testIsCacheableWithPathinfoSuccess(), PKPPageRouterTest\testIsCacheableWithPost(), PKPRequestTest\testIsPathInfoEnabled1(), PKPRequestTest\testIsPathInfoEnabled2(), PKPRequestTest\testIsRestfulUrlsEnabled1(), PKPRequestTest\testIsRestfulUrlsEnabled2(), PKPComponentRouterTest\testUrlWithoutPathinfoAndOverriddenBaseUrl(), PKPPageRouterTest\testUrlWithoutPathinfoAndOverriddenBaseUrl(), PKPComponentRouterTest\testUrlWithoutPathinfoAndSecondContextObjectIsNull(), PKPPageRouterTest\testUrlWithoutPathinfoAndSecondContextObjectIsNull(), PKPPageRouterTest\testUrlWithPathinfo(), PKPComponentRouterTest\testUrlWithPathinfo(), PKPPageRouterTest\testUrlWithPathinfoAndOverriddenBaseUrl(), PKPComponentRouterTest\testUrlWithPathinfoAndOverriddenBaseUrl(), and PKPPageRouterTest\testUrlWithPathinfoAndOverriddenNewContext().

◆ setUp()

◆ tearDown()

Field Documentation

◆ $mockedRegistryKeys

PKPTestCase::$mockedRegistryKeys = array()

Definition at line 31 of file PKPTestCase.inc.php.

Referenced by getMockedRegistryKeys().

◆ $registryBackup

PKPTestCase::$registryBackup = array()

Definition at line 30 of file PKPTestCase.inc.php.


The documentation for this class was generated from the following file: