Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
violinist_teams
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
violinist_teams
Commits
82d8807d
Commit
82d8807d
authored
11 months ago
by
Eirik Morland
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3425417
by eiriksm: Make it possible to get and set the slack webhook for the team
parent
94282b2b
No related branches found
No related tags found
1 merge request
!34
Make it possible and add some tests
Pipeline
#110465
passed with warnings
11 months ago
Stage: build
Stage: validate
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/TeamNode.php
+21
-0
21 additions, 0 deletions
src/TeamNode.php
tests/src/Kernel/KernelTestBase.php
+16
-0
16 additions, 0 deletions
tests/src/Kernel/KernelTestBase.php
tests/src/Kernel/TeamNodeTest.php
+15
-0
15 additions, 0 deletions
tests/src/Kernel/TeamNodeTest.php
with
52 additions
and
0 deletions
src/TeamNode.php
+
21
−
0
View file @
82d8807d
...
...
@@ -379,4 +379,25 @@ class TeamNode extends Node {
return
in_array
(
$user_id
,
$this
->
getMemberIds
())
||
in_array
(
$user_id
,
$this
->
getAdministratorIds
());
}
/**
* Getter for the slack webhook.
*/
public
function
getTeamSlackWebhook
()
{
if
(
!
$this
->
hasField
(
'field_slack_webhook'
)
||
$this
->
get
(
'field_slack_webhook'
)
->
isEmpty
())
{
return
FALSE
;
}
return
$this
->
get
(
'field_slack_webhook'
)
->
first
()
->
getString
();
}
/**
* Setter for the slack webhook.
*/
public
function
setTeamSlackWebhook
(
$webhook
)
:
self
{
if
(
!
$this
->
hasField
(
'field_slack_webhook'
))
{
return
$this
;
}
$this
->
set
(
'field_slack_webhook'
,
$webhook
);
return
$this
;
}
}
This diff is collapsed.
Click to expand it.
tests/src/Kernel/KernelTestBase.php
+
16
−
0
View file @
82d8807d
...
...
@@ -241,6 +241,22 @@ abstract class KernelTestBase extends CoreKernelTestBase {
'required'
=>
FALSE
,
]);
$field
->
save
();
// Slack webhook.
$fieldStorage
=
FieldStorageConfig
::
create
([
'field_name'
=>
'field_slack_webhook'
,
'entity_type'
=>
'node'
,
'type'
=>
'string'
,
'cardinality'
=>
1
,
]);
$fieldStorage
->
save
();
$field
=
FieldConfig
::
create
([
'field_storage'
=>
$fieldStorage
,
'bundle'
=>
$this
->
nodeType
->
id
(),
'field_type'
=>
'string'
,
'required'
=>
FALSE
,
]);
$field
->
save
();
$this
->
installSchema
(
'user'
,
[
'users_data'
]);
}
...
...
This diff is collapsed.
Click to expand it.
tests/src/Kernel/TeamNodeTest.php
+
15
−
0
View file @
82d8807d
...
...
@@ -141,6 +141,21 @@ class TeamNodeTest extends KernelTestBase {
self
::
assertEquals
(
$expexted
,
$node
->
isNotificationsEnabledForSlack
());
}
/**
* Test for the method to set and get the slack webhook.
*/
public
function
testGetSlackWebhook
()
{
/** @var \Drupal\violinist_teams\TeamNode $node */
$node
=
Node
::
create
([
'type'
=>
$this
->
nodeType
->
id
(),
]);
$node
->
set
(
'field_slack_webhook'
,
'https://example.com/slack_hook'
);
self
::
assertEquals
(
'https://example.com/slack_hook'
,
$node
->
getTeamSlackWebhook
());
// Should actually also be possible to use a setter method.
$node
->
setTeamSlackWebhook
(
'https://example.com/slack_hook2'
);
self
::
assertEquals
(
'https://example.com/slack_hook2'
,
$node
->
getTeamSlackWebhook
());
}
/**
* Test migrating billing emails.
*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment