Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F97871034
ConpherenceTestCase.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Jan 7, 00:29
Size
2 KB
Mime Type
text/x-php
Expires
Thu, Jan 9, 00:29 (2 d)
Engine
blob
Format
Raw Data
Handle
23424944
Attached To
rPH Phabricator
ConpherenceTestCase.php
View Options
<?php
abstract
class
ConpherenceTestCase
extends
PhabricatorTestCase
{
protected
function
addParticipants
(
PhabricatorUser
$actor
,
ConpherenceThread
$conpherence
,
array
$participant_phids
)
{
$xactions
=
array
(
id
(
new
ConpherenceTransaction
())
->
setTransactionType
(
ConpherenceTransaction
::
TYPE_PARTICIPANTS
)
->
setNewValue
(
array
(
'+'
=>
$participant_phids
)),
);
$editor
=
id
(
new
ConpherenceEditor
())
->
setActor
(
$actor
)
->
setContentSource
(
PhabricatorContentSource
::
newConsoleSource
())
->
applyTransactions
(
$conpherence
,
$xactions
);
}
protected
function
removeParticipants
(
PhabricatorUser
$actor
,
ConpherenceThread
$conpherence
,
array
$participant_phids
)
{
$xactions
=
array
(
id
(
new
ConpherenceTransaction
())
->
setTransactionType
(
ConpherenceTransaction
::
TYPE_PARTICIPANTS
)
->
setNewValue
(
array
(
'-'
=>
$participant_phids
)),
);
$editor
=
id
(
new
ConpherenceEditor
())
->
setActor
(
$actor
)
->
setContentSource
(
PhabricatorContentSource
::
newConsoleSource
())
->
applyTransactions
(
$conpherence
,
$xactions
);
}
protected
function
addMessageWithFile
(
PhabricatorUser
$actor
,
ConpherenceThread
$conpherence
)
{
$file
=
$this
->
generateTestFile
(
$actor
);
$message
=
Filesystem
::
readRandomCharacters
(
64
).
sprintf
(
' {%s} '
,
$file
->
getMonogram
());
$editor
=
id
(
new
ConpherenceEditor
())
->
setActor
(
$actor
)
->
setContentSource
(
PhabricatorContentSource
::
newConsoleSource
());
$xactions
=
$editor
->
generateTransactionsFromText
(
$actor
,
$conpherence
,
$message
);
return
$editor
->
applyTransactions
(
$conpherence
,
$xactions
);
}
private
function
generateTestFile
(
PhabricatorUser
$actor
)
{
$engine
=
new
PhabricatorTestStorageEngine
();
$data
=
Filesystem
::
readRandomCharacters
(
64
);
$params
=
array
(
'name'
=>
'test.'
.
$actor
->
getPHID
(),
'viewPolicy'
=>
$actor
->
getPHID
(),
'authorPHID'
=>
$actor
->
getPHID
(),
'storageEngines'
=>
array
(
$engine
,
),
);
$file
=
PhabricatorFile
::
newFromFileData
(
$data
,
$params
);
$file
->
save
();
return
$file
;
}
}
Event Timeline
Log In to Comment