diff --git a/tests/AbstractTest.php b/tests/AbstractTest.php index fcbc5220..ef3134ad 100644 --- a/tests/AbstractTest.php +++ b/tests/AbstractTest.php @@ -79,4 +79,18 @@ protected function getSandboxRoot() { return __DIR__."/sandbox"; } + + /** + * Generate a random string. + * + * @param int $length + * The desired length. + * + * @return string + * The random string. + */ + protected function generateRandomString($length = 10) + { + return substr(str_shuffle(str_repeat($x = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length/strlen($x)))), 1, $length); + } } diff --git a/tests/CommandsTest.php b/tests/CommandsTest.php index d3948abb..54318a83 100644 --- a/tests/CommandsTest.php +++ b/tests/CommandsTest.php @@ -158,6 +158,31 @@ public function testSettingsSetup(array $config, array $expected) $content = file_get_contents($this->getSandboxFilepath($row['file'])); $this->assertContainsNotContains($content, $row); } + + // Generate a random function name. + $fct = $this->generateRandomString(20); + + // Generate a dummy PHP code. + $config_override_dummy_script = <<< EOF +getSandboxRoot() . '/build/sites/' . $sites_subdir . '/' . $config_override_filename, + $config_override_dummy_script + ); + + // Include the config override file. + include_once $this->getSandboxRoot() . '/build/sites/' . $sites_subdir . '/' . $config_override_filename; + + // Test if the dummy PHP code has been properly included. + $this->assertTrue(\function_exists($fct)); } /** @@ -184,6 +209,31 @@ public function testSettingsSetupForce(array $config, array $expected) $content = file_get_contents($this->getSandboxFilepath($row['file'])); $this->assertContainsNotContains($content, $row); } + + // Generate a random function name. + $fct = $this->generateRandomString(20); + + // Generate a dummy PHP code. + $config_override_dummy_script = <<< EOF +getSandboxRoot() . '/build/sites/' . $sites_subdir . '/' . $config_override_filename, + $config_override_dummy_script + ); + + // Include the config override file. + include_once $this->getSandboxRoot() . '/build/sites/' . $sites_subdir . '/' . $config_override_filename; + + // Test if the dummy PHP code has been properly included. + $this->assertTrue(\function_exists($fct)); } /**