From 1fea118f1806b31f064f60d4b741cd06f57887c4 Mon Sep 17 00:00:00 2001 From: Art4 Date: Tue, 13 Feb 2024 16:25:55 +0100 Subject: [PATCH] add scenario for creating a group --- tests/Behat/Bootstrap/FeatureContext.php | 1 + tests/Behat/Bootstrap/GroupContextTrait.php | 30 +++++++++++++++++++++ tests/Behat/features/groups.feature | 20 ++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 tests/Behat/Bootstrap/GroupContextTrait.php create mode 100644 tests/Behat/features/groups.feature diff --git a/tests/Behat/Bootstrap/FeatureContext.php b/tests/Behat/Bootstrap/FeatureContext.php index ca21cb20..53ba9ce5 100644 --- a/tests/Behat/Bootstrap/FeatureContext.php +++ b/tests/Behat/Bootstrap/FeatureContext.php @@ -25,6 +25,7 @@ final class FeatureContext extends TestCase implements Context { + use GroupContextTrait; use ProjectContextTrait; private static ?BehatHookTracer $tracer = null; diff --git a/tests/Behat/Bootstrap/GroupContextTrait.php b/tests/Behat/Bootstrap/GroupContextTrait.php new file mode 100644 index 00000000..8dac1619 --- /dev/null +++ b/tests/Behat/Bootstrap/GroupContextTrait.php @@ -0,0 +1,30 @@ + $groupName, + ]; + + /** @var Group */ + $groupApi = $this->getNativeCurlClient()->getApi('group'); + + $this->registerClientResponse( + $groupApi->create($data), + $groupApi->getLastResponse() + ); + } +} diff --git a/tests/Behat/features/groups.feature b/tests/Behat/features/groups.feature new file mode 100644 index 00000000..07b22ee1 --- /dev/null +++ b/tests/Behat/features/groups.feature @@ -0,0 +1,20 @@ +Feature: Interacting with the REST API for groups + In order to interact with REST API for groups + As a user + I want to make sure the Redmine server replies with the correct response + + Scenario: Creating a group with minimal parameters + Given I have a "NativeCurlClient" client + When I create a group with name "Test Group" + Then the response has the status code "201" + And the response has the content type "application/xml" + And the returned data is an instance of "SimpleXMLElement" + And the returned data has only the following properties + """ + id + name + """ + And the returned data has proterties with the following data + | property | value | + | id | 4 | + | name | Test Group |