mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-22 12:41:19 +01:00
Files Generating
Summary: Ref T2903 Test Plan: Files are being generating, albeit temporary. Reviewers: epriestley, AnhNhan Reviewed By: AnhNhan CC: aran, Korvin, AnhNhan, chad Maniphest Tasks: T2903 Differential Revision: https://secure.phabricator.com/D5801
This commit is contained in:
parent
c2014bb4db
commit
16ba0275c0
3 changed files with 32 additions and 2 deletions
|
@ -990,6 +990,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorFileStorageEngine' => 'applications/files/engine/PhabricatorFileStorageEngine.php',
|
||||
'PhabricatorFileStorageEngineSelector' => 'applications/files/engineselector/PhabricatorFileStorageEngineSelector.php',
|
||||
'PhabricatorFileTestCase' => 'applications/files/storage/__tests__/PhabricatorFileTestCase.php',
|
||||
'PhabricatorFileTestDataGenerator' => 'applications/files/lipsum/PhabricatorFileTestDataGenerator.php',
|
||||
'PhabricatorFileTransformController' => 'applications/files/controller/PhabricatorFileTransformController.php',
|
||||
'PhabricatorFileUploadController' => 'applications/files/controller/PhabricatorFileUploadController.php',
|
||||
'PhabricatorFileUploadException' => 'applications/files/exception/PhabricatorFileUploadException.php',
|
||||
|
@ -2724,6 +2725,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorFileStorageBlob' => 'PhabricatorFileDAO',
|
||||
'PhabricatorFileStorageConfigurationException' => 'Exception',
|
||||
'PhabricatorFileTestCase' => 'PhabricatorTestCase',
|
||||
'PhabricatorFileTestDataGenerator' => 'PhabricatorTestDataGenerator',
|
||||
'PhabricatorFileTransformController' => 'PhabricatorFileController',
|
||||
'PhabricatorFileUploadController' => 'PhabricatorFileController',
|
||||
'PhabricatorFileUploadException' => 'Exception',
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorFileTestDataGenerator
|
||||
extends PhabricatorTestDataGenerator {
|
||||
|
||||
public function generate() {
|
||||
$authorPHID = $this->loadAuthorPHID();
|
||||
$dimension = 1 << rand(5, 12);
|
||||
$image = id(new PhabricatorLipsumMondrianArtist())
|
||||
->generate($dimension, $dimension);
|
||||
$file = PhabricatorFile::newFromFileData(
|
||||
$image,
|
||||
array(
|
||||
'name' => 'rand-'.rand(1000, 9999),
|
||||
));
|
||||
$file->setAuthorPHID($authorPHID);
|
||||
$file->setMimeType('image/jpeg');
|
||||
return $file->save();
|
||||
}
|
||||
|
||||
private function loadPhabrictorUserPHID() {
|
||||
return $this->loadOneRandom("PhabricatorUser")->getPHID();
|
||||
}
|
||||
|
||||
public function loadAuthorPHID() {
|
||||
return $this->loadPhabrictorUserPHID();
|
||||
}
|
||||
}
|
|
@ -30,8 +30,8 @@ final class PhabricatorLipsumMondrianArtist extends PhabricatorLipsumArtist {
|
|||
|
||||
$fills = mt_rand(3, 8);
|
||||
for ($ii = 0; $ii < $fills; $ii++) {
|
||||
$xp = mt_rand(0, $x);
|
||||
$yp = mt_rand(0, $y);
|
||||
$xp = mt_rand(0, $x - 1);
|
||||
$yp = mt_rand(0, $y - 1);
|
||||
if (imagecolorat($image, $xp, $yp) != $c_white) {
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue