diff --git a/composer.json b/composer.json index f81c60092..a91c12013 100644 --- a/composer.json +++ b/composer.json @@ -36,7 +36,8 @@ "rector/rector": "2.1.4", "sebastian/diff": "^4.0", "symfony/polyfill-php84": "^1.31", - "symfony/process": "^5.4 || ^6.4 || ^7.0" + "symfony/process": "^5.4 || ^6.4 || ^7.0", + "symfony/filesystem": "^5.4 || ^6.4 || ^7.0" }, "suggest": { diff --git a/features/bootstrap/FeatureContext.php b/features/bootstrap/FeatureContext.php index ec6d01762..d9b8ead53 100644 --- a/features/bootstrap/FeatureContext.php +++ b/features/bootstrap/FeatureContext.php @@ -17,6 +17,7 @@ use PHPUnit\Framework\Assert; use SebastianBergmann\Diff\Differ; use SebastianBergmann\Diff\Output\DiffOnlyOutputBuilder; +use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Process\PhpExecutableFinder; use Symfony\Component\Process\Process; @@ -39,10 +40,7 @@ class FeatureContext implements Context * @var string */ private $workingDir; - /** - * @var string - */ - private $tempDir; + /** * @var string */ @@ -56,7 +54,10 @@ class FeatureContext implements Context */ private $answerString; - private bool $workingDirChanged = false; + public function __construct( + private readonly Filesystem $filesystem = new Filesystem(), + ) { + } /** * Cleans test folders in the temporary directory. @@ -67,9 +68,7 @@ class FeatureContext implements Context */ public static function cleanTestFolders() { - if (is_dir($dir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'behat')) { - self::clearDirectory($dir); - } + (new Filesystem())->remove(sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'behat'); } /** @@ -82,14 +81,13 @@ public function prepareTestFolders() $dir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'behat' . DIRECTORY_SEPARATOR . md5(microtime() . rand(0, 10000)); - mkdir($dir . '/features/bootstrap/i18n', 0777, true); + $this->filesystem->mkdir($dir); $phpFinder = new PhpExecutableFinder(); if (false === $php = $phpFinder->find()) { throw new RuntimeException('Unable to find the PHP executable.'); } $this->workingDir = $dir; - $this->tempDir = $dir; $this->phpBin = $php; } @@ -104,7 +102,7 @@ public function prepareTestFolders() public function aFileNamedWith($filename, PyStringNode $content) { $content = strtr((string) $content, ["'''" => '"""']); - $this->createFile($this->workingDir . '/' . $filename, $content); + $this->createFileInWorkingDir($filename, $content); } /** @@ -116,7 +114,7 @@ public function aFileNamedWith($filename, PyStringNode $content) */ public function aFileNamed($filename) { - $this->createFile($this->workingDir . '/' . $filename, ''); + $this->createFileInWorkingDir($filename, ''); } /** @@ -136,7 +134,7 @@ class FeatureContext implements Context { } EOL; - $this->createFile($this->workingDir . '/' . $filename, $content); + $this->createFileInWorkingDir($filename, $content); } /** @@ -152,7 +150,7 @@ public function aNoopFeature() Scenario: When this scenario executes EOL; - $this->createFile($this->workingDir . '/' . $filename, $content); + $this->createFileInWorkingDir($filename, $content); } /** @@ -199,9 +197,7 @@ public function iSetBehatParamsEnvironmentVariable(PyStringNode $value) $this->env = ['BEHAT_PARAMS' => (string) $value]; } - /** - * @When I set the working directory to the :dir fixtures folder - */ + #[When('I initialise the working directory from the :dir fixtures folder')] public function iSetTheWorkingDirectoryToTheFixturesFolder($dir): void { $basePath = dirname(__DIR__, 2) . '/tests/Fixtures/'; @@ -209,8 +205,7 @@ public function iSetTheWorkingDirectoryToTheFixturesFolder($dir): void if (!is_dir($dir)) { throw new RuntimeException(sprintf('The directory "%s" does not exist', $dir)); } - $this->workingDir = $dir; - $this->workingDirChanged = true; + $this->filesystem->mirror($dir, $this->workingDir); } #[Given('I clear the default behat options')] @@ -371,6 +366,21 @@ public function fileShouldContain($path, PyStringNode $text) Assert::assertEquals($this->getExpectedOutput($text), $fileContent); } + #[Then(':path file should contain exactly:')] + public function fileShouldContainExactly(string $path, PyStringNode $text): void + { + $path = $this->workingDir.'/'.$path; + Assert::assertFileExists($path); + + $fileContent = trim(file_get_contents($path)); + // Normalize the line endings in the output + if ("\n" !== PHP_EOL) { + $fileContent = str_replace(PHP_EOL, "\n", $fileContent); + } + + Assert::assertEquals($text, $fileContent); + } + /** * Checks whether specified content and structure of the xml is correct without worrying about layout. * @@ -385,41 +395,13 @@ public function fileXmlShouldBeLike($path, PyStringNode $text) $this->checkXmlFileContents($path, $text); } - #[When('I copy the :file file to the temp folder')] - public function iCopyTheFileToTheTempFolder($file): void - { - $origin = $this->workingDir . '/' . $file; - $destination = $this->tempDir . '/' . $file; - copy($origin, $destination); - } - - #[Then('the temp :file file should be like:')] - public function theTempFileShouldBeLike($file, PyStringNode $string): void - { - $path = $this->tempDir . '/' . $file; - Assert::assertFileExists($path); - - $fileContent = trim(file_get_contents($path)); - - Assert::assertSame($string->getRaw(), $fileContent); - } - - #[Then('the temp :file file should have been removed')] - public function theTempFileShouldHaveBeenRemoved($file): void + #[Then('the :file file should have been removed from the working directory')] + public function fileShouldHaveBeenRemoved($file): void { - $path = $this->tempDir . '/' . $file; + $path = $this->workingDir . '/' . $file; Assert::assertFileDoesNotExist($path); } - /** - * @Then the temp :path file xml should be like: - */ - public function theTempFileFileXmlShouldBeLike($path, PyStringNode $text): void - { - $path = $this->tempDir . '/' . $path; - $this->checkXmlFileContents($path, $text); - } - private function checkXmlFileContents($path, PyStringNode $text) { Assert::assertFileExists($path); @@ -554,15 +536,6 @@ public function xmlShouldBeValid($xmlFile, $schemaPath) $this->checkXmlIsValid($path, $schemaPath); } - /** - * @Then the temp file :xmlFile should be a valid document according to :schemaPath - */ - public function theTempFileShouldBeAValidDocumentAccordingTo($xmlFile, $schemaPath): void - { - $path = $this->tempDir . '/' . $xmlFile; - $this->checkXmlIsValid($path, $schemaPath); - } - private function checkXmlIsValid(string $xmlFile, string $schemaPath): void { $dom = new DOMDocument(); @@ -602,30 +575,15 @@ private function getOutput(): string return trim(preg_replace('/ +$/m', '', $output)); } - private function createFile($filename, $content) + private function createFileInWorkingDir(string $filename, string $content): void { - if ($this->workingDirChanged) { - throw new RuntimeException('Trying to write a file in a fixtures folder'); - } - $path = dirname($filename); - $this->createDirectory($path); - - file_put_contents($filename, $content); - } - - private function createDirectory($path) - { - if (!is_dir($path)) { - mkdir($path, 0777, true); - } + $this->filesystem->dumpFile($this->workingDir . DIRECTORY_SEPARATOR . $filename, $content); } private function moveToNewPath($path) { $newWorkingDir = $this->workingDir . '/' . $path; - if (!file_exists($newWorkingDir)) { - mkdir($newWorkingDir, 0777, true); - } + $this->filesystem->mkdir($newWorkingDir); $this->workingDir = $newWorkingDir; } @@ -648,22 +606,6 @@ private function getOutputDiff(PyStringNode $expectedText): string return $differ->diff($this->getExpectedOutput($expectedText), $this->getOutput()); } - private static function clearDirectory($path) - { - $files = scandir($path); - array_shift($files); - array_shift($files); - - foreach ($files as $file) { - $file = $path . DIRECTORY_SEPARATOR . $file; - if (is_dir($file)) { - self::clearDirectory($file); - } else { - unlink($file); - } - } - } - private function addBehatOptions(TableNode $table): void { $rows = $table->getHash(); @@ -671,11 +613,8 @@ private function addBehatOptions(TableNode $table): void $option = $row['option']; $value = $row['value']; if ($value !== '') { - if (str_starts_with($value, '{SYSTEM_TMP_DIR}')) { - $value = $this->tempDir . substr($value, strlen('{SYSTEM_TMP_DIR}')); - } if (str_starts_with($value, '{BASE_PATH}')) { - $basePath = realpath(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR; + $basePath = realpath($this->workingDir) . DIRECTORY_SEPARATOR; $value = $basePath . substr($value, strlen('{BASE_PATH}')); } diff --git a/features/config_strict_testers.feature b/features/config_strict_testers.feature index 32f2f3b63..18e84a57c 100644 --- a/features/config_strict_testers.feature +++ b/features/config_strict_testers.feature @@ -4,7 +4,7 @@ Feature: Strict result interpretation defined in configuration file I need to be able to configure "strict" option in the configuration file Background: - Given I set the working directory to the "ConfigStrictTesters" fixtures folder + Given I initialise the working directory from the "ConfigStrictTesters" fixtures folder And I provide the following options for all behat invocations: | option | value | | --no-colors | | diff --git a/features/convert_config.feature b/features/convert_config.feature index 169355295..4cd060927 100644 --- a/features/convert_config.feature +++ b/features/convert_config.feature @@ -4,7 +4,7 @@ Feature: Convert config I need to be able to convert this configuration to the new PHP format Background: - Given I set the working directory to the "ConvertConfig" fixtures folder + Given I initialise the working directory from the "ConvertConfig" fixtures folder And I clear the default behat options And I provide the following options for all behat invocations: | option | value | @@ -12,11 +12,11 @@ Feature: Convert config | --convert-config | | Scenario: Convert empty file - When I copy the "empty.yaml" file to the temp folder When I run behat with the following additional options: - | option | value | - | --config | {SYSTEM_TMP_DIR}/empty.yaml | - Then the temp "empty.php" file should be like: + | option | value | + | --config | empty.yaml | + Then it should pass + And "empty.php" file should contain: """ withProfile(new Profile('default')) ->withProfile(new Profile('another')); """ - And the temp "profiles.yaml" file should have been removed + And the "profiles.yaml" file should have been removed from the working directory Scenario: Preferred profile - When I copy the "preferred_profile.yaml" file to the temp folder When I run behat with the following additional options: - | option | value | - | --config | {SYSTEM_TMP_DIR}/preferred_profile.yaml | - Then the temp "preferred_profile.php" file should be like: + | option | value | + | --config | preferred_profile.yaml | + Then it should pass + And "preferred_profile.php" file should contain: """ disableFormatter('pretty')) ->withPreferredProfile('another'); """ - And the temp "preferred_profile.yaml" file should have been removed + And the "preferred_profile.yaml" file should have been removed from the working directory Scenario: Imports - When I copy the "imports.yaml" file to the temp folder - And I copy the "imported.yaml" file to the temp folder When I run behat with the following additional options: - | option | value | - | --config | {SYSTEM_TMP_DIR}/imports.yaml | - Then the temp "imports.php" file should be like: + | option | value | + | --config | imports.yaml | + Then it should pass + And "imports.php" file should contain: """ import('imported.php') ->withProfile(new Profile('default')); """ - And the temp "imported.php" file should be like: + And "imported.php" file should contain: """ withProfile(new Profile('another')); """ - And the temp "imports.yaml" file should have been removed - And the temp "imported.yaml" file should have been removed + And the "imports.yaml" file should have been removed from the working directory + And the "imported.yaml" file should have been removed from the working directory Scenario: Multiple Imports - When I copy the "multiple_imports.yaml" file to the temp folder - And I copy the "imported.yaml" file to the temp folder - And I copy the "other_imported.yaml" file to the temp folder When I run behat with the following additional options: - | option | value | - | --config | {SYSTEM_TMP_DIR}/multiple_imports.yaml | - Then the temp "multiple_imports.php" file should be like: + | option | value | + | --config | multiple_imports.yaml | + Then it should pass with: + """ + Starting conversion + Converting configuration file: multiple_imports.yaml + Converting configuration file: .%%DS%%imported.yaml + Converting configuration file: .%%DS%%other_imported.yaml + Conversion finished + """ + And "multiple_imports.php" file should contain: """ withProfile(new Profile('default')); - """ - And the temp "imported.php" file should be like: + """ + And "imported.php" file should contain: """ withProfile(new Profile('another')); """ - And the temp "other_imported.php" file should be like: + And "other_imported.php" file should contain: """ withProfile(new Profile('other')); """ - And the temp "imports.yaml" file should have been removed - And the temp "imported.yaml" file should have been removed - And the temp "other_imported.yaml" file should have been removed + And the "multiple_imports.yaml" file should have been removed from the working directory + And the "imported.yaml" file should have been removed from the working directory + And the "other_imported.yaml" file should have been removed from the working directory Scenario: Suites - When I copy the "suites.yaml" file to the temp folder When I run behat with the following additional options: - | option | value | - | --config | {SYSTEM_TMP_DIR}/suites.yaml | - Then the temp "suites.php" file should be like: + | option | value | + | --config | suites.yaml | + Then it should pass + And "suites.php" file should contain: """ withSuite(new Suite('one_suite')) ->withSuite(new Suite('another_suite'))); """ - And the temp "suites.yaml" file should have been removed + And the "suites.yaml" file should have been removed from the working directory Scenario: Suite contexts - When I copy the "suite_contexts.yaml" file to the temp folder When I run behat with the following additional options: - | option | value | - | --config | {SYSTEM_TMP_DIR}/suite_contexts.yaml | - Then the temp "suite_contexts.php" file should be like: + | option | value | + | --config | suite_contexts.yaml | + Then it should pass + And "suite_contexts.php" file should contain: """ addContext('AnotherContext'))); """ - And the temp "suite_contexts.yaml" file should have been removed + And the "suite_contexts_with_args.yaml" file should have been removed from the working directory Scenario: Suite paths - When I copy the "suite_paths.yaml" file to the temp folder When I run behat with the following additional options: - | option | value | - | --config | {SYSTEM_TMP_DIR}/suite_paths.yaml | - Then the temp "suite_paths.php" file should be like: + | option | value | + | --config | suite_paths.yaml | + Then it should pass + And "suite_paths.php" file should contain: """ withSuite((new Suite('my_suite')) ->withFilter(new TagFilter('@run')))); """ - And the temp "suite_filters.yaml" file should have been removed + And the "suite_filters.yaml" file should have been removed from the working directory Scenario: Extensions - When I copy the "extensions.yaml" file to the temp folder When I run behat with the following additional options: - | option | value | - | --config | {SYSTEM_TMP_DIR}/extensions.yaml | - Then the temp "extensions.php" file should be like: + | option | value | + | --config | extensions.yaml | + Then it should pass + And "extensions.php" file should contain: """ addContext(MySecondContext::class))); """ - And the temp "class_references.yaml" file should have been removed + And the "class_references.yaml" file should have been removed from the working directory Scenario: Profile filters - When I copy the "profile_filters.yaml" file to the temp folder When I run behat with the following additional options: - | option | value | - | --config | {SYSTEM_TMP_DIR}/profile_filters.yaml | - Then the temp "profile_filters.php" file should be like: + | option | value | + | --config | profile_filters.yaml | + Then it should pass + And "profile_filters.php" file should contain: """ withFilter(new NameFilter('john')) ->withFilter(new RoleFilter('admin'))); """ - And the temp "profile_filters.yaml" file should have been removed + And the "profile_filters.yaml" file should have been removed from the working directory Scenario: Unused definitions - When I copy the "unused_definitions.yaml" file to the temp folder When I run behat with the following additional options: - | option | value | - | --config | {SYSTEM_TMP_DIR}/unused_definitions.yaml | - Then the temp "unused_definitions.php" file should be like: + | option | value | + | --config | unused_definitions.yaml | + Then it should pass + And "unused_definitions.php" file should contain: """ withProfile((new Profile('default')) ->withPrintUnusedDefinitions()); """ - And the temp "unused_definitions.yaml" file should have been removed + And the "unused_definitions.yaml" file should have been removed from the working directory Scenario: Formatters - When I copy the "formatters.yaml" file to the temp folder When I run behat with the following additional options: - | option | value | - | --config | {SYSTEM_TMP_DIR}/formatters.yaml | - Then the temp "formatters.php" file should be like: + | option | value | + | --config | formatters.yaml | + Then it should pass + And "formatters.php" file should contain: """ withSkipAllTests() ->withErrorReporting(E_ALL & ~(E_WARNING | E_NOTICE | E_DEPRECATED)))); """ - And the temp "tester_options.yaml" file should have been removed + And the "tester_options.yaml" file should have been removed from the working directory Scenario: Full configuration - When I copy the "full_configuration.yaml" file to the temp folder - And I copy the "imported.yaml" file to the temp folder And the "MY_SECRET_PASSWORD" environment variable is set to "sesame" When I run behat with the following additional options: - | option | value | - | --config | {SYSTEM_TMP_DIR}/full_configuration.yaml | - Then the temp "full_configuration.php" file should be like: + | option | value | + | --config | full_configuration.yaml | + Then it should pass + And "full_configuration.php" file should contain exactly: """ withErrorReporting(E_ERROR))) ->withPreferredProfile('other'); """ - And the temp "imported.php" file should be like: + And "imported.php" file should contain: """ withProfile(new Profile('another')); """ - And the temp "full_configuration.yaml" file should have been removed - And the temp "imported.yaml" file should have been removed + And the "full_configuration.yaml" file should have been removed from the working directory + And the "imported.yaml" file should have been removed from the working directory diff --git a/features/definitions_transformations_annotations.feature b/features/definitions_transformations_annotations.feature index b1c42c43c..95a053a2c 100644 --- a/features/definitions_transformations_annotations.feature +++ b/features/definitions_transformations_annotations.feature @@ -4,7 +4,7 @@ Feature: Step Arguments Transformations Annotations I need to use transformation functions using annotations Background: - Given I set the working directory to the "Transformations" fixtures folder + Given I initialise the working directory from the "Transformations" fixtures folder And I provide the following options for all behat invocations: | option | value | | --no-colors | | diff --git a/features/definitions_transformations_attributes.feature b/features/definitions_transformations_attributes.feature index f4946fe51..cf1b0087f 100644 --- a/features/definitions_transformations_attributes.feature +++ b/features/definitions_transformations_attributes.feature @@ -4,7 +4,7 @@ Feature: Step Arguments Transformations with Attributes I need to use transformation functions using PHP attributes Background: - Given I set the working directory to the "Transformations" fixtures folder + Given I initialise the working directory from the "Transformations" fixtures folder And I provide the following options for all behat invocations: | option | value | | --no-colors | | @@ -58,4 +58,3 @@ Feature: Step Arguments Transformations with Attributes 4 scenarios (4 passed) 11 steps (11 passed) """ - diff --git a/features/editor_url.feature b/features/editor_url.feature index effcb1f83..f94a8886b 100644 --- a/features/editor_url.feature +++ b/features/editor_url.feature @@ -4,7 +4,7 @@ Feature: Editor URL I need to be able to ask Behat to add editor links to file paths in the output Background: - Given I set the working directory to the "EditorUrl" fixtures folder + Given I initialise the working directory from the "EditorUrl" fixtures folder And I provide the following options for all behat invocations: | option | value | | --no-colors | | @@ -47,14 +47,14 @@ Feature: Editor URL | --editor-url | 'phpstorm://open?file={absPath}&line={line}' | Then the output should contain: """ - Scenario: # features/test.feature:3 + Scenario: # features/test.feature:3 Given I have a passing step # FeatureContext::iHaveAPassingStep() And I have a step that throws an exception # FeatureContext::iHaveAFailingStep() - Warning: Undefined variable $b in features/bootstrap/FeatureContext.php line 16 + Warning: Undefined variable $b in features/bootstrap/FeatureContext.php line 16 --- Failed scenarios: - features/test.feature:3 + features/test.feature:3 """ Scenario: Use relative paths in url but absolute paths in visible text @@ -64,13 +64,12 @@ Feature: Editor URL | --editor-url | 'phpstorm://open?file={relPath}&line={line}' | Then the output should contain: """ - Scenario: # {BASE_PATH}tests/Fixtures/EditorUrl/features/test.feature:3 + Scenario: # %%WORKING_DIR%%features/test.feature:3 Given I have a passing step # FeatureContext::iHaveAPassingStep() And I have a step that throws an exception # FeatureContext::iHaveAFailingStep() - Warning: Undefined variable $b in {BASE_PATH}tests/Fixtures/EditorUrl/features/bootstrap/FeatureContext.php line 16 + Warning: Undefined variable $b in %%WORKING_DIR%%features/bootstrap/FeatureContext.php line 16 --- Failed scenarios: - {BASE_PATH}tests/Fixtures/EditorUrl/features/test.feature:3 + %%WORKING_DIR%%features/test.feature:3 """ - diff --git a/features/error_reporting.feature b/features/error_reporting.feature index 964ab05b4..45b6bf4d0 100644 --- a/features/error_reporting.feature +++ b/features/error_reporting.feature @@ -4,7 +4,7 @@ Feature: Error Reporting I need to have an ability to set a custom error level for steps to be executed in Background: - Given I set the working directory to the "ErrorReporting" fixtures folder + Given I initialise the working directory from the "ErrorReporting" fixtures folder And I provide the following options for all behat invocations: | option | value | | --no-colors | | diff --git a/features/junit_format.feature b/features/junit_format.feature index 701a28211..70f720aba 100644 --- a/features/junit_format.feature +++ b/features/junit_format.feature @@ -1,18 +1,18 @@ - Feature: JUnit Formatter +Feature: JUnit Formatter In order to integrate with other development tools As a developer I need to be able to generate a JUnit-compatible report Background: - Given I set the working directory to the "JunitFormat" fixtures folder + Given I initialise the working directory from the "JunitFormat" fixtures folder And I provide the following options for all behat invocations: | option | value | | --no-colors | | | --snippets-type | regex | | --format | junit | - | --out | {SYSTEM_TMP_DIR} | + | --out | {BASE_PATH}/logs | - Scenario: Run a single feature + Scenario: Run a single feature When I run behat with the following additional options: | option | value | | --snippets-for | FeatureContext | @@ -27,7 +27,7 @@ throw new PendingException(); } """ - And the temp "single_feature.xml" file xml should be like: + And the "logs/single_feature.xml" file xml should be like: """ @@ -54,14 +54,14 @@ """ - And the temp file "single_feature.xml" should be a valid document according to "junit.xsd" + And the file "logs/single_feature.xml" should be a valid document according to "junit.xsd" Scenario: Run multiple Features When I run behat with the following additional options: | option | value | | --suite | multiple_features | Then it should pass with no output - And the temp "multiple_features.xml" file xml should be like: + And the "logs/multiple_features.xml" file xml should be like: """ @@ -73,14 +73,14 @@ """ - And the temp file "multiple_features.xml" should be a valid document according to "junit.xsd" + And the file "logs/multiple_features.xml" should be a valid document according to "junit.xsd" Scenario: Confirm multiline scenario titles are printed correctly When I run behat with the following additional options: | option | value | | --suite | multiline_titles | Then it should pass with no output - And the temp "multiline_titles.xml" file xml should be like: + And the "logs/multiline_titles.xml" file xml should be like: """ @@ -90,14 +90,14 @@ """ - And the temp file "multiline_titles.xml" should be a valid document according to "junit.xsd" + And the file "logs/multiline_titles.xml" should be a valid document according to "junit.xsd" Scenario: Multiple suites When I run behat with the following additional options: | option | value | | --config | two_suites.php | Then it should fail with no output - And the temp "small_kid.xml" file xml should be like: + And the "logs/small_kid.xml" file xml should be like: """ @@ -106,8 +106,8 @@ """ - And the temp file "small_kid.xml" should be a valid document according to "junit.xsd" - And the temp "old_man.xml" file xml should be like: + And the file "logs/small_kid.xml" should be a valid document according to "junit.xsd" + And the "logs/old_man.xml" file xml should be like: """ @@ -118,14 +118,14 @@ """ - And the temp file "old_man.xml" should be a valid document according to "junit.xsd" + And the file "logs/old_man.xml" should be a valid document according to "junit.xsd" Scenario: Report skipped testcases When I run behat with the following additional options: | option | value | | --suite | skipped_test_cases | Then it should fail with no output - And the temp "skipped_test_cases.xml" file xml should be like: + And the "logs/skipped_test_cases.xml" file xml should be like: """ @@ -139,14 +139,14 @@ """ - And the temp file "skipped_test_cases.xml" should be a valid document according to "junit.xsd" + And the file "logs/skipped_test_cases.xml" should be a valid document according to "junit.xsd" Scenario: Stop on Failure When I run behat with the following additional options: | option | value | | --suite | stop_on_failure | Then it should fail with no output - And the temp "stop_on_failure.xml" file xml should be like: + And the "logs/stop_on_failure.xml" file xml should be like: """ @@ -157,7 +157,7 @@ """ - And the temp file "stop_on_failure.xml" should be a valid document according to "junit.xsd" + And the file "logs/stop_on_failure.xml" should be a valid document according to "junit.xsd" Scenario: Aborting due to PHP error When I run behat with the following additional options: @@ -167,7 +167,7 @@ """ cannot extend interface Behat\Behat\Context\Context """ - And the temp "abort_on_php_error.xml" file xml should be like: + And the "logs/abort_on_php_error.xml" file xml should be like: """ diff --git a/features/path_filters.feature b/features/path_filters.feature index a37164605..7364b5526 100644 --- a/features/path_filters.feature +++ b/features/path_filters.feature @@ -4,7 +4,7 @@ Feature: Path filters I need Behat to support path(s) filtering Background: - Given I set the working directory to the "PathFilters" fixtures folder + Given I initialise the working directory from the "PathFilters" fixtures folder And I provide the following options for all behat invocations: | option | value | | --no-colors | | diff --git a/features/print_absolute_paths.feature b/features/print_absolute_paths.feature index ab0f10e6e..b4ccafc03 100644 --- a/features/print_absolute_paths.feature +++ b/features/print_absolute_paths.feature @@ -4,7 +4,7 @@ Feature: Print absolute paths I need to be able to ask Behat to print the full absolute path for files Background: - Given I set the working directory to the "PrintAbsolutePaths" fixtures folder + Given I initialise the working directory from the "PrintAbsolutePaths" fixtures folder And I provide the following options for all behat invocations: | option | value | | --no-colors | | @@ -15,14 +15,14 @@ Feature: Print absolute paths | --print-absolute-paths | | Then the output should contain: """ - Scenario: # {BASE_PATH}tests/Fixtures/PrintAbsolutePaths/features/test.feature:3 + Scenario: # %%WORKING_DIR%%features%%DS%%test.feature:3 Given I have a passing step # FeatureContext::iHaveAPassingStep() And I have a step that throws an exception # FeatureContext::iHaveAFailingStep() - Warning: Undefined variable $b in {BASE_PATH}tests/Fixtures/PrintAbsolutePaths/features/bootstrap/FeatureContext.php line 16 + Warning: Undefined variable $b in %%WORKING_DIR%%features%%DS%%bootstrap%%DS%%FeatureContext.php line 16 --- Failed scenarios: - {BASE_PATH}tests/Fixtures/PrintAbsolutePaths/features/test.feature:3 + %%WORKING_DIR%%features%%DS%%test.feature:3 """ Scenario: Add option in config file @@ -31,12 +31,12 @@ Feature: Print absolute paths | --profile | absolute_paths | Then the output should contain: """ - Scenario: # {BASE_PATH}tests/Fixtures/PrintAbsolutePaths/features/test.feature:3 + Scenario: # %%WORKING_DIR%%features%%DS%%test.feature:3 Given I have a passing step # FeatureContext::iHaveAPassingStep() And I have a step that throws an exception # FeatureContext::iHaveAFailingStep() - Warning: Undefined variable $b in {BASE_PATH}tests/Fixtures/PrintAbsolutePaths/features/bootstrap/FeatureContext.php line 16 + Warning: Undefined variable $b in %%WORKING_DIR%%features%%DS%%bootstrap%%DS%%FeatureContext.php line 16 --- Failed scenarios: - {BASE_PATH}tests/Fixtures/PrintAbsolutePaths/features/test.feature:3 + %%WORKING_DIR%%features%%DS%%test.feature:3 """ diff --git a/features/remove_prefix.feature b/features/remove_prefix.feature index 35dc25215..679ec38b9 100644 --- a/features/remove_prefix.feature +++ b/features/remove_prefix.feature @@ -4,7 +4,7 @@ Feature: Remove prefix I need to be able to ask Behat to remove specific prefixes from paths in the output Background: - Given I set the working directory to the "RemovePrefix" fixtures folder + Given I initialise the working directory from the "RemovePrefix" fixtures folder And I provide the following options for all behat invocations: | option | value | | --no-colors | | @@ -65,12 +65,12 @@ Feature: Remove prefix | --remove-prefix | {BASE_PATH} | Then the output should contain: """ - Scenario: # tests/Fixtures/RemovePrefix/features/test.feature:3 + Scenario: # features%%DS%%test.feature:3 Given I have a passing step # FeatureContext::iHaveAPassingStep() And I have a step that throws an exception # FeatureContext::iHaveAFailingStep() - Warning: Undefined variable $b in tests/Fixtures/RemovePrefix/features/bootstrap/FeatureContext.php line 16 + Warning: Undefined variable $b in features%%DS%%bootstrap%%DS%%FeatureContext.php line 16 --- Failed scenarios: - tests/Fixtures/RemovePrefix/features/test.feature:3 + features%%DS%%test.feature:3 """ diff --git a/features/stop_on_failure.feature b/features/stop_on_failure.feature index e62470118..edc2cf170 100644 --- a/features/stop_on_failure.feature +++ b/features/stop_on_failure.feature @@ -4,7 +4,7 @@ Feature: Stop on failure via config I need to have a stop-on-failure option on the CLI or in config Background: - Given I set the working directory to the "StopOnFailure" fixtures folder + Given I initialise the working directory from the "StopOnFailure" fixtures folder And I provide the following options for all behat invocations: | option | value | | --no-colors | | diff --git a/features/unused_definitions.feature b/features/unused_definitions.feature index e9225f58a..13c7dd61c 100644 --- a/features/unused_definitions.feature +++ b/features/unused_definitions.feature @@ -4,7 +4,7 @@ Feature: Unused definitions I need to be able to generate a list of unused definitions Background: - Given I set the working directory to the "UnusedDefinitions" fixtures folder + Given I initialise the working directory from the "UnusedDefinitions" fixtures folder And I provide the following options for all behat invocations: | option | value | | --no-colors | | @@ -79,4 +79,3 @@ Feature: Unused definitions [Given|*] /^I have clicked "+"$/ `TranslatedDefinitionsContext::iHaveClickedPlus()` """ -