Path: blob/master/src/infrastructure/testing/fixture/PhabricatorStorageFixtureScopeGuard.php
12241 views
<?php12/**3* Used by unit tests to build storage fixtures.4*/5final class PhabricatorStorageFixtureScopeGuard extends Phobject {67private $name;89public function __construct($name) {10$this->name = $name;1112execx(13'php %s upgrade --force --namespace %s',14$this->getStorageBinPath(),15$this->name);1617PhabricatorLiskDAO::pushStorageNamespace($name);1819// Destructor is not called with fatal error.20register_shutdown_function(array($this, 'destroy'));21}2223public function destroy() {24PhabricatorLiskDAO::popStorageNamespace();2526// NOTE: We need to close all connections before destroying the databases.27// If we do not, the "DROP DATABASE ..." statements may hang, waiting for28// our connections to close.29PhabricatorLiskDAO::closeAllConnections();3031execx(32'php %s destroy --force --namespace %s',33$this->getStorageBinPath(),34$this->name);35}3637private function getStorageBinPath() {38$root = dirname(phutil_get_library_root('phabricator'));39return $root.'/scripts/sql/manage_storage.php';40}4142}434445