FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
BookStack/tests/Activity/WebhookFormatTesting.php at development · BookStackApp/BookStack · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
BookStackApp
/
BookStack
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
2.4k
Star
19k
Code
Issues
0
Pull requests
1
Security and quality
8
Insights
Additional navigation options
Code
Issues
Pull requests
Security and quality
Insights
Expand file tree
Breadcrumbs
BookStack
/
tests
/
Activity
/
WebhookFormatTesting.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
49 lines (40 loc) · 1.92 KB
Breadcrumbs
BookStack
/
tests
/
Activity
/
WebhookFormatTesting.php
Copy path
File metadata and controls
49 lines (40 loc) · 1.92 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
namespace
Tests
\
Activity
;
use
BookStack
\
Activity
\
ActivityType
;
use
BookStack
\
Activity
\
Models
\
Webhook
;
use
BookStack
\
Activity
\
Tools
\
WebhookFormatter
;
use
Illuminate
\
Support
\
Arr
;
use
Tests
\
TestCase
;
class
WebhookFormatTesting
extends
TestCase
{
public
function
test_entity_events_show_related_user_info
()
{
$
events
= [
ActivityType::
BOOK_UPDATE
=>
$
this
->
entities
->
book
(),
ActivityType::
CHAPTER_CREATE
=>
$
this
->
entities
->
chapter
(),
ActivityType::
PAGE_MOVE
=>
$
this
->
entities
->
page
(),
];
foreach
(
$
events
as
$
event
=>
$
entity
) {
$
data
=
$
this
->
getWebhookData
(
$
event
,
$
entity
);
$
this
->
assertEquals
(
$
entity
->
createdBy
->
name
, Arr::
get
(
$
data
,
'
related_item.created_by.name
'
));
$
this
->
assertEquals
(
$
entity
->
updatedBy
->
id
, Arr::
get
(
$
data
,
'
related_item.updated_by.id
'
));
$
this
->
assertEquals
(
$
entity
->
ownedBy
->
slug
, Arr::
get
(
$
data
,
'
related_item.owned_by.slug
'
));
}
}
public
function
test_page_create_and_update_events_show_revision_info
()
{
$
page
=
$
this
->
entities
->
page
();
$
this
->
asEditor
()->
put
(
$
page
->
getUrl
(), [
'
name
'
=>
'
Updated page
'
,
'
html
'
=>
'
new page html
'
,
'
summary
'
=>
'
Update a
'
]);
$
data
=
$
this
->
getWebhookData
(ActivityType::
PAGE_UPDATE
,
$
page
);
$
this
->
assertEquals
(
$
page
->
currentRevision
->
id
, Arr::
get
(
$
data
,
'
related_item.current_revision.id
'
));
$
this
->
assertEquals
(
$
page
->
currentRevision
->
type
, Arr::
get
(
$
data
,
'
related_item.current_revision.type
'
));
$
this
->
assertEquals
(
'
Update a
'
, Arr::
get
(
$
data
,
'
related_item.current_revision.summary
'
));
}
protected
function
getWebhookData
(
string
$
event
,
$
detail
):
array
{
$
webhook
= Webhook::
factory
()->
make
();
$
user
=
$
this
->
users
->
editor
();
$
formatter
= WebhookFormatter::
getDefault
(
$
event
,
$
webhook
,
$
detail
,
$
user
,
time
());
return
$
formatter
->
format
();
}
}
Back
|
FazBrowse Home
|
New Git URL