Merge pull request #21057 from eileenmcnaughton/tok_resolve
[civicrm-core.git] / Civi / Test / CiviEnvBuilder / SqlFileStep.php
1 <?php
2 namespace Civi\Test\CiviEnvBuilder;
3
4 class SqlFileStep implements StepInterface {
5 private $file;
6
7 /**
8 * SqlFileStep constructor.
9 * @param string $file
10 */
11 public function __construct($file) {
12 $this->file = $file;
13 }
14
15 public function getSig() {
16 return implode(' ', [
17 $this->file,
18 filemtime($this->file),
19 filectime($this->file),
20 ]);
21 }
22
23 public function isValid() {
24 return is_file($this->file) && is_readable($this->file);
25 }
26
27 public function run($ctx) {
28 /** @var $ctx \CiviEnvBuilder */
29 if (\Civi\Test::execute(@file_get_contents($this->file)) === FALSE) {
30 throw new \RuntimeException("Cannot load {$this->file}. Aborting.");
31 }
32 }
33
34 }