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


PHP InstallUtil::autoBuildDatabase方法代码示例

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


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

示例1: testSaveAllMetadata

 public function testSaveAllMetadata()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $this->assertTrue(ContactsModule::loadStartingData());
     $messageLogger = new MessageLogger();
     InstallUtil::autoBuildDatabase($messageLogger, true);
     chdir(COMMON_ROOT . DIRECTORY_SEPARATOR . 'protected' . DIRECTORY_SEPARATOR . 'commands');
     $command = "php zurmocTest.php manageMetadata super saveAllMetadata";
     if (!IS_WINNT) {
         $command .= ' 2>&1';
     }
     exec($command, $output);
     // Check if data are saved for some specific View
     $moduleMetadata = ZurmoRedBean::getRow("SELECT * FROM globalmetadata WHERE classname='NotesModule'");
     $this->assertTrue($moduleMetadata['id'] > 0);
     $this->assertTrue(strlen($moduleMetadata['serializedmetadata']) > 0);
     // Check if data are saved for some specific View
     $modelMetadata = ZurmoRedBean::getRow("SELECT * FROM globalmetadata WHERE classname='Note'");
     $this->assertTrue($modelMetadata['id'] > 0);
     $this->assertTrue(strlen($modelMetadata['serializedmetadata']) > 0);
     // Check if data are saved for some specific View
     $viewMetadata = ZurmoRedBean::getRow("SELECT * FROM globalmetadata WHERE classname='ContactsListView'");
     $this->assertTrue($viewMetadata['id'] > 0);
     $this->assertTrue(strlen($viewMetadata['serializedmetadata']) > 0);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:26,代码来源:ManageMetadataCommandTest.php

