Skip to content

Commit

Permalink
Increased code test coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSkrypnyk committed Nov 4, 2024
1 parent 02b10a1 commit 16bca42
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class ScreenshotContextInitializer implements ContextInitializer {
* File name pattern failed.
* @param bool $needsPurging
* Check if need to actually purge.
*
* @codeCoverageIgnore
*/
public function __construct(protected string $dir, protected bool $fail, private readonly string $failPrefix, protected bool $purge, protected string $filenamePattern, protected string $filenamePatternFailed, protected bool $needsPurging = TRUE) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,12 @@ public function iSaveScreenshot(bool $fail = FALSE, ?string $filename = NULL): v
$fileName = $this->makeFileName('png', $filename, $fail);
$this->saveScreenshotData($fileName, $data);
}
// @codeCoverageIgnoreStart
catch (UnsupportedDriverActionException) {
// Nothing to do here - drivers without support for screenshots
// simply do not have them created.
}
// @codeCoverageIgnoreEnd
}

/**
Expand Down Expand Up @@ -233,6 +235,8 @@ public function getBeforeStepScope(): BeforeStepScope {
*
* @return int
* Current timestamp.
*
* @codeCoverageIgnore
*/
public function getCurrentTime(): int {
return time();
Expand Down Expand Up @@ -303,10 +307,12 @@ protected function makeFileName(string $ext, ?string $filename = NULL, bool $fai
}

if (!empty($url) && !empty(getenv('BEHAT_SCREENSHOT_TOKEN_HOST'))) {
// @codeCoverageIgnoreStart
$host = parse_url($url, PHP_URL_HOST);
if ($host) {
$url = str_replace($host, getenv('BEHAT_SCREENSHOT_TOKEN_HOST'), $url);
}
// @codeCoverageIgnoreEnd
}

$data = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class BehatScreenshotExtension implements ExtensionInterface {

/**
* {@inheritdoc}
*
* @codeCoverageIgnore
*/
public function process(ContainerBuilder $container): void {
}
Expand All @@ -37,6 +39,8 @@ public function getConfigKey(): string {

/**
* {@inheritdoc}
*
* @codeCoverageIgnore
*/
public function initialize(ExtensionManager $extensionManager): void {
}
Expand Down
10 changes: 10 additions & 0 deletions tests/phpunit/Unit/Tokenizer/TokenizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,16 @@ public static function dataProviderReplaceTokens(): array {
$data,
'20240312_045703.foo-fail_foo-file.feature_6_Foo_step_name.png',
],
[
'{url}.{ext}',
$data,
'http%3A%2F%2Fexample.com%2Ffoo%3Ffoo%3Dfoo-value%23hello-fragment.png',
],
[
'{nontoken}.{ext}',
$data,
'{nontoken}.png',
],
];
}

Expand Down

0 comments on commit 16bca42

Please sign in to comment.