First commit
This commit is contained in:
commit
c6e2478c40
13918 changed files with 2303184 additions and 0 deletions
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
namespace Civi\Test\CiviEnvBuilder;
|
||||
class CallbackStep implements StepInterface {
|
||||
private $callback;
|
||||
private $sig;
|
||||
|
||||
/**
|
||||
* CallbackStep constructor.
|
||||
* @param $callback
|
||||
* @param $sig
|
||||
*/
|
||||
public function __construct($callback, $sig = NULL) {
|
||||
$this->callback = $callback;
|
||||
$this->sig = $sig === NULL ? md5(var_export($callback, 1)) : $sig;
|
||||
}
|
||||
|
||||
public function getSig() {
|
||||
return $this->sig;
|
||||
}
|
||||
|
||||
public function isValid() {
|
||||
return is_callable($this->callback);
|
||||
}
|
||||
|
||||
public function run($ctx) {
|
||||
call_user_func($this->callback, $ctx);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
namespace Civi\Test\CiviEnvBuilder;
|
||||
class ExtensionsStep implements StepInterface {
|
||||
private $action;
|
||||
private $names;
|
||||
|
||||
/**
|
||||
* ExtensionStep constructor.
|
||||
* @param string $action
|
||||
* Ex: 'install', 'uninstall'.
|
||||
* @param string|array $names
|
||||
*/
|
||||
public function __construct($action, $names) {
|
||||
$this->action = $action;
|
||||
$this->names = (array) $names;
|
||||
}
|
||||
|
||||
public function getSig() {
|
||||
return 'ext:' . implode(',', $this->names);
|
||||
}
|
||||
|
||||
public function isValid() {
|
||||
if (!in_array($this->action, array('install', 'uninstall'))) {
|
||||
return FALSE;
|
||||
}
|
||||
foreach ($this->names as $name) {
|
||||
if (!is_string($name)) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public function run($ctx) {
|
||||
$allKeys = \CRM_Extension_System::singleton()->getFullContainer()->getKeys();
|
||||
$names = \CRM_Utils_String::filterByWildcards($this->names, $allKeys, TRUE);
|
||||
|
||||
$manager = \CRM_Extension_System::singleton()->getManager();
|
||||
switch ($this->action) {
|
||||
case 'install':
|
||||
$manager->install($names);
|
||||
break;
|
||||
|
||||
case 'uninstall':
|
||||
$manager->disable($names);
|
||||
$manager->uninstall($names);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
namespace Civi\Test\CiviEnvBuilder;
|
||||
|
||||
class SqlFileStep implements StepInterface {
|
||||
private $file;
|
||||
|
||||
/**
|
||||
* SqlFileStep constructor.
|
||||
* @param string $file
|
||||
*/
|
||||
public function __construct($file) {
|
||||
$this->file = $file;
|
||||
}
|
||||
|
||||
|
||||
public function getSig() {
|
||||
return implode(' ', array(
|
||||
$this->file,
|
||||
filemtime($this->file),
|
||||
filectime($this->file),
|
||||
));
|
||||
}
|
||||
|
||||
public function isValid() {
|
||||
return is_file($this->file) && is_readable($this->file);
|
||||
}
|
||||
|
||||
public function run($ctx) {
|
||||
/** @var $ctx \CiviEnvBuilder */
|
||||
if (\Civi\Test::execute(@file_get_contents($this->file)) === FALSE) {
|
||||
throw new \RuntimeException("Cannot load {$this->file}. Aborting.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
namespace Civi\Test\CiviEnvBuilder;
|
||||
class SqlStep implements StepInterface {
|
||||
private $sql;
|
||||
|
||||
/**
|
||||
* SqlFileStep constructor.
|
||||
* @param string $sql
|
||||
*/
|
||||
public function __construct($sql) {
|
||||
$this->sql = $sql;
|
||||
}
|
||||
|
||||
|
||||
public function getSig() {
|
||||
return md5($this->sql);
|
||||
}
|
||||
|
||||
public function isValid() {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public function run($ctx) {
|
||||
/** @var $ctx \CiviEnvBuilder */
|
||||
if (\Civi\Test::execute($this->sql) === FALSE) {
|
||||
throw new \RuntimeException("Cannot execute: {$this->sql}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
namespace Civi\Test\CiviEnvBuilder;
|
||||
|
||||
interface StepInterface {
|
||||
public function getSig();
|
||||
|
||||
public function isValid();
|
||||
|
||||
public function run($ctx);
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue