Merge pull request #9302 from systopia/CRM-19639-2
[civicrm-core.git] / Civi / Test / CiviEnvBuilder / SqlFileStep.php
CommitLineData
728bbd5b
TO
1<?php
2namespace Civi\Test\CiviEnvBuilder;
3
4class 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
16 public function getSig() {
17 return implode(' ', array(
18 $this->file,
19 filemtime($this->file),
20 filectime($this->file),
21 ));
22 }
23
24 public function isValid() {
25 return is_file($this->file) && is_readable($this->file);
26 }
27
28 public function run($ctx) {
29 /** @var $ctx \CiviEnvBuilder */
30 if (\Civi\Test::execute(@file_get_contents($this->file)) === FALSE) {
31 throw new \RuntimeException("Cannot load {$this->file}. Aborting.");
32 }
33 }
34
35}