示例#1
0
 /**
  * Test recursive copying of directories
  *
  *
  */
 public function testRCopy()
 {
     $name = $this->_get_rand_name();
     $source_dir = dirname(dirname(__FILE__)) . '/model/samples/repo1';
     $target_dir = MODX_CORE_PATH . 'cache/repoman/' . $name;
     Repoman::rcopy($source_dir, $target_dir, array());
     $this->assertTrue(file_exists($target_dir . '/elements') && is_dir($target_dir . '/elements'), 'elements directory must exist');
     $this->assertTrue(file_exists($target_dir . '/elements/plugins') && is_dir($target_dir . '/elements/plugins'), 'elements/plugins directory must exist');
     $this->assertTrue(file_exists($target_dir . '/elements/snippets') && is_dir($target_dir . '/elements/snippets'), 'elements/snippets directory must exist');
     $this->assertTrue(file_exists($target_dir . '/elements/templates') && is_dir($target_dir . '/elements/templates'), 'elements/templates directory must exist');
     $this->assertTrue(file_exists($target_dir . '/elements/tvs') && is_dir($target_dir . '/elements/tvs'), 'elements/tvs directory must exist');
     $this->assertTrue(file_exists($target_dir . '/elements/chunks/MyChunk.html'), 'elements/chunks/MyChunk.html file must exist');
     $this->assertTrue(file_exists($target_dir . '/elements/plugins/MyPlugin.php'), 'elements/plugins/MyPlugin.php file must exist');
     $this->assertTrue(file_exists($target_dir . '/elements/snippets/MySnippet.php'), 'elements/snippets/MySnippet.php file must exist');
     $this->assertTrue(file_exists($target_dir . '/elements/templates/MyTemplate.html'), 'elements/templates/MyTemplate.html file must exist');
     $this->assertTrue(file_exists($target_dir . '/elements/tvs/myTV.php'), 'elements/tvs/myTV.php file must exist');
     Repoman::rrmdir($target_dir);
 }
示例#2
0
 /**
  * Attempts to uninstall the default namespace, system settings, modx objects,
  * and any database migrations. The behavior is dependent on the MODX cache b/c
  * all new objects are registered in the repoman custom cache partition.
  *
  * No input parameters are required: this looks at the "namespace" config setting.
  *
  * php repoman.php uninstall --namespace=something
  */
 public function uninstall($pkg_root_dir)
 {
     $pkg_root_dir = self::get_dir($pkg_root_dir);
     // uninstall migrations. Global $modx and $object variables
     $this->migrate($pkg_root_dir, 'uninstall');
     // Remove installed objects
     $cache_dir = MODX_CORE_PATH . 'cache/repoman/' . $this->get('namespace');
     if (file_exists($cache_dir) && is_dir($cache_dir)) {
         $obj_dirs = array_diff(scandir($cache_dir), array('..', '.'));
         foreach ($obj_dirs as $objectname_dir) {
             if (!is_dir($cache_dir . '/' . $objectname_dir)) {
                 continue;
                 // wtf? Did you manually edit the cache dirs?
             }
             $objects = array_diff(scandir($cache_dir . '/' . $objectname_dir), array('..', '.'));
             $objecttype = basename($objectname_dir);
             foreach ($objects as $o) {
                 $criteria = (include $cache_dir . '/' . $objectname_dir . '/' . $o);
                 $Obj = $this->modx->getObject($objecttype, $criteria);
                 if ($Obj) {
                     $Obj->remove();
                 } else {
                     // Some objects are removed b/c of relations before we get to them
                     $this->modx->log(modX::LOG_LEVEL_DEBUG, $objecttype . ' could not be located ' . print_r($criteria, true));
                 }
             }
         }
         Repoman::rrmdir($cache_dir);
     } else {
         $this->modx->log(modX::LOG_LEVEL_WARN, 'No cached import data at ' . $cache_dir);
     }
     $this->tidy_modx();
 }