Skip to content

Commit

Permalink
#62: Ensure that application helper tests use the test database.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamfranco committed Aug 12, 2024
1 parent 25f15ef commit 06f40e7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion application/resources/Catalog/Action/Helper/Osid.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function getConfigPath () {
* @throws osid_IllegalStateException The config path has already been set.
*/
public function setConfigPath ($path) {
if (isset(self::$configPath))
if (isset(self::$configPath) && self::$configPath != $path)
throw new osid_IllegalStateException('the config path has already been set');

self::$configPath = $path;
Expand Down
2 changes: 2 additions & 0 deletions application/test/Catalog/Action/Helper/OsidTermsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ class Catalog_Action_Helper_OsidTermsTest extends TestCase
protected function setUp(): void
{
$this->osidHelper = new Catalog_Action_Helper_Osid();
$this->osidHelper->setConfigPath($this->getTestConfigPath());
Zend_Controller_Action_HelperBroker::addHelper($this->osidHelper);
$this->osidIdHelper = new Catalog_Action_Helper_OsidId();
Zend_Controller_Action_HelperBroker::addHelper($this->osidIdHelper);
$this->osidTermsHelper = new Catalog_Action_Helper_OsidTerms();
$this->osidHelper->setConfigPath($this->getTestConfigPath());
Zend_Controller_Action_HelperBroker::addHelper($this->osidTermsHelper);

$this->mcugId = new phpkit_id_URNInetId('urn:inet:middlebury.edu:catalog/MCUG');
Expand Down
1 change: 1 addition & 0 deletions application/test/Catalog/Action/Helper/OsidTopicTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Catalog_Action_Helper_OsidTopicTest extends TestCase
protected function setUp(): void
{
$this->osidHelper = new Catalog_Action_Helper_Osid();
$this->osidHelper->setConfigPath($this->getTestConfigPath());
Zend_Controller_Action_HelperBroker::addHelper($this->osidHelper);
$this->osidIdHelper = new Catalog_Action_Helper_OsidId();
Zend_Controller_Action_HelperBroker::addHelper($this->osidIdHelper);
Expand Down
9 changes: 6 additions & 3 deletions application/test/Catalog/ApplicationTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ public static function setUpBeforeClass(): void

$registry = Zend_Registry::getInstance();
$registry->config = new Zend_Config_Ini(dirname(__FILE__).'/frontend_config.ini', 'development');
}

// Use the APC implementation instead of the direct-query Banner implementation.
self::$runtimeManager = new phpkit_AutoloadOsidRuntimeManager(dirname(__FILE__).'/../apc/configuration.plist');
self::$courseManager = self::$runtimeManager->getManager(osid_OSID::COURSE(), 'apc_course_CourseManager', '3.0.0');
/**
* Answer the configuration path to be used when running tests.
*/
public function getTestConfigPath() {
return dirname(__FILE__).'/../apc/configuration.plist';
}

}

0 comments on commit 06f40e7

Please sign in to comment.