Skip to content

Commit 248bc8a

Browse files
committed
BootCommand - Add support for --level=cms-full
1 parent 72b38d1 commit 248bc8a

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

bin/cv

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ $autoloaders = array(
1818
foreach ($autoloaders as $autoloader) {
1919
if (file_exists($autoloader)) {
2020
require_once $autoloader;
21+
define('CV_AUTOLOAD', $autoloader);
2122
$found = 1;
2223
break;
2324
}

src/Command/BootCommand.php

+10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
namespace Civi\Cv\Command;
33

4+
use Civi\Cv\CmsBootstrap;
45
use Civi\Cv\Util\BootTrait;
56
use Symfony\Component\Console\Input\InputInterface;
67
use Symfony\Component\Console\Output\OutputInterface;
@@ -36,6 +37,15 @@ protected function execute(InputInterface $input, OutputInterface $output) {
3637
. '\CRM_Utils_System::loadBootStrap(array(), FALSE);';
3738
break;
3839

40+
case 'cms-full':
41+
$instance = \Civi\Cv\CmsBootstrap::singleton();
42+
$instanceExpr = '\\' . get_class($instance) . '::singleton()';
43+
$code = '';
44+
$code .= sprintf("require_once %s;\n", var_export(CV_AUTOLOAD, TRUE));
45+
$code .= sprintf("%s->addOptions(%s);\n", $instanceExpr, var_export($instance->getOptions(), TRUE));
46+
$code .= sprintf("%s->bootCms()->bootCivi();\n", $instanceExpr);
47+
break;
48+
3949
case 'none':
4050
break;
4151

tests/Command/BootCommandTest.php

+14-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ public function setUp(): void {
1313
parent::setUp();
1414
}
1515

16-
public function testBootDefault() {
17-
$phpBoot = Process::runOk($this->cv("php:boot"));
16+
public function testBootFull() {
17+
$phpBoot = Process::runOk($this->cv("php:boot --level=full"));
1818
$this->assertRegExp(';CIVICRM_SETTINGS_PATH;', $phpBoot->getOutput());
1919

2020
$helloPhp = escapeshellarg($phpBoot->getOutput()
@@ -24,6 +24,18 @@ public function testBootDefault() {
2424
$this->assertRegExp('/^count is [0-9]+$/', $phpRun->getOutput());
2525
}
2626

27+
public function testBootCmsFull() {
28+
$phpBoot = Process::runOk($this->cv("php:boot --level=cms-full"));
29+
$this->assertRegExp(';BEGINPHP;', $phpBoot->getOutput());
30+
$this->assertRegExp(';ENDPHP;', $phpBoot->getOutput());
31+
32+
$helloPhp = escapeshellarg($phpBoot->getOutput()
33+
. 'printf("count is %s\n", CRM_Core_DAO::singleValueQuery("select count(*) from civicrm_contact"));'
34+
);
35+
$phpRun = Process::runOk(new \Symfony\Component\Process\Process("php -r $helloPhp"));
36+
$this->assertRegExp('/^count is [0-9]+$/', $phpRun->getOutput());
37+
}
38+
2739
public function testBootClassLoader() {
2840
$phpBoot = Process::runOk($this->cv("php:boot --level=classloader"));
2941
$this->assertRegExp(';ClassLoader;', $phpBoot->getOutput());

0 commit comments

Comments
 (0)