當前位置: 首頁>>代碼示例>>PHP>>正文


PHP SapphireTest類代碼示例

本文整理匯總了PHP中SapphireTest的典型用法代碼示例。如果您正苦於以下問題:PHP SapphireTest類的具體用法?PHP SapphireTest怎麽用?PHP SapphireTest使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了SapphireTest類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: artefacts

 /**
  * @return array
  */
 private function artefacts()
 {
     $oldschema = [];
     $newschema = [];
     $current = DB::get_conn()->getSelectedDatabase();
     foreach (DB::table_list() as $lowercase => $dbtablename) {
         $oldschema[$dbtablename] = DB::field_list($dbtablename);
     }
     $test = new SapphireTest();
     $test->create_temp_db();
     foreach (DB::table_list() as $lowercase => $dbtablename) {
         $newschema[$lowercase] = DB::field_list($dbtablename);
     }
     $test->kill_temp_db();
     DB::get_conn()->selectDatabase($current);
     $artefacts = [];
     foreach ($oldschema as $table => $fields) {
         if (!isset($newschema[strtolower($table)])) {
             $artefacts[$table] = $table;
             continue;
         }
         foreach ($fields as $field => $spec) {
             if (!isset($newschema[strtolower($table)][$field])) {
                 $artefacts[$table][$field] = $field;
             }
         }
     }
     return $artefacts;
 }
開發者ID:oddnoc,項目名稱:silverstripe-artefactcleaner,代碼行數:32,代碼來源:ArtefactCleanTask.php

示例2: run

 public function run($request)
 {
     $db = DB::getConn();
     if (!$db instanceof MySQLDatabase) {
         echo '<h3>This task only appies to MySQL databases. This installation is using a ' . get_class($db) . '</h3>';
         return;
     }
     $oldschema = array();
     $newschema = array();
     $renamed = 0;
     $current = DB::getConn()->currentDatabase();
     foreach (DB::getConn()->tableList() as $lowercase => $dbtablename) {
         $oldschema[] = $dbtablename;
     }
     DB::getConn()->selectDatabase('tmpdb');
     $test = new SapphireTest();
     $test->create_temp_db();
     foreach (DB::getConn()->tableList() as $lowercase => $dbtablename) {
         $newschema[] = $dbtablename;
     }
     $test->kill_temp_db();
     DB::getConn()->selectDatabase($current);
     echo "<ul>\n";
     foreach ($newschema as $table) {
         if (in_array(strtolower($table), $oldschema)) {
             echo "<li>renaming {$table}</li>";
             $db->renameTable(strtolower($table), $table);
             $renamed++;
         }
     }
     echo "</ul>\n";
     echo "<p>{$renamed} tables renamed.</p>\n";
 }
開發者ID:helpfulrobot,項目名稱:lekoala-silverstripe-devtoolkit,代碼行數:33,代碼來源:FixTablesCase.php

示例3: connectDatabase

 function connectDatabase()
 {
     $this->enum_map = array();
     $parameters = $this->parameters;
     $dbName = !isset($this->database) ? $parameters['database'] : ($dbName = $this->database);
     //assumes that the path to dbname will always be provided:
     $file = $parameters['path'] . '/' . $dbName;
     // use the very lightspeed SQLite In-Memory feature for testing
     if (SapphireTest::using_temp_db() && $parameters['memory']) {
         $file = ':memory:';
         $this->lives_in_memory = true;
     } else {
         $this->lives_in_memory = false;
     }
     if (!file_exists($parameters['path'])) {
         SQLiteDatabaseConfigurationHelper::create_db_dir($parameters['path']);
         SQLiteDatabaseConfigurationHelper::secure_db_dir($parameters['path']);
     }
     $this->dbConn = new PDO("sqlite:{$file}");
     //By virtue of getting here, the connection is active:
     $this->active = true;
     $this->database = $dbName;
     if (!$this->dbConn) {
         $this->databaseError("Couldn't connect to SQLite3 database");
         return false;
     }
     foreach (self::$default_pragma as $pragma => $value) {
         $this->pragma($pragma, $value);
     }
     if (empty(self::$default_pragma['locking_mode'])) {
         self::$default_pragma['locking_mode'] = $this->pragma('locking_mode');
     }
     return true;
 }
開發者ID:rodneyway,項目名稱:ss3-misc,代碼行數:34,代碼來源:SQLitePDODatabase.php

示例4: sendFile

 /**
  * Output file to the browser.
  * For performance reasons, we avoid SS_HTTPResponse and just output the contents instead.
  */
 public function sendFile($file)
 {
     $reader = $file->reader();
     if (!$reader || !$reader->isReadable()) {
         return;
     }
     if (class_exists('SapphireTest', false) && SapphireTest::is_running_test()) {
         return $reader->read();
     }
     $type = HTTP::get_mime_type($file->Filename);
     $disposition = strpos($type, 'image') !== false ? 'inline' : 'attachment';
     header('Content-Description: File Transfer');
     // Quotes needed to retain spaces (http://kb.mozillazine.org/Filenames_with_spaces_are_truncated_upon_download)
     header(sprintf('Content-Disposition: %s; filename="%s"', $disposition, basename($file->Filename)));
     header('Content-Length: ' . $file->FileSize);
     header('Content-Type: ' . $type);
     header('Content-Transfer-Encoding: binary');
     // Ensure we enforce no-cache headers consistently, so that files accesses aren't cached by CDN/edge networks
     header('Pragma: no-cache');
     header('Cache-Control: private, no-cache, no-store');
     increase_time_limit_to(0);
     // Clear PHP buffer, otherwise the script will try to allocate memory for entire file.
     while (ob_get_level() > 0) {
         ob_end_flush();
     }
     // Prevent blocking of the session file by PHP. Without this the user can't visit another page of the same
     // website during download (see http://konrness.com/php5/how-to-prevent-blocking-php-requests/)
     session_write_close();
     echo $reader->read();
     die;
 }