示例2: testRun

 public function testRun()
 {
     $this->assertTrue(ContactsModule::loadStartingData());
     $messageLogger = new MessageLogger();
     InstallUtil::autoBuildDatabase($messageLogger);
     chdir(COMMON_ROOT . DIRECTORY_SEPARATOR . 'protected' . DIRECTORY_SEPARATOR . 'commands');
     $command = "php zurmocTest.php jobManager super ExportCleanup";
     if (!IS_WINNT) {
         $command .= ' 2>&1';
     }
     exec($command, $output);
     $this->assertTrue(array_search('Info - Job completed successfully', $output) !== false);
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:13,代码来源:JobManagerCommandTest.php

示例3: testRun

 public function testRun()
 {
     $this->assertTrue(ContactsModule::loadStartingData());
     $messageLogger = new MessageLogger();
     InstallUtil::autoBuildDatabase($messageLogger, true);
     chdir(COMMON_ROOT . DIRECTORY_SEPARATOR . 'protected' . DIRECTORY_SEPARATOR . 'commands');
     $command = "php zurmocTest.php jobManager super ExportCleanup";
     if (!IS_WINNT) {
         $command .= ' 2>&1';
     }
     exec($command, $output);
     $this->assertContains('Sending output to', $output[2]);
     $this->assertContains('ExportCleanup.log', $output[2]);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:14,代码来源:JobManagerCommandTest.php

示例4: testRun

 public function testRun()
 {
     $this->assertTrue(ContactsModule::loadStartingData());
     $messageLogger = new MessageLogger();
     InstallUtil::autoBuildDatabase($messageLogger);
     chdir(COMMON_ROOT . DIRECTORY_SEPARATOR . 'protected' . DIRECTORY_SEPARATOR . 'commands');
     $command = "php zurmocTest.php updateSchema super";
     if (!IS_WINNT) {
         $command .= ' 2>&1';
     }
     exec($command, $output);
     $this->assertTrue(array_search('Info - Auto built Account saved.', $output) !== false);
     $this->assertTrue(array_search('Schema update complete.', $output) !== false);
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:14,代码来源:UpdateSchemaCommandTest.php

示例5: 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

示例6: testAutoBuildUpgrade

 /**
  * @depends testAutoBuildDatabase
  */
 public function testAutoBuildUpgrade()
 {
     $this->unfreezeWhenDone = false;
     if (RedBeanDatabase::isFrozen()) {
         RedBeanDatabase::unfreeze();
         $this->unfreezeWhenDone = true;
     }
     // adding Text Field
     $metadata = Account::getMetadata();
     $metadata['Account']['members'][] = 'newField';
     $rules = array('newField', 'type', 'type' => 'string');
     $metadata['Account']['rules'][] = $rules;
     $metadata['Account']['members'][] = 'string128';
     $rules = array('string128', 'type', 'type' => 'string');
     $metadata['Account']['rules'][] = $rules;
     $rules = array('string128', 'length', 'min' => 3, 'max' => 128);
     $metadata['Account']['rules'][] = $rules;
     $metadata['Account']['members'][] = 'string555';
     $rules = array('string555', 'type', 'type' => 'string');
     $metadata['Account']['rules'][] = $rules;
     $rules = array('string555', 'length', 'min' => 1, 'max' => 555);
     $metadata['Account']['rules'][] = $rules;
     $metadata['Account']['members'][] = 'string100000';
     $rules = array('string100000', 'type', 'type' => 'string');
     $metadata['Account']['rules'][] = $rules;
     $rules = array('string100000', 'length', 'min' => 1, 'max' => 100000);
     $metadata['Account']['rules'][] = $rules;
     $metadata['Account']['members'][] = 'textField';
     $rules = array('textField', 'type', 'type' => 'text');
     $metadata['Account']['rules'][] = $rules;
     $metadata['Account']['members'][] = 'longTextField';
     $rules = array('longTextField', 'type', 'type' => 'longtext');
     $metadata['Account']['rules'][] = $rules;
     $metadata['Account']['members'][] = 'dateField';
     $rules = array('dateField', 'type', 'type' => 'date');
     $metadata['Account']['rules'][] = $rules;
     $metadata['Account']['members'][] = 'booleanField';
     $rules = array('booleanField', 'boolean');
     $metadata['Account']['rules'][] = $rules;
     $metadata['Account']['members'][] = 'integerField';
     $rules = array('integerField', 'type', 'type' => 'integer');
     $metadata['Account']['rules'][] = $rules;
     $metadata['Account']['members'][] = 'dateTimeField';
     $rules = array('dateTimeField', 'type', 'type' => 'datetime');
     $metadata['Account']['rules'][] = $rules;
     $metadata['Account']['members'][] = 'urlField';
     $rules = array('urlField', 'url');
     $metadata['Account']['rules'][] = $rules;
     $metadata['Account']['members'][] = 'floatField';
     $rules = array('floatField', 'type', 'type' => 'float');
     $metadata['Account']['rules'][] = $rules;
     $metadata['Account']['members'][] = 'longTextField';
     $rules = array('longTextField', 'type', 'type' => 'longtext');
     $metadata['Account']['rules'][] = $rules;
     $metadata['Account']['members'][] = 'blobField';
     $rules = array('blobField', 'type', 'type' => 'blob');
     $metadata['Account']['rules'][] = $rules;
     $metadata['Account']['members'][] = 'longBlobField';
     $rules = array('longBlobField', 'type', 'type' => 'longblob');
     $metadata['Account']['rules'][] = $rules;
     Account::setMetadata($metadata);
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $messageLogger = new MessageLogger();
     $beforeRowCount = DatabaseCompatibilityUtil::getTableRowsCountTotal();
     InstallUtil::autoBuildDatabase($messageLogger);
     $afterRowCount = DatabaseCompatibilityUtil::getTableRowsCountTotal();
     $this->assertEquals($beforeRowCount, $afterRowCount);
     //Check Account fields
     $tableName = RedBeanModel::getTableName('Account');
     $columns = R::$writer->getColumns($tableName);
     $this->assertEquals('text', $columns['newfield']);
     $this->assertEquals('varchar(128)', $columns['string128']);
     $this->assertEquals('text', $columns['string555']);
     $this->assertEquals('longtext', $columns['string100000']);
     $this->assertEquals('text', $columns['textfield']);
     $this->assertEquals('date', $columns['datefield']);
     $this->assertEquals('tinyint(1)', $columns['booleanfield']);
     $this->assertEquals('int(11) unsigned', $columns['integerfield']);
     $this->assertEquals('datetime', $columns['datetimefield']);
     $this->assertEquals('varchar(255)', $columns['urlfield']);
     $this->assertEquals('double', $columns['floatfield']);
     $this->assertEquals('longtext', $columns['longtextfield']);
     $this->assertEquals('blob', $columns['blobfield']);
     $this->assertEquals('longblob', $columns['longblobfield']);
     $account = new Account();
     $account->name = 'Test Name';
     $account->owner = $super;
     $randomString = str_repeat("Aa", 64);
     $account->string128 = $randomString;
     $this->assertTrue($account->save());
     $metadata = Account::getMetadata();
     foreach ($metadata['Account']['rules'] as $key => $rule) {
         if ($rule[0] == 'string128' && $rule[1] == 'length') {
             $metadata['Account']['rules'][$key]['max'] = 64;
         }
     }
//.........这里部分代码省略.........
开发者ID:youprofit,项目名称:Zurmo,代码行数:101,代码来源:AutoBuildDatabaseTest.php

示例7: 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

示例8: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     // we are using some hardcoded Ids, we need fresh tables so these Ids are what we expect, rebuild:
     ForgetAllCacheUtil::forgetAllCaches();
     ZurmoRedBean::$writer->wipeAll();
     InstallUtil::autoBuildDatabase(new MessageLogger(), true);
     // This is setting up users and groups to match Jason's
     // powerpoint workings out of how the munge should look
     // after each operation. Things are set up in the order
     // that will give them the right ids to have munge ids
     // that match the document. The names are adjusted
     // to conform to the minimum lengths and casing in
     // the models. This the basic set up that is almost
     // right for many of the tests, and each test does
     // whatever it needs to to make the exactly what it
     // needs AND puts it back how it found it.
     $u1 = new User();
     $u1->username = 'u1.';
     $u1->lastName = 'U1';
     $saved = $u1->save();
     assert('$saved');
     // Not Coding Standard
     assert('$u1->id == 1');
     // Not Coding Standard
     $u2 = new User();
     $u2->username = 'u2.';
     $u2->lastName = 'U2';
     $saved = $u2->save();
     assert('$saved');
     // Not Coding Standard
     assert('$u2->id == 2');
     // Not Coding Standard
     $u3 = new User();
     $u3->username = 'u3.';
     $u3->lastName = 'U3';
     $saved = $u3->save();
     assert('$saved');
     // Not Coding Standard
     assert('$u3->id == 3');
     // Not Coding Standard
     $u4 = new User();
     $u4->username = 'u4.';
     $u4->lastName = 'U4';
     $saved = $u4->save();
     assert('$saved');
     // Not Coding Standard
     assert('$u4->id == 4');
     // Not Coding Standard
     $u5 = new User();
     $u5->username = 'u5.';
     $u5->lastName = 'U5';
     $saved = $u5->save();
     assert('$saved');
     // Not Coding Standard
     assert('$u5->id == 5');
     // Not Coding Standard
     $u6 = new User();
     $u6->username = 'u6.';
     $u6->lastName = 'U6';
     $saved = $u6->save();
     assert('$saved');
     // Not Coding Standard
     assert('$u6->id == 6');
     // Not Coding Standard
     $u99 = new User();
     // A user with no roles
     $u99->username = 'u99.';
     // that can create accounts
     $u99->lastName = 'U99';
     // without having any
     $saved = $u99->save();
     // effect on the munge.
     assert('$saved');
     // Not Coding Standard
     $g1 = new Group();
     $g1->name = 'G1.';
     $saved = $g1->save();
     assert('$saved');
     // Not Coding Standard
     assert('$g1->id == 1');
     // Not Coding Standard
     $g2 = new Group();
     $g2->name = 'G2.';
     $saved = $g2->save();
     assert('$saved');
     // Not Coding Standard
     assert('$g2->id == 2');
     // Not Coding Standard
     $g3 = new Group();
     $g3->name = 'G3.';
     $saved = $g3->save();
     assert('$saved');
     // Not Coding Standard
     assert('$g3->id == 3');
     // Not Coding Standard
     $r1 = new Role();
     $r1->name = 'R1.';
     $saved = $r1->save();
     assert('$saved');
//.........这里部分代码省略.........
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:101,代码来源:AccountReadPermissionsOptimizationScenariosTest.php

示例9: testConnectToDatabaseCreateSuperUserBuildDatabase

 public function testConnectToDatabaseCreateSuperUserBuildDatabase()
 {
     InstallUtil::connectToDatabase('mysql', $this->temporaryDatabaseHostname, $this->temporaryDatabaseName, $this->temporaryDatabaseUsername, $this->temporaryDatabasePassword, $this->temporaryDatabasePort);
     $messageLogger = new MessageLogger();
     InstallUtil::autoBuildDatabase($messageLogger, true);
     $this->assertFalse($messageLogger->isErrorMessagePresent());
     AllPermissionsOptimizationUtil::rebuild();
     $tableNames = ZurmoRedBean::$writer->getTables();
     $expectedTables = array('_group', '_group__user', '_right', '_user', 'account', 'account_read', 'account_read_subscription', 'accountstarred', 'activelanguage', 'activity', 'activity_item', 'address', 'auditevent', 'autoresponder', 'autoresponderitem', 'autoresponderitemactivity', 'basecustomfield', 'bytimeworkflowinqueue', 'calculatedderivedattributemetadata', 'campaign', 'campaign_read', 'campaignitem', 'campaignitemactivity', 'comment', 'contact', 'contact_opportunity', 'contact_read', 'contact_read_subscription', 'contactstarred', 'contactstate', 'contactwebform', 'contactwebform_read', 'contactwebformentry', 'conversation', 'conversation_item', 'conversation_read', 'conversationstarred', 'conversationparticipant', 'currency', 'currencyvalue', 'customfield', 'customfielddata', 'customfieldvalue', 'dashboard', 'derivedattributemetadata', 'dropdowndependencyderivedattributemetadata', 'email', 'emailaccount', 'emailbox', 'emailfolder', 'emailmessage', 'emailmessage_read', 'emailmessageactivity', 'emailmessagecontent', 'emailmessagerecipient', 'emailmessagesender', 'emailmessagesenderror', 'emailmessageurl', 'emailsignature', 'emailtemplate', 'emailtemplate_read', 'exportfilemodel', 'exportitem', 'filecontent', 'filemodel', 'gamebadge', 'gamelevel', 'gamenotification', 'gamepoint', 'gamepointtransaction', 'gamescore', 'globalmetadata', 'import', 'item', 'jobinprocess', 'joblog', 'marketinglist', 'marketinglist_read', 'marketinglistmember', 'meeting', 'meeting_read', 'meeting_read_subscription', 'messagesource', 'messagetranslation', 'mission', 'mission_read', 'modelcreationapisync', 'multiplevaluescustomfield', 'namedsecurableitem', 'note', 'note_read', 'notification', 'notificationmessage', 'opportunity', 'opportunity_read', 'opportunitystarred', 'ownedsecurableitem', 'permission', 'permitable', 'person', 'personwhohavenotreadlatest', 'perusermetadata', 'policy', 'portlet', 'product', 'product_productcategory', 'product_read', 'productcatalog', 'productcatalog_productcategory', 'productcategory', 'productcategory_producttemplate', 'producttemplate', 'role', 'savedreport', 'savedreport_read', 'savedsearch', 'savedworkflow', 'securableitem', 'sellpriceformula', 'socialitem', 'socialitem_read', 'task', 'task_read', 'task_read_subscription', 'workflowmessageinqueue');
     foreach ($expectedTables as $expectedTable) {
         $this->assertTrue(in_array($expectedTable, $tableNames));
     }
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:13,代码来源:InstallUtilTest.php

示例10: runUpdateSchema

 protected function runUpdateSchema(&$output, $overwriteExistingReadTables = null)
 {
     $messageLogger = new MessageLogger();
     InstallUtil::autoBuildDatabase($messageLogger, true);
     chdir(COMMON_ROOT . DIRECTORY_SEPARATOR . 'protected' . DIRECTORY_SEPARATOR . 'commands');
     $command = "php zurmocTest.php updateSchema super " . $overwriteExistingReadTables;
     //echo PHP_EOL . "Executing : $command" . PHP_EOL;
     if (!IS_WINNT) {
         $command .= ' 2>&1';
     }
     exec($command, $output);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:12,代码来源:UpdateSchemaCommandTest.php

示例11: 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

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