/**
  * @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;
 }
 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";
 }
Exemplo n.º 3
0
 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();
 }
	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');
	}
 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);
 }
Exemplo n.º 6
0
 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();
 }
Exemplo n.º 7
0
 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;
 }
 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));
 }
 public function setUp()
 {
     parent::setUp();
     Config::inst()->update('Email', 'admin_email', '*****@*****.**');
     $this->order = $this->objFromFixture('Order', 'paid');
     $this->notifier = OrderEmailNotifier::create($this->order);
 }
 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();
         }
     }
 }
 /**
  * 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;
 }
Exemplo n.º 12
0
 public function tearDown()
 {
     parent::tearDown();
     unset($this->mp3player);
     unset($this->socks);
     unset($this->beachball);
 }
 public function setUp()
 {
     parent::setUp();
     // mock the real api
     $this->api = $this->getMock('\\Acquia\\Pingdom\\PingdomApi', ['request'], ["*****@*****.**", "password", "token"]);
     Injector::inst()->registerService($this->api, 'PingdomService');
 }
 function setUpOnce()
 {
     if (class_exists('Comment')) {
         Comment::add_extension('DrupalCommentExtension');
     }
     parent::setUpOnce();
 }
 public function __construct()
 {
     if (!class_exists('AbstractQueuedJob')) {
         $this->skipTest = true;
     }
     parent::__construct();
 }
 public function setUp()
 {
     parent::setUp();
     ini_set('display_errors', 1);
     ini_set("log_errors", 1);
     error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
 }
 public function fire()
 {
     SapphireTest::delete_all_temp_dbs();
     $this->deleteAllTempDbs();
     $this->line(" ");
     $this->info("Test databases cleared");
 }
 public function setUp()
 {
     parent::setUp();
     if (!isset($_SERVER['HTTP_HOST'])) {
         $_SERVER['HTTP_HOST'] = 'http://localhost';
     }
 }
Exemplo n.º 19
0
 public function tearDown()
 {
     if ($this->origBackend) {
         Image::set_backend($this->origBackend);
     }
     // Remove the test files that we've created
     $fileIDs = $this->allFixtureIDs('Image');
     foreach ($fileIDs as $fileID) {
         $file = DataObject::get_by_id('Image', $fileID);
         if ($file && file_exists(BASE_PATH . "/{$file->Filename}")) {
             unlink(BASE_PATH . "/{$file->Filename}");
         }
     }
     // Remove the test folders that we've created
     $folderIDs = $this->allFixtureIDs('Folder');
     foreach ($folderIDs as $folderID) {
         $folder = DataObject::get_by_id('Folder', $folderID);
         if ($folder && file_exists(BASE_PATH . "/{$folder->Filename}")) {
             Filesystem::removeFolder(BASE_PATH . "/{$folder->Filename}");
         }
         if ($folder && file_exists(BASE_PATH . "/" . $folder->Filename . "_resampled")) {
             Filesystem::removeFolder(BASE_PATH . "/" . $folder->Filename . "_resampled");
         }
     }
     parent::tearDown();
 }
 public function tearDown()
 {
     AssetStoreTest_SpyStore::reset();
     SS_Filesystem::removeFolder($this->getBasePath());
     parent::tearDown();
     Config::unnest();
 }
 public function tearDown()
 {
     parent::tearDown();
     i18n::set_locale($this->originalLocale);
     Config::inst()->remove('TimeField', 'default_config');
     Config::inst()->update('TimeField', 'default_config', $this->origTimeConfig);
 }
Exemplo n.º 22
0
	public function setUp() {
		parent::setUp();
		$this->list = new DataList('GridFieldAction_Delete_Team');
		$config = GridFieldConfig::create()->addComponent(new GridFieldDeleteAction());
		$this->gridField = new GridField('testfield', 'testfield', $this->list, $config);
		$this->form = new Form(new Controller(), 'mockform', new FieldList(array($this->gridField)), new FieldList());
	}
Exemplo n.º 23
0
 public function tearDown()
 {
     parent::tearDown();
     i18n::set_locale($this->originalLocale);
     DateField::$default_config['dateformat'] = $this->origDateFormat;
     TimeField::$default_config['timeformat'] = $this->origTimeFormat;
 }
 public function setUp()
 {
     parent::setUp();
     $this->ball = $this->objFromFixture("Product", "ball");
     $this->mp3player = $this->objFromFixture("Product", "mp3player");
     $this->redlarge = $this->objFromFixture("ProductVariation", "redlarge");
 }
 /**
  * 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;
 }
 public function setUp()
 {
     parent::setUp();
     ShopTest::setConfiguration();
     $this->cart = $this->objFromFixture("Order", "cart");
     $this->othercart = $this->objFromFixture("Order", "othercart");
 }
 public function setUp()
 {
     parent::setUp();
     if (!class_exists('FileSystemContentSource')) {
         throw new Exception("You must have the filesystem connector installed to use for testing");
     }
 }
Exemplo n.º 28
0
	public function setUp() {
		parent::setUp();

		$this->list = new DataList('GridFieldExportButtonTest_Team');
		$config = GridFieldConfig::create()->addComponent(new GridFieldExportButton());
		$this->gridField = new GridField('testfield', 'testfield', $this->list, $config);
	}
 public function tearDown()
 {
     $_SERVER['HTTP_HOST'] = $this->oldhost;
     Config::unnest();
     Email::set_mailer(new Mailer());
     parent::tearDown();
 }
 /**
  * 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;
 }