/** * @covers \Kisma::set * @covers \Kisma::get * @cover \Kisma\Core\Utility\Inflector::neutralize */ public function testSet() { \Kisma::set('testSetOption', true); // These two keys are identical, but one is neutralized $this->assertTrue(true === \Kisma::get('testSetOption')); $this->assertTrue(true === \Kisma::get('test_set_option')); }
public function testGenerateUnique() { \Kisma::set('debug.kisma.core.utility.hasher::generate_unique', true); $_hash1 = Hasher::generateUnique(); $_hash2 = Hasher::generateUnique('*****@*****.**'); $_hash3 = Hasher::generateUnique(); $_hash4 = Hasher::generateUnique('*****@*****.**'); $this->assertTrue($_hash1 != $_hash3 && $_hash2 != $_hash4); }
/** * Extensible framework sniffer. * Subclass and add a YourClass::sniff_[framework]() method. * * @param string $path */ public static function framework($path = null) { foreach (\Kisma\Core\Enums\PhpFrameworks::getDefinedConstants() as $_constant => $_value) { $_thisClass = get_called_class(); $_method = 'sniff_' . $_value; if (method_exists($_thisClass, $_method) && call_user_func(array($_thisClass, $_method))) { \Kisma::set('app.framework', $_value); // Log::debug( 'PHP framework detected: ' . $_constant . ' (' . $_value . ')' ); switch ($_constant) { case \Kisma\Core\Enums\PhpFrameworks::Yii: /** * Pull in all the parameters from the Yii app into the bag... */ foreach (\Yii::app()->getParams()->toArray() as $_parameterName => $_parameterValue) { \Kisma::set($_parameterName, $_parameterValue); } break; } return $_value; } } }
* distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * bootstrap.php * Bootstrap script for PHPUnit tests */ $_basePath = dirname(__DIR__); $_vendorPath = $_basePath . '/vendor'; if (!is_dir($_vendorPath)) { echo 'Please run composer install/update before running tests.'; exit(1); } // Composer $_autoloader = (require $_basePath . '/vendor/autoload.php'); // Load up Yii require_once $_basePath . '/vendor/dreamfactory/yii/framework/yii.php'; // Yii debug settings defined(YII_DEBUG) or define(YII_DEBUG, true); defined(YII_TRACE_LEVEL) or define(YII_TRACE_LEVEL, 3); \Kisma::set('app.log_file', $_basePath . '/build/console.test.log'); $_config = (require __DIR__ . '/config/test.config.php'); // Testing keys if (file_exists(__DIR__ . '/config/keys.php')) { /** @noinspection PhpIncludeInspection */ require_once __DIR__ . '/config/keys.php'; } // Create the application but don't run (false at the end) $_app = DreamFactory\Yii\Utility\Pii::run($_basePath, $_autoloader, 'DreamFactory\\Platform\\Yii\\Components\\PlatformConsoleApplication', $_config, false, true, false);
$_keys = Pii::includeIfExists(__DIR__ . KEYS_CONFIG_PATH, true) ?: array(); /** @noinspection PhpIncludeInspection */ if (false !== ($_salts = Pii::includeIfExists(__DIR__ . SALT_CONFIG_PATH, true))) { if (!empty($_salts)) { foreach ($_salts as $_key => $_salt) { if ($_salt) { $_dspSalts['dsp.salts.' . $_key] = $_salt; } } } unset($_salts); } /** * Application Paths */ \Kisma::set(array('app.app_name' => $_appName, 'app.project_root' => $_basePath, 'app.vendor_path' => $_vendorPath, 'app.log_path' => $_logFilePath, 'app.log_file_name' => $_logFileName, 'app.install_type' => array($_installType => $_installName), 'app.fabric_hosted' => $_fabricHosted, 'app.doc_root' => $_docRoot)); /** * Database Caching */ $_dbCache = $_dbCacheEnabled ? array('class' => 'CDbCache', 'connectionID' => 'db', 'cacheTableName' => 'df_sys_cache', 'autoCreateCacheTable' => true) : null; $_storageKey = \Kisma::get('platform.storage_key'); /** * Set up and return the common settings... */ if ($_fabricHosted) { $_storagePath = $_storageBasePath = LocalStorageTypes::FABRIC_STORAGE_BASE_PATH . '/' . $_storageKey; $_privatePath = \Kisma::get('platform.private_path'); $_storagePath = $_storageBasePath . (version_compare(DSP_VERSION, '2.0.0', '<') ? '/blob' : null); $_identity = array('dsp.storage_id' => $_storageKey, 'dsp.private_storage_id' => \Kisma::get('platform.private_storage_key')); } else { $_storagePath = $_storageBasePath = $_basePath . LocalStorageTypes::LOCAL_STORAGE_BASE_PATH;
// Where the log files go and the name... $_logFilePath = $_basePath . '/log'; $_logFileName = basename(\Kisma::get('app.log_file')); // Our app's name $_appName = 'Portal Sandbox Test Suite'; /** * Aliases */ file_exists(__DIR__ . ALIASES_CONFIG_PATH) && (require __DIR__ . ALIASES_CONFIG_PATH); /** * Application Paths */ \Kisma::set('app.app_name', $_appName); \Kisma::set('app.doc_root', $_docRoot); \Kisma::set('app.log_path', $_logFilePath); \Kisma::set('app.vendor_path', $_vendorPath); \Kisma::set('app.log_file_name', $_logFileName); \Kisma::set('app.project_root', $_basePath); /** * Database Caching */ $_dbCache = $_dbCacheEnabled ? array('class' => 'CDbCache', 'connectionID' => 'db', 'cacheTableName' => 'df_sys_cache', 'autoCreateCacheTable' => true) : null; /** * Set up and return the common settings... */ if (Fabric::fabricHosted()) { $_instanceSettings = array('storage_base_path' => '/data/storage/' . \Kisma::get('platform.storage_key'), 'storage_path' => '/data/storage/' . \Kisma::get('platform.storage_key') . '/blob', 'private_path' => \Kisma::get('platform.private_path'), 'snapshot_path' => \Kisma::get('platform.private_path') . '/snapshots', 'applications_path' => '/data/storage/' . \Kisma::get('platform.storage_key') . '/blob/applications', 'library_path' => '/data/storage/' . \Kisma::get('platform.storage_key') . '/blob/lib', 'plugins_path' => '/data/storage/' . \Kisma::get('platform.storage_key') . '/blob/plugins', 'dsp_name' => \Kisma::get('platform.dsp_name'), 'dsp.storage_id' => \Kisma::get('platform.storage_key'), 'dsp.private_storage_id' => \Kisma::get('platform.private_storage_key')); } else { $_instanceSettings = array('storage_base_path' => $_basePath . '/storage', 'storage_path' => $_basePath . '/storage', 'private_path' => $_basePath . '/storage/.private', 'snapshot_path' => $_basePath . '/storage/.private/snapshots', 'applications_path' => $_basePath . '/storage/applications', 'library_path' => $_basePath . '/storage/lib', 'plugins_path' => $_basePath . '/storage/plugins', 'dsp_name' => gethostname(), 'dsp.storage_id' => null, 'dsp.private_storage_id' => null); } return array_merge($_instanceSettings, array('base_path' => $_basePath, 'dsp.version' => DSP_VERSION, 'dsp.name' => $_instanceSettings['dsp_name'], 'dsp.auth_endpoint' => DEFAULT_INSTANCE_AUTH_ENDPOINT, 'cloud.endpoint' => DEFAULT_CLOUD_API_ENDPOINT, 'oauth.salt' => 'rW64wRUk6Ocs+5c7JwQ{69U{]MBdIHqmx9Wj,=C%S#cA%+?!cJMbaQ+juMjHeEx[dlSe%h%kcI', 'dsp.allow_remote_logins' => true, 'dsp.allow_admin_remote_logins' => true, 'adminEmail' => DEFAULT_SUPPORT_EMAIL, 'dsp.service_config' => require __DIR__ . SERVICES_CONFIG_PATH, 'dsp.service_location_map' => array(), 'dsp.default_services' => array(array('api_name' => 'user', 'name' => 'User Login'), array('api_name' => 'system', 'name' => 'System Configuration'), array('api_name' => 'api_docs', 'name' => 'API Documentation')), 'dsp.default_app' => '/launchpad/index.html', 'dsp.confirm_invite_url' => '/confirm_invite.html', 'dsp.confirm_register_url' => '/confirm_reg.html', 'dsp.confirm_reset_url' => '/confirm_reset.html', 'dsp.db_max_records_returned' => 1000, 'admin.resource_schema' => require __DIR__ . DEFAULT_ADMIN_RESOURCE_SCHEMA, 'admin.default_theme' => 'united'));