Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
Doorcode
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Guardians of the Kretschmar Elock System
Doorcode
Commits
9890a28f
Commit
9890a28f
authored
Jul 19, 2020
by
Jacob Priddy
👌
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix update group tests after changing behavior
parent
1fd3a5ca
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
11 deletions
+14
-11
src/backend/src/UseCases/Groups/UpdateGroup/UpdateGroup.php
src/backend/src/UseCases/Groups/UpdateGroup/UpdateGroup.php
+1
-1
src/backend/tests/Unit/Source/UseCases/Groups/UpdateGroup/UseCaseTest.php
...s/Unit/Source/UseCases/Groups/UpdateGroup/UseCaseTest.php
+13
-10
No files found.
src/backend/src/UseCases/Groups/UpdateGroup/UpdateGroup.php
View file @
9890a28f
...
...
@@ -40,7 +40,7 @@ class UpdateGroup implements UpdateGroupUseCase
$reflection
=
new
ReflectionClass
(
Permissions
::
class
);
if
(
in_array
(
$group
->
getTitle
(),
$reflection
->
getConstants
(),
true
))
{
$response
->
setError
(
'You cannot modify the title of a default permission group'
);
$response
->
setError
(
'You cannot modify the title of a default permission group
.
'
);
$presenter
->
present
(
$response
);
return
;
}
...
...
src/backend/tests/Unit/Source/UseCases/Groups/UpdateGroup/UseCaseTest.php
View file @
9890a28f
...
...
@@ -43,6 +43,7 @@ class UseCaseTest extends TestCase
* @param string $groupId
* @param array $attributes
* @throws EntityNotFoundException
* @throws \Source\Exceptions\EntityExistsException
*/
public
function
handleTest
(
string
$groupId
,
array
$attributes
):
void
{
...
...
@@ -54,6 +55,7 @@ class UseCaseTest extends TestCase
/**
* @test
* @throws EntityNotFoundException
* @throws \Source\Exceptions\EntityExistsException
*/
public
function
presenter_was_called
():
void
{
...
...
@@ -62,12 +64,13 @@ class UseCaseTest extends TestCase
$this
->
handleTest
(
'69'
,
$this
->
createGroupAttributes
(
$group
));
$this
->
assertTrue
(
$this
->
presenter
->
wasPresenterCalled
());
self
::
assertTrue
(
$this
->
presenter
->
wasPresenterCalled
());
}
/**
* @test
* @throws EntityNotFoundException
* @throws \Source\Exceptions\EntityExistsException
*/
public
function
it_updates_a_group
():
void
{
...
...
@@ -77,14 +80,15 @@ class UseCaseTest extends TestCase
$this
->
handleTest
(
'69'
,
$this
->
createGroupAttributes
(
$updatedGroup
));
$this
->
assertFalse
(
$this
->
response
->
hasError
());
$this
->
assertEquals
(
'updated title'
,
$this
->
groups
->
get
(
'69'
)
->
getTitle
());
$this
->
assertEquals
(
$updatedGroup
,
$this
->
response
->
getGroup
());
self
::
assertFalse
(
$this
->
response
->
hasError
());
self
::
assertEquals
(
'updated title'
,
$this
->
groups
->
get
(
'69'
)
->
getTitle
());
self
::
assertEquals
(
$updatedGroup
,
$this
->
response
->
getGroup
());
}
/**
* @test
* @throws EntityNotFoundException
* @throws \Source\Exceptions\EntityExistsException
*/
public
function
it_cannot_update_non_existent_group
():
void
{
...
...
@@ -97,9 +101,11 @@ class UseCaseTest extends TestCase
/**
* @test
* @throws EntityNotFoundException
* @throws \Source\Exceptions\EntityExistsException
*/
public
function
it_
sets_error_on_fai
l
():
void
public
function
it_
fails_if_update_returns_nul
l
():
void
{
$this
->
expectException
(
EntityNotFoundException
::
class
);
$updatedGroup
=
new
Group
(
420
,
'updated name'
,
''
);
$stub
=
new
InMemoryGroupsRepositoryStub
();
...
...
@@ -107,14 +113,12 @@ class UseCaseTest extends TestCase
$this
->
useCase
=
new
UpdateGroup
(
$stub
);
$this
->
handleTest
(
'420'
,
$this
->
createGroupAttributes
(
$updatedGroup
));
$this
->
assertTrue
(
$this
->
response
->
hasError
());
$this
->
assertEquals
(
'Unable to update group.'
,
$this
->
response
->
getError
());
}
/**
* @test
* @throws \Source\Exceptions\EntityNotFoundException
* @throws \Source\Exceptions\EntityExistsException
*/
public
function
it_cannot_change_title_on_default_permission_group
():
void
{
...
...
@@ -124,7 +128,6 @@ class UseCaseTest extends TestCase
$this
->
handleTest
(
'69'
,
$this
->
createGroupAttributes
(
$updatedGroup
));
$this
->
assertEquals
(
Permissions
::
CODE_QUERY
,
$this
->
response
->
getGroup
()
->
getTitle
());
$this
->
assertEquals
(
'asdf'
,
$this
->
response
->
getGroup
()
->
getDescription
());
self
::
assertEquals
(
'You cannot modify the title of a default permission group.'
,
$this
->
response
->
getError
());
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment