当前位置: 首页>>代码示例>>PHP>>正文


PHP InstallUtil::createSuperUser方法代码示例

本文整理汇总了PHP中InstallUtil::createSuperUser方法的典型用法代码示例。如果您正苦于以下问题:PHP InstallUtil::createSuperUser方法的具体用法?PHP InstallUtil::createSuperUser怎么用?PHP InstallUtil::createSuperUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在InstallUtil的用法示例。


在下文中一共展示了InstallUtil::createSuperUser方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: suite

 public static function suite()
 {
     global $argv;
     PhpUnitServiceUtil::checkVersion();
     $usage = PHP_EOL . "  Usage: phpunit [phpunit options] TestSuite.php <All|Framework|Misc|moduleName|TestClassName> [custom options]" . PHP_EOL . PHP_EOL . "    All                     Run all tests." . PHP_EOL . "    Framework               Run the tests in app/protected/extensions/framework/tests/unit." . PHP_EOL . "    Misc                    Run the tests in app/protected/tests/unit." . PHP_EOL . "    moduleName              Run the tests in app/protected/modules/moduleName/tests/unit." . PHP_EOL . "    TestClassName           Run the tests in TestClassName.php, wherever that happens to be." . PHP_EOL . PHP_EOL . "  Custom Options:" . PHP_EOL . PHP_EOL . "    --only-walkthroughs     For the specified test, only includes tests under a walkthroughs directory." . PHP_EOL . "    --exclude-walkthroughs  For the specified test, exclude tests under a walkthroughs directory." . PHP_EOL . "    --only-benchmarks       For the specified test, only includes tests under a benchmarks directory." . PHP_EOL . "    --exclude-benchmarks    For the specified test, exclude tests under a benchmarks directory." . PHP_EOL . "    --reuse-schema          Reload a previously auto build database. (Will auto build if there is no" . PHP_EOL . "                            previous one. The auto built schema is dumped to the system temp dir in" . PHP_EOL . "                            autobuild.sql.)" . PHP_EOL . PHP_EOL . "  Examples:" . PHP_EOL . PHP_EOL . "    phpunit --verbose TestSuite.php accounts (Run the tests in the Accounts module.)" . PHP_EOL . "    phpunit TestSuite.php RedBeanModelTest   (Run the tests in RedBeanModelTest.php.)" . PHP_EOL . PHP_EOL . "    To run specific tests use the phpunit --filter <regex> option." . PHP_EOL . "    phpunit has its own options. Check phpunit --help." . PHP_EOL . PHP_EOL;
     // Not Coding Standard
     $onlyWalkthroughs = self::customOptionSet('--only-walkthroughs', $argv);
     $excludeWalkthroughs = self::customOptionSet('--exclude-walkthroughs', $argv);
     $onlyBenchmarks = self::customOptionSet('--only-benchmarks', $argv);
     $excludeBenchmarks = self::customOptionSet('--exclude-benchmarks', $argv);
     $reuse = self::customOptionSet('--reuse-schema', $argv);
     if ($argv[count($argv) - 2] != 'TestSuite.php') {
         echo $usage;
         exit(static::ERROR_INVOCATION_WITHOUT_TESTSUITE);
     }
     if ($onlyWalkthroughs && $onlyBenchmarks) {
         echo $usage;
         echo "It doesn't have sense to select both \"--only-walkthroughs\" and \"--only-benchmarks\" options. " . PHP_EOL . PHP_EOL;
         exit(static::ERROR_WALKTHROUGH_AND_BENCHMARK_SELECTED);
     }
     $whatToTest = $argv[count($argv) - 1];
     $includeUnitTests = !$onlyWalkthroughs && !$onlyBenchmarks;
     $includeWalkthroughs = !$excludeWalkthroughs && !$onlyBenchmarks;
     $includeBenchmarks = !$excludeBenchmarks && !$onlyWalkthroughs;
     $suite = new PHPUnit_Framework_TestSuite();
     $suite->setName("{$whatToTest} Tests");
     self::buildAndAddSuiteFromDirectory($suite, 'Framework', COMMON_ROOT . '/protected/core/tests/unit', $whatToTest, true, false, $includeBenchmarks);
     $moduleDirectoryName = COMMON_ROOT . '/protected/modules';
     if (is_dir($moduleDirectoryName)) {
         $moduleNames = scandir($moduleDirectoryName);
         foreach ($moduleNames as $moduleName) {
             if ($moduleName != '.' && $moduleName != '..') {
                 $moduleUnitTestDirectoryName = "{$moduleDirectoryName}/{$moduleName}/tests/unit";
                 self::buildAndAddSuiteFromDirectory($suite, $moduleName, $moduleUnitTestDirectoryName, $whatToTest, $includeUnitTests, $includeWalkthroughs, $includeBenchmarks);
             }
         }
     }
     self::buildAndAddSuiteFromDirectory($suite, 'Misc', COMMON_ROOT . '/protected/tests/unit', $whatToTest, $includeUnitTests, $includeWalkthroughs, $includeBenchmarks);
     self::buildAndAddSuiteFromDirectory($suite, 'Commands', COMMON_ROOT . '/protected/commands/tests/unit', $whatToTest, $includeUnitTests, $includeWalkthroughs, $includeBenchmarks);
     ////////////////////////////////////////////////////////////////////////////////
     // Temporary - See Readme.txt in the notSupposedToBeHere directory.
     self::buildAndAddSuiteFromDirectory($suite, 'BadDependencies', COMMON_ROOT . '/protected/tests/unit/notSupposedToBeHere', $whatToTest, $includeUnitTests, $includeWalkthroughs, $includeBenchmarks);
     ////////////////////////////////////////////////////////////////////////////////
     if ($suite->count() == 0) {
         echo $usage;
         echo "  No tests found for '{$whatToTest}'." . PHP_EOL . PHP_EOL;
         exit(static::ERROR_TEST_NOT_FOUND);
     }
     echo "Testing with database: '" . Yii::app()->db->connectionString . '\', ' . 'username: \'' . Yii::app()->db->username . "'." . PHP_EOL;
     static::setupDatabaseConnection();
     // get rid of any caches from last execution, this ensure we rebuild any required tables
     // without this some of many_many tables have issues as we use cache to determine
     // if we need to rebuild those.
     ForgetAllCacheUtil::forgetAllCaches();
     $template = "{message}\n";
     $messageStreamer = new MessageStreamer($template);
     $messageStreamer->setExtraRenderBytes(0);
     $messageLogger = new MessageLogger($messageStreamer);
     $messageLogger->logDateTimeStamp = false;
     if (!$reuse) {
         if (!is_writable(sys_get_temp_dir())) {
             echo PHP_EOL . PHP_EOL . "Temp directory must be writable to store reusable schema" . PHP_EOL;
             // Not Coding Standard
             echo "Temp directory: " . sys_get_temp_dir() . PHP_EOL . PHP_EOL;
             // Not Coding Standard
             exit(static::ERROR_TEMP_DIR_NOT_WRITABLE);
         }
         echo "Auto building database schema..." . PHP_EOL;
         ZurmoRedBean::$writer->wipeAll();
         InstallUtil::autoBuildDatabase($messageLogger, true);
         $messageLogger->printMessages();
         // recreate all tables, we know there aren't existing because we just did a wipeAll();
         static::rebuildReadPermissionsTables(true, true, $messageStreamer);
         assert('RedBeanDatabase::isSetup()');
         Yii::app()->user->userModel = InstallUtil::createSuperUser('super', 'super');
         echo "Saving auto built schema..." . PHP_EOL;
         $schemaFile = sys_get_temp_dir() . '/autobuilt.sql';
         $success = preg_match("/;dbname=([^;]+)/", Yii::app()->db->connectionString, $matches);
         // Not Coding Standard
         assert('$success == 1');
         $databaseName = $matches[1];
         preg_match("/mysql:host=([^;]+)/", Yii::app()->db->connectionString, $matches);
         // Not Coding Standard
         $host = $matches[1];
         $systemOutput = system('mysqldump -u' . Yii::app()->db->username . ' -p' . Yii::app()->db->password . ' -h ' . $host . ' ' . $databaseName . " > {$schemaFile}");
         if ($systemOutput != null) {
             echo 'Dumping schema using system command. Output: ' . $systemOutput . PHP_EOL . PHP_EOL;
         }
     } else {
         echo PHP_EOL;
         static::buildDependentTestModels($messageLogger);
         $messageLogger->printMessages();
     }
     echo PHP_EOL;
     static::closeDatabaseConnection();
     return $suite;
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:97,代码来源:TestSuite.php

示例2: suite

 public static function suite()
 {
     global $argv, $freeze;
     PhpUnitServiceUtil::checkVersion();
     $usage = "\n" . "  Usage: phpunit [phpunit options] TestSuite.php <All|Framework|Misc|moduleName|TestClassName> [custom options]\n" . "\n" . "    All                     Run all tests.\n" . "    Framework               Run the tests in app/protected/extensions/framework/tests/unit.\n" . "    Misc                    Run the tests in app/protected/tests/unit.\n" . "    moduleName              Run the tests in app/protected/modules/moduleName/tests/unit.\n" . "    TestClassName           Run the tests in TestClassName.php, wherever that happens to be.\n" . "\n" . "  Custom Options:\n" . "\n" . "    --only-walkthroughs     For the specified test, only includes tests under a walkthroughs directory.\n" . "    --exclude-walkthroughs  For the specified test, exclude tests under a walkthroughs directory.\n" . "    --only-benchmarks       For the specified test, only includes tests under a benchmarks directory.\n" . "    --exclude-benchmarks    For the specified test, exclude tests under a benchmarks directory.\n" . "    --reuse-schema          Reload a previously auto build database. (Will auto build if there is no\n" . "                            previous one. The auto built schema is dumped to the system temp dir in\n" . "                            autobuild.sql.)\n" . "    --no-freeze             Don't auto build and freeze the database.\n" . "\n" . "  Examples:\n" . "\n" . "    phpunit --verbose TestSuite.php accounts (Run the tests in the Accounts module.)\n" . "    phpunit TestSuite.php RedBeanModelTest   (Run the tests in RedBeanModelTest.php.)\n" . "\n" . "  Note:\n" . "\n" . "    Framework and Misc tests run only when -no-freeze is specified.\n" . "\n" . "    To run specific tests use the phpunit --filter <regex> option.\n" . "    phpunit has its own options. Check phpunit --help.\n\n";
     // Not Coding Standard
     $onlyWalkthroughs = self::customOptionSet('--only-walkthroughs', $argv);
     $excludeWalkthroughs = self::customOptionSet('--exclude-walkthroughs', $argv);
     $onlyBenchmarks = self::customOptionSet('--only-benchmarks', $argv);
     $excludeBenchmarks = self::customOptionSet('--exclude-benchmarks', $argv);
     $reuse = self::customOptionSet('--reuse-schema', $argv);
     $freeze = !self::customOptionSet('--no-freeze', $argv);
     if ($freeze == true && FORCE_NO_FREEZE == true) {
         echo "\n\nBecause forceNoFreeze is set to TRUE in debugTest, you cannot run unit tests in frozen mode\n\n";
         // Not Coding Standard
         exit;
     }
     if ($argv[count($argv) - 2] != 'TestSuite.php') {
         echo $usage;
         exit;
     }
     if ($onlyWalkthroughs && $onlyBenchmarks) {
         echo $usage;
         echo "It doesn't have sense to select both \"--only-walkthroughs\" and \"--only-benchmarks\" options. \n\n";
         exit;
     }
     $whatToTest = $argv[count($argv) - 1];
     $includeUnitTests = !$onlyWalkthroughs && !$onlyBenchmarks;
     $includeWalkthroughs = !$excludeWalkthroughs && !$onlyBenchmarks;
     $includeBenchmarks = !$excludeBenchmarks && !$onlyWalkthroughs;
     echo "Testing with database: '" . Yii::app()->db->connectionString . '\', ' . 'username: \'' . Yii::app()->db->username . "'.\n";
     if ($freeze && !$reuse) {
         if (!is_writable(sys_get_temp_dir())) {
             echo "\n\nTemp directory must be writable to store reusable schema\n";
             // Not Coding Standard
             echo "Temp directory: " . sys_get_temp_dir() . "\n\n";
             // Not Coding Standard
             exit;
         }
         InstallUtil::connectToDatabaseWithConnectionString(Yii::app()->db->connectionString, Yii::app()->db->username, Yii::app()->db->password);
         echo "Auto building database schema...\n";
         InstallUtil::dropAllTables();
         Yii::app()->user->userModel = InstallUtil::createSuperUser('super', 'super');
         $messageLogger = new MessageLogger();
         InstallUtil::autoBuildDatabase($messageLogger);
         $messageLogger->printMessages();
         ReadPermissionsOptimizationUtil::rebuild();
         assert('RedBeanDatabase::isSetup()');
         echo "Saving auto built schema...\n";
         $schemaFile = sys_get_temp_dir() . '/autobuilt.sql';
         $success = preg_match("/;dbname=([^;]+)/", Yii::app()->db->connectionString, $matches);
         // Not Coding Standard
         assert('$success == 1');
         $databaseName = $matches[1];
         $systemOutput = system('mysqldump -u' . Yii::app()->db->username . ' -p' . Yii::app()->db->password . ' ' . $databaseName . " > {$schemaFile}");
         if ($systemOutput != null) {
             echo 'Dumping schema using system command. Output: ' . $systemOutput . "\n\n";
         }
         InstallUtil::close();
         echo "Database closed.\n";
         assert('!RedBeanDatabase::isSetup()');
     }
     $suite = new PHPUnit_Framework_TestSuite();
     $suite->setName("{$whatToTest} Tests");
     if (!$freeze) {
         self::buildAndAddSuiteFromDirectory($suite, 'Framework', COMMON_ROOT . '/protected/core/tests/unit', $whatToTest, true, false, $includeBenchmarks);
     }
     $moduleDirectoryName = COMMON_ROOT . '/protected/modules';
     if (is_dir($moduleDirectoryName)) {
         $moduleNames = scandir($moduleDirectoryName);
         foreach ($moduleNames as $moduleName) {
             if ($moduleName != '.' && $moduleName != '..') {
                 $moduleUnitTestDirectoryName = "{$moduleDirectoryName}/{$moduleName}/tests/unit";
                 self::buildAndAddSuiteFromDirectory($suite, $moduleName, $moduleUnitTestDirectoryName, $whatToTest, $includeUnitTests, $includeWalkthroughs, $includeBenchmarks);
             }
         }
     }
     if (!$freeze) {
         self::buildAndAddSuiteFromDirectory($suite, 'Misc', COMMON_ROOT . '/protected/tests/unit', $whatToTest, $includeUnitTests, $includeWalkthroughs, $includeBenchmarks);
         self::buildAndAddSuiteFromDirectory($suite, 'Commands', COMMON_ROOT . '/protected/commands/tests/unit', $whatToTest, $includeUnitTests, $includeWalkthroughs, $includeBenchmarks);
         ////////////////////////////////////////////////////////////////////////////////
         // Temporary - See Readme.txt in the notSupposedToBeHere directory.
         self::buildAndAddSuiteFromDirectory($suite, 'BadDependencies', COMMON_ROOT . '/protected/tests/unit/notSupposedToBeHere', $whatToTest, $includeUnitTests, $includeWalkthroughs, $includeBenchmarks);
         ////////////////////////////////////////////////////////////////////////////////
     }
     if ($suite->count() == 0) {
         echo $usage;
         echo "  No tests found for '{$whatToTest}'.\n\n";
         exit;
     }
     return $suite;
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:92,代码来源:TestSuite.php

示例3: runInstallation

 /**
  * Given an installSettingsForm, run the install including the schema creation and default data load. This is
  * used by the interactice install and the command line install.
  * @param object $form
  * @param object $messageStreamer
  */
 public static function runInstallation($form, &$messageStreamer)
 {
     assert('$form instanceof InstallSettingsForm');
     assert('$messageStreamer instanceof MessageStreamer');
     if (defined('IS_TEST')) {
         $perInstanceFilename = "perInstanceTest.php";
         $debugFilename = "debugTest.php";
     } else {
         @set_time_limit(1200);
         $perInstanceFilename = "perInstance.php";
         $debugFilename = "debug.php";
     }
     $messageStreamer->add(Zurmo::t('InstallModule', 'Connecting to Database.'));
     InstallUtil::connectToDatabase($form->databaseType, $form->databaseHostname, $form->databaseName, $form->databaseUsername, $form->databasePassword, $form->databasePort);
     ForgetAllCacheUtil::forgetAllCaches();
     $messageStreamer->add(Zurmo::t('InstallModule', 'Dropping existing tables.'));
     InstallUtil::dropAllTables();
     $messageStreamer->add(Zurmo::t('InstallModule', 'Creating super user.'));
     InstallUtil::createSuperUser('super', $form->superUserPassword);
     $messageLogger = new MessageLogger($messageStreamer);
     Yii::app()->custom->runBeforeInstallationAutoBuildDatabase($messageLogger);
     $messageStreamer->add(Zurmo::t('InstallModule', 'Starting database schema creation.'));
     $startTime = microtime(true);
     $messageStreamer->add('debugOn:' . BooleanUtil::boolToString(YII_DEBUG));
     $messageStreamer->add('phpLevelCaching:' . BooleanUtil::boolToString(PHP_CACHING_ON));
     $messageStreamer->add('memcacheLevelCaching:' . BooleanUtil::boolToString(MEMCACHE_ON));
     InstallUtil::autoBuildDatabase($messageLogger);
     $endTime = microtime(true);
     $messageStreamer->add(Zurmo::t('InstallModule', 'Total autobuild time: {formattedTime} seconds.', array('{formattedTime}' => number_format($endTime - $startTime, 3))));
     if (SHOW_QUERY_DATA) {
         $messageStreamer->add(PageView::getTotalAndDuplicateQueryCountContent());
         $messageStreamer->add(PageView::makeNonHtmlDuplicateCountAndQueryContent());
     }
     $messageStreamer->add(Zurmo::t('InstallModule', 'Database schema creation complete.'));
     $messageStreamer->add(Zurmo::t('InstallModule', 'Rebuilding Permissions.'));
     ReadPermissionsOptimizationUtil::rebuild();
     $messageStreamer->add(Zurmo::t('InstallModule', 'Freezing database.'));
     InstallUtil::freezeDatabase();
     $messageStreamer->add(Zurmo::t('InstallModule', 'Writing Configuration File.'));
     InstallUtil::writeConfiguration(INSTANCE_ROOT, $form->databaseType, $form->databaseHostname, $form->databaseName, $form->databaseUsername, $form->databasePassword, $form->databasePort, $form->memcacheHostname, (int) $form->memcachePortNumber, true, Yii::app()->language, $perInstanceFilename, $debugFilename, $form->hostInfo, $form->scriptUrl, $form->submitCrashToSentry);
     $messageStreamer->add(Zurmo::t('InstallModule', 'Setting up default data.'));
     DefaultDataUtil::load($messageLogger);
     Yii::app()->custom->runAfterInstallationDefaultDataLoad($messageLogger);
     // Send notification to super admin to delete test.php file in case if this
     // installation is used in production mode.
     $message = new NotificationMessage();
     $message->textContent = Zurmo::t('InstallModule', 'If this website is in production mode, please remove the app/test.php file.');
     $rules = new RemoveApiTestEntryScriptFileNotificationRules();
     NotificationsUtil::submit($message, $rules);
     // If minify is disabled, inform user that they should fix issues and enable minify
     $setIncludePathServiceHelper = new SetIncludePathServiceHelper();
     if (!$setIncludePathServiceHelper->runCheckAndGetIfSuccessful()) {
         $message = new NotificationMessage();
         $message->textContent = Zurmo::t('InstallModule', 'Minify has been disabled due to a system issue. Try to resolve the problem and re-enable Minify.');
         $rules = new EnableMinifyNotificationRules();
         NotificationsUtil::submit($message, $rules);
     }
     InstallUtil::setZurmoTokenAndWriteToPerInstanceFile(INSTANCE_ROOT);
     ZurmoPasswordSecurityUtil::setPasswordSaltAndWriteToPerInstanceFile(INSTANCE_ROOT);
     $messageStreamer->add(Zurmo::t('InstallModule', 'Installation Complete.'));
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:67,代码来源:InstallUtil.php

示例4: testConnectToDatabaseCreateSuperUserBuildDatabaseAndFreeze

 public function testConnectToDatabaseCreateSuperUserBuildDatabaseAndFreeze()
 {
     // This test cannot run as saltdev. It is therefore skipped on the server.
     if ($this->temporaryDatabaseUsername == 'root') {
         $this->assertTrue(DatabaseCompatibilityUtil::createDatabase('mysql', $this->temporaryDatabaseHostname, $this->temporaryDatabaseUsername, $this->temporaryDatabasePassword, $this->temporaryDatabasePort, $this->temporaryDatabaseName));
         $this->assertTrue(DatabaseCompatibilityUtil::createDatabaseUser('mysql', $this->temporaryDatabaseHostname, $this->temporaryDatabaseUsername, $this->temporaryDatabasePassword, $this->temporaryDatabasePort, $this->temporaryDatabaseName, 'wacko', 'wacked'));
         InstallUtil::connectToDatabase('mysql', $this->temporaryDatabaseHostname, 'wacky', $this->temporaryDatabaseUsername, $this->temporaryDatabasePassword, $this->temporaryDatabasePort);
         Yii::app()->user->userModel = InstallUtil::createSuperUser('super', 'super');
         $messageLogger = new MessageLogger();
         InstallUtil::autoBuildDatabase($messageLogger);
         $this->assertFalse($messageLogger->isErrorMessagePresent());
         ReadPermissionsOptimizationUtil::rebuild();
         InstallUtil::freezeDatabase();
         $tableNames = R::getCol('show tables');
         $this->assertEquals(array('_group', '_group__user', '_right', '_user', 'account', 'account_read', 'activity', 'activity_item', 'actual_permissions_cache', 'address', 'auditevent', 'contact', 'contact_opportunity', 'contact_read', 'contactstate', 'currency', 'currencyvalue', 'customfield', 'customfielddata', 'dashboard', 'email', 'filecontent', 'filemodel', 'globalmetadata', 'item', 'log', 'mashableactivity', 'meeting', 'meeting_read', 'namedsecurableitem', 'note', 'note_read', 'opportunity', 'opportunity_read', 'ownedcustomfield', 'ownedsecurableitem', 'permission', 'permitable', 'person', 'perusermetadata', 'policy', 'portlet', 'role', 'securableitem', 'task', 'task_read'), $tableNames);
     }
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:17,代码来源:InstallUtilTest.php


注:本文中的InstallUtil::createSuperUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。