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