-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/9.x' of github.com:ec-europa/toolkit into relea…
…se/10.x
- Loading branch information
Showing
51 changed files
with
314 additions
and
73,209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
toolkit: | ||
project_id: toolkit | ||
tmp_folder: '/cache' | ||
clean: | ||
config_file: 'config/sync/core.extension.yml' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace EcEuropa\Toolkit; | ||
|
||
use Symfony\Component\Process\Process; | ||
|
||
/** | ||
* Toolkit mock class. | ||
*/ | ||
final class Mock | ||
{ | ||
|
||
/** | ||
* Downloads the mock from the repo. | ||
* | ||
* @throws \Exception | ||
* If missing env var TOOLKIT_MOCK_REPO. | ||
*/ | ||
public static function download(): bool | ||
{ | ||
if (!Toolkit::isCiCd()) { | ||
return false; | ||
} | ||
$mockDir = getenv('TOOLKIT_MOCK_DIR') ?: 'mock'; | ||
if (file_exists($mockDir)) { | ||
return true; | ||
} | ||
if (empty($repo = getenv('TOOLKIT_MOCK_REPO'))) { | ||
throw new \Exception('Missing env var TOOLKIT_MOCK_REPO.'); | ||
} | ||
$branch = getenv('TOOLKIT_MOCK_BRANCH') ?: '0.0.2'; | ||
$command = "git clone --depth 1 --branch $branch $repo $mockDir"; | ||
$process = Process::fromShellCommandline($command); | ||
$process->run(); | ||
if ($process->getExitCode()) { | ||
throw new \Exception($process->getErrorOutput()); | ||
} | ||
return file_exists($mockDir); | ||
} | ||
|
||
/** | ||
* Returns the content of the endpoint from the mock. | ||
* | ||
* @param string $endpoint | ||
* The endpoint to return the content from. | ||
* | ||
* @throws \Exception | ||
* If the mock or endpoint file is not found. | ||
*/ | ||
public static function getEndpointContent(string $endpoint) | ||
{ | ||
if (!Toolkit::isCiCd()) { | ||
return false; | ||
} | ||
$mockDir = getenv('TOOLKIT_MOCK_DIR') ?: 'mock'; | ||
if (!file_exists($mockDir)) { | ||
throw new \Exception("Mock not found at '$mockDir'."); | ||
} | ||
$endpointFile = "$mockDir/$endpoint.json"; | ||
if (!file_exists($endpointFile)) { | ||
throw new \Exception("No file found for endpoint '$endpoint'."); | ||
} | ||
return file_get_contents($endpointFile); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.