Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F98356145
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
Sun, Jan 12, 10:26
Size
2 KB
Mime Type
text/x-php
Expires
Tue, Jan 14, 10:26 (1 d, 21 h)
Engine
blob
Format
Raw Data
Handle
23564804
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