開發者ID:stephenmcm,項目名稱:silverstripe-cdncontent,代碼行數:35,代碼來源:CDNSecureFileController.php

示例5: fire

 public function fire()
 {
     SapphireTest::delete_all_temp_dbs();
     $this->deleteAllTempDbs();
     $this->line(" ");
     $this->info("Test databases cleared");
 }
開發者ID:axyr,項目名稱:silverstripe-console,代碼行數:7,代碼來源:ClearTestDatabasesCommand.php

示例6: tearDown

 function tearDown()
 {
     Object::remove_extension("SiteTree", "FilesystemPublisher('../FilesystemPublisherTest-static-folder/')");
     SiteTree::$write_homepage_map = true;
     FilesystemPublisher::$domain_based_caching = $this->orig['domain_based_caching'];
     parent::tearDown();
 }
開發者ID:Raiser,項目名稱:Praktikum,代碼行數:7,代碼來源:FilesystemPublisherTest.php

示例7: setUp

	function setUp() {
		parent::setUp();
		
		// Log in as admin so that we don't run into permission issues.  That's not what we're
		// testing here.
		$this->logInWithPermission('ADMIN');
	}
開發者ID:redema,項目名稱:silverstripe-cms,代碼行數:7,代碼來源:SiteTreeBacklinksTest.php

示例8: setUp

 public function setUp()
 {
     parent::setUp();
     $this->base = dirname(__FILE__) . '/fixtures/classmanifest';
     $this->manifest = new SS_ClassManifest($this->base, false, true, false);
     $this->manifestTests = new SS_ClassManifest($this->base, true, true, false);
 }
開發者ID:ivoba,項目名稱:silverstripe-framework,代碼行數:7,代碼來源:ClassManifestTest.php

示例9: tearDown

 public function tearDown()
 {
     // TODO Remove director rule, currently API doesnt allow this
     // Reinstate the original REQUEST_URI after it was modified by some tests
     $_SERVER['REQUEST_URI'] = self::$originalRequestURI;
     parent::tearDown();
 }
開發者ID:normann,項目名稱:sapphire,代碼行數:7,代碼來源:DirectorTest.php

示例10: setUp

 public function setUp()
 {
     parent::setUp();
     $data = array(array("Course.Title" => "Math 101", "Term" => 1), array("Course.Title" => "Tech 102", "Term" => 1), array("Course.Title" => "Geometry 722", "Term" => 1));
     $this->loader = new BetterBulkLoader("BulkLoaderRelationTest_CourseSelection");
     $this->loader->setSource(new ArrayBulkLoaderSource($data));
 }
開發者ID:helpfulrobot,項目名稱:burnbright-silverstripe-importexport,代碼行數:7,代碼來源:BulkLoaderRelationTest.php

示例11: setUp

 public function setUp()
 {
     parent::setUp();
     Config::inst()->update('Email', 'admin_email', 'shop-admin@example.com');
     $this->order = $this->objFromFixture('Order', 'paid');
     $this->notifier = OrderEmailNotifier::create($this->order);
 }
開發者ID:burnbright,項目名稱:silverstripe-shop,代碼行數:7,代碼來源:OrderNotificationTest.php

示例12: setUp

 public function setUp()
 {
     parent::setUp();
     SocialQueue::queueURL($this->testURL);
     // now setup a statistics for the URL
     foreach ($this->services as $service) {
         $countService = new $service();
         if (is_array($countService->statistic)) {
             foreach ($countService->statistic as $statistic) {
                 $stat = URLStatistics::create();
                 $stat->Service = $countService->service;
                 $stat->Action = $statistic;
                 $stat->Count = 50;
                 $stat->URL = $this->testURL;
                 $stat->write();
             }
         } else {
             $stat = URLStatistics::create();
             $stat->Service = $countService->service;
             $stat->Action = $countService->statistic;
             $stat->Count = 50;
             $stat->URL = $this->testURL;
             $stat->write();
         }
     }
 }
開發者ID:helpfulrobot,項目名稱:marketo-silverstripe-social-proof,代碼行數:26,代碼來源:SocialProofTest.php

示例13: tearDown

 public function tearDown()
 {
     parent::tearDown();
     unset($this->mp3player);
     unset($this->socks);
     unset($this->beachball);
 }
開發者ID:burnbright,項目名稱:silverstripe-shop,代碼行數:7,代碼來源:OrderTest.php

示例14: setUp

 public function setUp()
 {
     parent::setUp();
     // mock the real api
     $this->api = $this->getMock('\\Acquia\\Pingdom\\PingdomApi', ['request'], ["user@test.com", "password", "token"]);
     Injector::inst()->registerService($this->api, 'PingdomService');
 }
開發者ID:silverstripeltd,項目名稱:deploynaut-alerts,代碼行數:7,代碼來源:PingdomGatewayTest.php

示例15: setUpOnce

 function setUpOnce()
 {
     if (class_exists('Comment')) {
         Comment::add_extension('DrupalCommentExtension');
     }
     parent::setUpOnce();
 }
開發者ID:helpfulrobot,項目名稱:chillu-drupal-blog-importer,代碼行數:7,代碼來源:DrupalBlogCommentBulkLoaderTest.php


注:本文中的SapphireTest類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。