2 namespace Civi\Test\CiviEnvBuilder
;
6 * @package Civi\Test\CiviEnvBuilder
8 * An initialization step which loads the core SQL schema.
10 * Note that the computation of the schema is cached for the duration of
11 * the PHP process (\Civi\Test::$statics).
13 class CoreSchemaStep
implements StepInterface
{
20 public function getSql() {
21 if (!isset(\Civi\Test
::$statics['core_schema_sql'])) {
22 $schema = new \
CRM_Core_CodeGen_Schema(\Civi\Test
::codeGen());
23 $files = $schema->generateCreateSql();
24 \Civi\Test
::$statics['core_schema_sql'] = [
25 'digest' => md5($files['civicrm.mysql']),
26 'content' => $files['civicrm.mysql'],
29 return \Civi\Test
::$statics['core_schema_sql'];
32 public function getSig() {
33 return $this->getSql()['digest'];
36 public function isValid() {
41 * @param \Civi\Test\CiviEnvBuilder $ctx
43 public function run($ctx) {
44 $sql = $this->getSql();
45 if (\Civi\Test
::execute($sql['content']) === FALSE) {
46 throw new \
RuntimeException("Cannot execute SQL");