本文整理汇总了PHP中SapphireTest类的典型用法代码示例。如果您正苦于以下问题:PHP SapphireTest类的具体用法?PHP SapphireTest怎么用?PHP SapphireTest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SapphireTest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: sendFile
/**
* Output file to the browser.
* For performance reasons, we avoid SS_HTTPResponse and just output the contents instead.
*/
public function sendFile($file)
{
$path = $file->getFullPath();
if (SapphireTest::is_running_test()) {
return file_get_contents($path);
}
header('Content-Description: File Transfer');
// Quotes needed to retain spaces (http://kb.mozillazine.org/Filenames_with_spaces_are_truncated_upon_download)
header('Content-Disposition: inline; filename="' . basename($path) . '"');
header('Content-Length: ' . $file->getAbsoluteSize());
header('Content-Type: ' . HTTP::get_mime_type($file->getRelativePath()));
header('Content-Transfer-Encoding: binary');
// Fixes IE6,7,8 file downloads over HTTPS bug (http://support.microsoft.com/kb/812935)
header('Pragma: ');
if ($this->config()->min_download_bandwidth) {
// Allow the download to last long enough to allow full download with min_download_bandwidth connection.
increase_time_limit_to((int) (filesize($path) / ($this->config()->min_download_bandwidth * 1024)));
} else {
// Remove the timelimit.
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();
readfile($path);
die;
}
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-commerce-downloadableproduct,代码行数:35,代码来源:DownloadableFileController.php
示例7: validate
/**
* Run through the rules for this validator checking against
* the temporary file set by {@link setTmpFile()} to see if
* the file is deemed valid or not.
*
* @return boolean
*/
public function validate()
{
// we don't validate for empty upload fields yet
if (!isset($this->tmpFile['name']) || empty($this->tmpFile['name'])) {
return true;
}
$isRunningTests = class_exists('SapphireTest', false) && SapphireTest::is_running_test();
//needed to allow XHR uploads
/*if(isset($this->tmpFile['tmp_name']) && !is_uploaded_file($this->tmpFile['tmp_name']) && !$isRunningTests) {
$this->errors[] = _t('File.NOVALIDUPLOAD', 'File is not a valid upload');
return false;
}*/
$pathInfo = pathinfo($this->tmpFile['name']);
// filesize validation
if (!$this->isValidSize()) {
$ext = isset($pathInfo['extension']) ? $pathInfo['extension'] : '';
$arg = File::format_size($this->getAllowedMaxFileSize($ext));
$this->errors[] = sprintf(_t('File.TOOLARGE', 'Filesize is too large, maximum %s allowed.', PR_MEDIUM, 'Argument 1: Filesize (e.g. 1MB)'), $arg);
return false;
}
// extension validation
if (!$this->isValidExtension()) {
$this->errors[] = sprintf(_t('File.INVALIDEXTENSION', 'Extension is not allowed (valid: %s)', PR_MEDIUM, 'Argument 1: Comma-separated list of valid extensions'), wordwrap(implode(', ', $this->allowedExtensions)));
return false;
}
return true;
}
开发者ID:helpfulrobot,项目名称:burnbright-silverstripe-ajaxuploadfield,代码行数:34,代码来源:XHRUpload.php
示例8: 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
示例9: 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
示例10: 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
示例11: 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
示例12: 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
示例13: setUp
public function setUp()
{
parent::setUp();
Config::inst()->update('Email', 'admin_email', '[email protected]');
$this->order = $this->objFromFixture('Order', 'paid');
$this->notifier = OrderEmailNotifier::create($this->order);
}
开发者ID:burnbright,项目名称:silverstripe-shop,代码行数:7,代码来源:OrderNotificationTest.php
示例14: 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
示例15: tearDown
public function tearDown()
{
parent::tearDown();
unset($this->mp3player);
unset($this->socks);
unset($this->beachball);
}
开发者ID:burnbright,项目名称:silverstripe-shop,代码行数:7,代码来源:OrderTest.php
示例16: setUp
public function setUp()
{
parent::setUp();
// mock the real api
$this->api = $this->getMock('\\Acquia\\Pingdom\\PingdomApi', ['request'], ["[email protected]", "password", "token"]);
Injector::inst()->registerService($this->api, 'PingdomService');
}
开发者ID:silverstripeltd,项目名称:deploynaut-alerts,代码行数:7,代码来源:PingdomGatewayTest.php
示例17: setUpOnce
function setUpOnce()
{
if (class_exists('Comment')) {
Comment::add_extension('DrupalCommentExtension');
}
parent::setUpOnce();
}
开发者ID:helpfulrobot,项目名称:chillu-drupal-blog-importer,代码行数:7,代码来源:DrupalBlogCommentBulkLoaderTest.php
示例18: __construct
public function __construct()
{
if (!class_exists('AbstractQueuedJob')) {
$this->skipTest = true;
}
parent::__construct();
}
开发者ID:azt3k,项目名称:advancedworkflow,代码行数:7,代码来源:WorkflowEmbargoExpiryTest.php
示例19: setUp
public function setUp()
{
parent::setUp();
ini_set('display_errors', 1);
ini_set("log_errors", 1);
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
}
开发者ID:helpfulrobot,项目名称:ajshort-silverstripe-addressable,代码行数:7,代码来源:AddressableBuilder.php
示例20: setUp
public function setUp()
{
parent::setUp();
if (!isset($_SERVER['HTTP_HOST'])) {
$_SERVER['HTTP_HOST'] = 'http://localhost';
}
}
开发者ID:helpfulrobot,项目名称:cheesesucker-guestbook,代码行数:7,代码来源:SmileyTest.php
注:本文中的SapphireTest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论