Skip to content

Commit 1fea118

Browse files
committed
add scenario for creating a group
1 parent a038aff commit 1fea118

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

tests/Behat/Bootstrap/FeatureContext.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
final class FeatureContext extends TestCase implements Context
2727
{
28+
use GroupContextTrait;
2829
use ProjectContextTrait;
2930

3031
private static ?BehatHookTracer $tracer = null;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Redmine\Tests\Behat\Bootstrap;
6+
7+
use Behat\Behat\Tester\Exception\PendingException;
8+
use Behat\Gherkin\Node\TableNode;
9+
use Redmine\Api\Group;
10+
11+
trait GroupContextTrait
12+
{
13+
/**
14+
* @When I create a group with name :groupName
15+
*/
16+
public function iCreateAGroupWithName(string $groupName)
17+
{
18+
$data = [
19+
'name' => $groupName,
20+
];
21+
22+
/** @var Group */
23+
$groupApi = $this->getNativeCurlClient()->getApi('group');
24+
25+
$this->registerClientResponse(
26+
$groupApi->create($data),
27+
$groupApi->getLastResponse()
28+
);
29+
}
30+
}

tests/Behat/features/groups.feature

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Feature: Interacting with the REST API for groups
2+
In order to interact with REST API for groups
3+
As a user
4+
I want to make sure the Redmine server replies with the correct response
5+
6+
Scenario: Creating a group with minimal parameters
7+
Given I have a "NativeCurlClient" client
8+
When I create a group with name "Test Group"
9+
Then the response has the status code "201"
10+
And the response has the content type "application/xml"
11+
And the returned data is an instance of "SimpleXMLElement"
12+
And the returned data has only the following properties
13+
"""
14+
id
15+
name
16+
"""
17+
And the returned data has proterties with the following data
18+
| property | value |
19+
| id | 4 |
20+
| name | Test Group |

0 commit comments

Comments
 (0)