Skip to content

Commit

Permalink
add scenario for creating a group
Browse files Browse the repository at this point in the history
  • Loading branch information
Art4 committed Feb 13, 2024
1 parent a038aff commit 1fea118
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/Behat/Bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

final class FeatureContext extends TestCase implements Context
{
use GroupContextTrait;
use ProjectContextTrait;

private static ?BehatHookTracer $tracer = null;
Expand Down
30 changes: 30 additions & 0 deletions tests/Behat/Bootstrap/GroupContextTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

namespace Redmine\Tests\Behat\Bootstrap;

use Behat\Behat\Tester\Exception\PendingException;
use Behat\Gherkin\Node\TableNode;
use Redmine\Api\Group;

trait GroupContextTrait
{
/**
* @When I create a group with name :groupName
*/
public function iCreateAGroupWithName(string $groupName)
{
$data = [
'name' => $groupName,
];

/** @var Group */
$groupApi = $this->getNativeCurlClient()->getApi('group');

$this->registerClientResponse(
$groupApi->create($data),
$groupApi->getLastResponse()
);
}
}
20 changes: 20 additions & 0 deletions tests/Behat/features/groups.feature
Original file line number Diff line number Diff line change
@@ -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 |

0 comments on commit 1fea118

Please sign in to comment.