Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
unit-test
integration-test
  • Loading branch information
DumbergerL committed Jan 15, 2024
1 parent 8abde4b commit 5191c1e
Show file tree
Hide file tree
Showing 6 changed files with 396 additions and 1 deletion.
42 changes: 42 additions & 0 deletions docs/out/GroupAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -570,4 +570,46 @@
// Output: 0


```

## Group Roles

```php
use CTApi\Models\Groups\GroupTypeRole\GroupTypeRoleRequest;

$roles = GroupTypeRoleRequest::all();
$role = $roles[0];

var_dump( $role->getId());
// Output: 15

var_dump( $role->getGroupTypeId());
// Output: 2

$groupType = $role->requestGroupType();
var_dump( $role->getGrowPathId());
// Output: null

var_dump( $role->getName());
// Output: "Mitarbeiter"

var_dump( $role->getShorty());
// Output: "MA"

var_dump( $role->getType());
// Output: "participant"

var_dump( $role->getIsDefault());
// Output: true

var_dump( $role->getIsHidden());
// Output: false

var_dump( $role->getIsLeader());
// Output: false

var_dump( $role->getSortKey());
// Output: 0


```
6 changes: 5 additions & 1 deletion docs/src/ressources/GroupAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@

{{ \CTApi\Test\Unit\Docs\GroupTypeRequestTest.testGetAll }}

{{ \CTApi\Test\Unit\Docs\GroupTypeRequestTest.testFind }}
{{ \CTApi\Test\Unit\Docs\GroupTypeRequestTest.testFind }}

## Group Roles

{{ \CTApi\Test\Unit\Docs\GroupTypeRoleRequestTest.testGetGroupTypeRoleRequest }}
69 changes: 69 additions & 0 deletions tests/Integration/Requests/GroupTypeRoleRequestTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

namespace CTApi\Test\Integration\Requests;

use CTApi\CTLog;
use CTApi\Models\Groups\Group\GroupType;
use CTApi\Models\Groups\GroupTypeRole\GroupTypeRole;
use CTApi\Models\Groups\GroupTypeRole\GroupTypeRoleRequest;
use CTApi\Test\Integration\IntegrationTestData;
use CTApi\Test\Integration\TestCaseAuthenticated;

class GroupTypeRoleRequestTest extends TestCaseAuthenticated
{
private int $id;

protected function setUp(): void
{
parent::setUp();
$this->id = IntegrationTestData::getResultAsInt("group_type_roles", "any_group_type_role.id");
}

public function testGetAll()
{
CTLog::enableHttpLog();
$groupTypeRoles = GroupTypeRoleRequest::all();

$foundGroupTypeRole = null;
foreach ($groupTypeRoles as $groupTypeRole) {
if ($groupTypeRole->getIdAsInteger() === $this->id) {
$foundGroupTypeRole = $groupTypeRole;
}
}

$this->assertNotNull($foundGroupTypeRole);
$this->assertGroupTypeRole($foundGroupTypeRole);
}

public function testGetGroupTypeRole()
{
$groupTypeRole = GroupTypeRoleRequest::findOrFail($this->id);
$this->assertGroupTypeRole($groupTypeRole);

$groupType = $groupTypeRole->requestGroupType();
$this->assertGroupType($groupType);
}

private function assertGroupTypeRole(GroupTypeRole $groupTypeRole): void
{
$this->assertEqualsTestData("group_type_roles", "any_group_type_role.groupType.id", $groupTypeRole->getGroupTypeId());
$this->assertEqualsTestData("group_type_roles", "any_group_type_role.name", $groupTypeRole->getName());
$this->assertEqualsTestData("group_type_roles", "any_group_type_role.shorty", $groupTypeRole->getShorty());
$this->assertEqualsTestData("group_type_roles", "any_group_type_role.type", $groupTypeRole->getType());
$this->assertEqualsTestData("group_type_roles", "any_group_type_role.isDefault", $groupTypeRole->getIsDefault());
$this->assertEqualsTestData("group_type_roles", "any_group_type_role.isHidden", $groupTypeRole->getIsHidden());
$this->assertEqualsTestData("group_type_roles", "any_group_type_role.isLeader", $groupTypeRole->getIsLeader());
$this->assertEqualsTestData("group_type_roles", "any_group_type_role.sortKey", $groupTypeRole->getSortKey());
}

private function assertGroupType(GroupType $groupType): void
{
$this->assertEqualsTestData("group_type_roles", "any_group_type_role.groupType.id", $groupType->getId());
$this->assertEqualsTestData("group_type_roles", "any_group_type_role.groupType.availableForNewPerson", $groupType->getAvailableForNewPerson());
$this->assertEqualsTestData("group_type_roles", "any_group_type_role.groupType.isLeaderNecessary", $groupType->getIsLeaderNecessary());
$this->assertEqualsTestData("group_type_roles", "any_group_type_role.groupType.name", $groupType->getName());
$this->assertEqualsTestData("group_type_roles", "any_group_type_role.groupType.permissionDepth", $groupType->getPermissionDepth());
$this->assertEqualsTestData("group_type_roles", "any_group_type_role.groupType.shorty", $groupType->getShorty());
$this->assertEqualsTestData("group_type_roles", "any_group_type_role.groupType.sortKey", $groupType->getSortKey());
}
}
24 changes: 24 additions & 0 deletions tests/Integration/integration-test-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,30 @@
}
}
},
"group_type_roles": {
"description": "Get group type roles.",
"result": {
"any_group_type_role": {
"id": 12,
"groupType": {
"id": 1,
"availableForNewPerson": false,
"isLeaderNecessary": true,
"name": "Kleingruppe",
"permissionDepth": 1,
"shorty": "KG",
"sortKey": 0
},
"name": "Organisator",
"shorty": "O",
"type": "participant",
"isDefault": false,
"isHidden": false,
"isLeader": false,
"sortKey": 4
}
}
},
"update_group_member": {
"description": "Add person to group and remove them again.",
"filter": {
Expand Down
28 changes: 28 additions & 0 deletions tests/Unit/Docs/GroupTypeRoleRequestTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace CTApi\Test\Unit\Docs;

use CTApi\Models\Groups\GroupTypeRole\GroupTypeRoleRequest;
use CTApi\Test\Unit\TestCaseHttpMocked;

class GroupTypeRoleRequestTest extends TestCaseHttpMocked
{
public function testGetGroupTypeRoleRequest()
{
$roles = GroupTypeRoleRequest::all();
$role = $roles[0];

$this->assertEquals(15, $role->getId());
$this->assertEquals(2, $role->getGroupTypeId());
$groupType = $role->requestGroupType();
$this->assertEquals(null, $role->getGrowPathId());
$this->assertEquals("Mitarbeiter", $role->getName());
$this->assertEquals("MA", $role->getShorty());
$this->assertEquals("participant", $role->getType());
$this->assertEquals(true, $role->getIsDefault());
$this->assertEquals(false, $role->getIsHidden());
$this->assertEquals(false, $role->getIsLeader());
$this->assertEquals(0, $role->getSortKey());
}

}
Loading

0 comments on commit 5191c1e

Please sign in to comment.