当前位置: 首页>>代码示例>>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;未经允许,请勿转载。