本文整理汇总了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;
}
示例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";
}
示例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;
}
示例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;
}
示例5: fire
public function fire()
{
SapphireTest::delete_all_temp_dbs();
$this->deleteAllTempDbs();
$this->line(" ");
$this->info("Test databases cleared");
}
示例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();
}
示例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');
}
示例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);
}
示例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();
}
示例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));
}
示例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);
}
示例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();
}
}
}
示例13: tearDown
public function tearDown()
{
parent::tearDown();
unset($this->mp3player);
unset($this->socks);
unset($this->beachball);
}
示例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');
}
示例15: setUpOnce
function setUpOnce()
{
if (class_exists('Comment')) {
Comment::add_extension('DrupalCommentExtension');
}
parent::setUpOnce();
}