Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4170447
EventLoggingTestTrait.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
EventLoggingTestTrait.php
View Options
<?php
namespace
MediaWiki\Extension\EventLogging\Test
;
use
Wikimedia\TestingAccessWrapper
;
use
Wikimedia\Timestamp\ConvertibleTimestamp
;
/**
* A handful of helpful assertions that can be made about events in unit and integration tests.
*/
trait
EventLoggingTestTrait
{
public
function
assertIsTimestamp
(
string
$timestamp
):
void
{
// FIXME: Find a better way to assert "this is an ISO 8601 timestamp"
$this
->
assertMatchesRegularExpression
(
TestingAccessWrapper
::
newFromClass
(
ConvertibleTimestamp
::
class
)->
regexes
[
'TS_ISO_8601'
],
$timestamp
);
$this
->
assertStringEndsWith
(
'Z'
,
$timestamp
);
}
public
function
assertEventCanBeIngested
(
array
$event
,
string
$schema
,
string
$streamName
):
void
{
$this
->
assertSame
(
$schema
,
$event
[
'$schema'
]
);
$this
->
assertArrayHasKey
(
'meta'
,
$event
);
$this
->
assertSame
(
$streamName
,
$event
[
'meta'
][
'stream'
]
);
$this
->
assertArrayHasKey
(
'domain'
,
$event
[
'meta'
]
);
if
(
array_key_exists
(
'client_dt'
,
$event
)
)
{
$this
->
assertArrayNotHasKey
(
'dt'
,
$event
);
}
else
{
$this
->
assertArrayHasKey
(
'dt'
,
$event
);
$this
->
assertIsTimestamp
(
$event
[
'dt'
]
);
}
$this
->
assertArrayHasKey
(
'user-agent'
,
$event
[
'http'
][
'request_headers'
]
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Aug 20 2026, 05:44 (13 w, 6 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
9e/ee/6e97ba9896d29c6216b79b76b656
Default Alt Text
EventLoggingTestTrait.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment