Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/storage/__tests__/PhabricatorFileTestCase.php
Show First 20 Lines • Show All 218 Lines • ▼ Show 20 Lines | public function testFileVisibility() { | ||||
// Test the thumbnail's visibility. | // Test the thumbnail's visibility. | ||||
$this->assertEqual( | $this->assertEqual( | ||||
array( | array( | ||||
true, | true, | ||||
true, | true, | ||||
), | ), | ||||
$this->canViewFile($users, $xform), | $this->canViewFile($users, $xform), | ||||
pht('Attached Thumbnail Visibility')); | pht('Attached Thumbnail Visibility')); | ||||
// Detach the object and make sure it affects the thumbnail. | |||||
$file->detachFromObject($object->getPHID()); | |||||
// Test the detached thumbnail's visibility. | |||||
$this->assertEqual( | |||||
array( | |||||
true, | |||||
false, | |||||
), | |||||
$this->canViewFile($users, $xform), | |||||
pht('Detached Thumbnail Visibility')); | |||||
} | } | ||||
private function canViewFile(array $users, PhabricatorFile $file) { | private function canViewFile(array $users, PhabricatorFile $file) { | ||||
$results = array(); | $results = array(); | ||||
foreach ($users as $user) { | foreach ($users as $user) { | ||||
$results[] = (bool)id(new PhabricatorFileQuery()) | $results[] = (bool)id(new PhabricatorFileQuery()) | ||||
->setViewer($user) | ->setViewer($user) | ||||
->withPHIDs(array($file->getPHID())) | ->withPHIDs(array($file->getPHID())) | ||||
▲ Show 20 Lines • Show All 250 Lines • Show Last 20 Lines |