コード例 #1
0
 /**
  * Check that the mechanism to detect unrecognised config files works as expected
  *
  */
 function test_findOtherConfigFiles()
 {
     // Test 1.
     $oConf = new OA_Admin_Settings(true);
     // Build the local conf array manually.
     $oConf->aConf['foo'] = array('one' => 'bar', 'two' => 'baz');
     $oConf->aConf['webpath']['admin'] = 'localhost2';
     $oConf->aConf['webpath']['delivery'] = 'localhost';
     $oConf->aConf['webpath']['deliverySSL'] = 'localhost3';
     $filename = 'oa_test_' . rand();
     $folder = $this->basePath . '/oa_test_' . rand();
     mkdir($folder);
     $this->assertEqual(array(), $oConf->findOtherConfigFiles($folder, $filename), 'Unexpected un-recognised config files detected');
     //Check that if there is an admin config file, it it recognised
     touch($folder . '/' . $oConf->aConf['webpath']['admin'] . $filename . '.conf.php');
     $this->assertEqual(array(), $oConf->findOtherConfigFiles($folder, $filename), 'Unexpected un-recognised config files detected');
     // Same for a deliverySSL config file:
     touch($folder . '/' . $oConf->aConf['webpath']['deliverySSL'] . $filename . '.conf.php');
     $this->assertEqual(array(), $oConf->findOtherConfigFiles($folder, $filename), 'Unexpected un-recognised config files detected');
     $unrecognisedFilename = $folder . '/localhost4.' . $filename . '.conf.php';
     touch($unrecognisedFilename);
     $this->assertNotEqual(array(), $oConf->findOtherConfigFiles($folder, $filename), 'Expected un-recognised config files NOT detected');
     // Cleanup
     unlink($folder . '/' . $oConf->aConf['webpath']['admin'] . $filename . '.conf.php');
     unlink($folder . '/' . $oConf->aConf['webpath']['deliverySSL'] . $filename . '.conf.php');
     unlink($unrecognisedFilename);
     rmdir($folder);
 }