LocalStorageTest.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. <?php
  2. namespace App\Tests\Unit\Service\File\Storage;
  3. use App\Entity\Access\Access;
  4. use App\Entity\Core\File;
  5. use App\Entity\Organization\Organization;
  6. use App\Entity\Person\Person;
  7. use App\Enum\Core\FileStatusEnum;
  8. use App\Enum\Core\FileTypeEnum;
  9. use App\Repository\Access\AccessRepository;
  10. use App\Service\File\Factory\ImageFactory;
  11. use App\Service\File\Storage\LocalStorage;
  12. use App\Service\Utils\FileUtils;
  13. use App\Service\Utils\UrlBuilder;
  14. use DateTime;
  15. use Doctrine\ORM\EntityManagerInterface;
  16. use Gaufrette\Filesystem;
  17. use JetBrains\PhpStorm\Pure;
  18. use Knp\Bundle\GaufretteBundle\FilesystemMap;
  19. use Liip\ImagineBundle\Imagine\Cache\CacheManager;
  20. use Liip\ImagineBundle\Imagine\Data\DataManager;
  21. use PHPUnit\Framework\MockObject\MockObject;
  22. use PHPUnit\Framework\TestCase;
  23. use RuntimeException;
  24. class TestableLocalStorage extends LocalStorage {
  25. public const FS_KEY = parent::FS_KEY;
  26. public function getPrefix(mixed $owner, bool $isTemporary, string $type = null): string {
  27. return parent::getPrefix($owner, $isTemporary, $type);
  28. }
  29. #[Pure] public function getOrganizationAndPersonFromOwner(mixed $owner): array {
  30. return parent::getOrganizationAndPersonFromOwner($owner);
  31. }
  32. }
  33. class LocalStorageTest extends TestCase
  34. {
  35. private FilesystemMap $filesystemMap;
  36. private EntityManagerInterface $entityManager;
  37. private AccessRepository $accessRepository;
  38. private DataManager $dataManager;
  39. private CacheManager $cacheManager;
  40. private ImageFactory $imageFactory;
  41. private Filesystem $filesystem;
  42. private FileUtils $fileUtils;
  43. private UrlBuilder $urlBuilder;
  44. public function setUp(): void
  45. {
  46. $this->filesystemMap = $this->getMockBuilder(FilesystemMap::class)->disableOriginalConstructor()->getMock();
  47. $this->entityManager = $this->getMockBuilder(EntityManagerInterface::class)->disableOriginalConstructor()->getMock();
  48. $this->accessRepository = $this->getMockBuilder(AccessRepository::class)->disableOriginalConstructor()->getMock();
  49. $this->dataManager = $this->getMockBuilder(DataManager::class)->disableOriginalConstructor()->getMock();
  50. $this->cacheManager = $this->getMockBuilder(CacheManager::class)->disableOriginalConstructor()->getMock();
  51. $this->imageFactory = $this->getMockBuilder(ImageFactory::class)->disableOriginalConstructor()->getMock();
  52. $this->fileUtils = $this->getMockBuilder(FileUtils::class)->disableOriginalConstructor()->getMock();
  53. $this->urlBuilder = $this->getMockBuilder(UrlBuilder::class)->disableOriginalConstructor()->getMock();
  54. $this->filesystem = $this->getMockBuilder(Filesystem::class)->disableOriginalConstructor()->getMock();
  55. $this->filesystemMap->method('get')->with(TestableLocalStorage::FS_KEY)->willReturn($this->filesystem);
  56. }
  57. public function getMockForMethod(string $methodName): TestableLocalStorage | MockObject
  58. {
  59. return $this->getMockBuilder(TestableLocalStorage::class)
  60. ->setConstructorArgs([
  61. $this->filesystemMap,
  62. $this->entityManager,
  63. $this->accessRepository,
  64. $this->dataManager,
  65. $this->cacheManager,
  66. $this->imageFactory,
  67. $this->fileUtils,
  68. $this->urlBuilder
  69. ])
  70. ->setMethodsExcept([$methodName])
  71. ->getMock();
  72. }
  73. /**
  74. * @see LocalStorage::exists()
  75. */
  76. public function testExists(): void {
  77. $fileStorage = $this->getMockForMethod('exists');
  78. $file = $this->getMockBuilder(File::class)->getMock();
  79. $file->method('getSlug')->willReturn('foo');
  80. $this->filesystem->expects(self::once())->method('has')->with('foo')->willReturn(true);
  81. $this->assertTrue($fileStorage->exists($file));
  82. }
  83. /**
  84. * @see LocalStorage::exists()
  85. */
  86. public function testExistsInexistant(): void {
  87. $fileStorage = $this->getMockForMethod('exists');
  88. $file = $this->getMockBuilder(File::class)->getMock();
  89. $file->method('getSlug')->willReturn('foo');
  90. $this->filesystem->expects(self::once())->method('has')->with('foo')->willReturn(false);
  91. $this->assertFalse($fileStorage->exists($file));
  92. }
  93. /**
  94. * @see LocalStorage::listByOwner()
  95. */
  96. public function testListByOwner(): void
  97. {
  98. $fileStorage = $this->getMockForMethod('listByOwner');
  99. $owner = $this->getMockBuilder(Organization::class)->getMock();
  100. $fileStorage->method('getPrefix')->with($owner, false, FileTypeEnum::LICENCE_CMF()->getValue())->willReturn('foo');
  101. $this->filesystem->method('listKeys')->with('foo')->willReturn(['foo/a.txt', 'foo/b.pdf']);
  102. $this->assertEquals(
  103. ['foo/a.txt', 'foo/b.pdf'],
  104. $fileStorage->listByOwner($owner, FileTypeEnum::LICENCE_CMF())
  105. );
  106. }
  107. /**
  108. * @see LocalStorage::read()
  109. */
  110. public function testReadPdf(): void
  111. {
  112. $fileStorage = $this->getMockForMethod('read');
  113. $file = $this->getMockBuilder(File::class)->getMock();
  114. $file->method('getSlug')->willReturn('foo');
  115. $this->filesystem->method('read')->with('foo')->willReturn('12345679');
  116. $this->assertEquals(
  117. '12345679',
  118. $fileStorage->read($file)
  119. );
  120. }
  121. /**
  122. * @see LocalStorage::prepareFile()
  123. */
  124. public function testPrepareFile(): void
  125. {
  126. $fileStorage = $this->getMockForMethod('prepareFile');
  127. $owner = $this->getMockBuilder(Organization::class)->getMock();
  128. $author = $this->getMockBuilder(Access::class)->getMock();
  129. $author->method('getId')->willReturn(123);
  130. $fileStorage->method('getOrganizationAndPersonFromOwner')->with($owner)->willReturn([$owner, null]);
  131. $this->entityManager->expects(self::once())->method('persist');
  132. $this->entityManager->expects(self::once())->method('flush');
  133. $file = $fileStorage->prepareFile(
  134. $owner,
  135. 'file.ext',
  136. FileTypeEnum::LICENCE_CMF(),
  137. $author,
  138. true,
  139. 'ONLY_ORGANIZATION',
  140. 'application/pdf'
  141. );
  142. $this->assertEquals($owner, $file->getOrganization());
  143. $this->assertEquals(null, $file->getPerson());
  144. $this->assertEquals('file.ext', $file->getName());
  145. $this->assertEquals(null, $file->getSlug());
  146. $this->assertEquals(FileTypeEnum::LICENCE_CMF()->getValue(), $file->getType());
  147. $this->assertTrue($file->getIsTemporaryFile());
  148. $this->assertEquals('ONLY_ORGANIZATION', $file->getVisibility());
  149. $this->assertEquals('application/pdf', $file->getMimeType());
  150. $this->assertEquals(123, $file->getCreatedBy());
  151. }
  152. /**
  153. * @see LocalStorage::prepareFile()
  154. */
  155. public function testPrepareFileDefaultValues(): void
  156. {
  157. $fileStorage = $this->getMockForMethod('prepareFile');
  158. $owner = $this->getMockBuilder(Person::class)->getMock();
  159. $author = $this->getMockBuilder(Access::class)->getMock();
  160. $fileStorage->method('getOrganizationAndPersonFromOwner')->with($owner)->willReturn([null, $owner]);
  161. $this->entityManager->expects(self::once())->method('persist');
  162. $this->entityManager->expects(self::once())->method('flush');
  163. $this->fileUtils->method('guessMimeTypeFromFilename')->with('file.txt')->willReturn('text/plain');
  164. $file = $fileStorage->prepareFile($owner, 'file.txt', FileTypeEnum::NONE(), $author);
  165. $this->assertEquals(null, $file->getOrganization());
  166. $this->assertEquals($owner, $file->getPerson());
  167. $this->assertEquals('file.txt', $file->getName());
  168. $this->assertEquals(FileTypeEnum::NONE()->getValue(), $file->getType());
  169. $this->assertFalse($file->getIsTemporaryFile());
  170. $this->assertEquals('NOBODY', $file->getVisibility());
  171. $this->assertEquals('text/plain', $file->getMimeType());
  172. }
  173. /**
  174. * @see LocalStorage::prepareFile()
  175. */
  176. public function testPrepareFileNoFlush(): void
  177. {
  178. $fileStorage = $this->getMockForMethod('prepareFile');
  179. $owner = $this->getMockBuilder(Organization::class)->getMock();
  180. $author = $this->getMockBuilder(Access::class)->getMock();
  181. $fileStorage->method('getOrganizationAndPersonFromOwner')->with($owner)->willReturn([$owner, null]);
  182. $this->entityManager->expects(self::once())->method('persist');
  183. $this->entityManager->expects(self::never())->method('flush');
  184. $this->fileUtils->method('guessMimeTypeFromFilename')->willReturn('text/plain');
  185. $fileStorage->prepareFile(
  186. $owner,
  187. 'file.txt',
  188. FileTypeEnum::NONE(),
  189. $author,
  190. false,
  191. 'NOBODY',
  192. 'text/plain',
  193. false
  194. );
  195. }
  196. /**
  197. * @see LocalStorage::write()
  198. */
  199. public function testWriteNewFile(): void {
  200. $fileStorage = $this->getMockForMethod('write');
  201. $organization = $this->getMockBuilder(Organization::class)->getMock();
  202. $author = $this->getMockBuilder(Access::class)->getMock();
  203. $author->method('getId')->willReturn(123);
  204. $file = $this->getMockBuilder(File::class)->getMock();
  205. $file->method('getName')->willReturn('foo.txt');
  206. $file->method('getOrganization')->willReturn($organization);
  207. $file->method('getPerson')->willReturn(null);
  208. $file->method('getIsTemporaryFile')->willReturn(false);
  209. $file->method('getSlug')->willReturn(null);
  210. $file->method('getType')->willReturn(FileTypeEnum::NONE()->getValue());
  211. $fileStorage
  212. ->method('getPrefix')
  213. ->with($organization, false, FileTypeEnum::NONE()->getValue())
  214. ->willReturn('prefix/');
  215. $content = '123456789';
  216. $size = strlen($content);
  217. $this->filesystem
  218. ->expects(self::once())
  219. ->method('write')
  220. ->with(self::matchesRegularExpression('/^prefix\/\w{16,24}\/foo.txt/'), $content, true)
  221. ->willReturn($size);
  222. $file->expects(self::once())->method('setSize')->with($size)->willReturnSelf();
  223. $file->expects(self::once())->method('setStatus')->with(FileStatusEnum::READY()->getValue())->willReturnSelf();
  224. $file->expects(self::once())
  225. ->method('setSlug')
  226. ->with(self::matchesRegularExpression('/^prefix\/\w{16,24}\/foo.txt/'))
  227. ->willReturnSelf();
  228. $file->expects(self::once())->method('setCreateDate')->with(self::isInstanceOf(DateTime::class))->willReturnSelf();
  229. $file->expects(self::once())->method('setCreatedBy')->with(123)->willReturnSelf();
  230. $file->expects(self::never())->method('setUpdateDate');
  231. $file->expects(self::never())->method('setUpdatedBy');
  232. $this->entityManager->expects(self::once())->method('flush');
  233. $returned = $fileStorage->write($file, $content, $author);
  234. $this->assertSame($file, $returned);
  235. }
  236. /**
  237. * @see LocalStorage::write()
  238. */
  239. public function testWriteExistingFile(): void {
  240. $fileStorage = $this->getMockForMethod('write');
  241. $person = $this->getMockBuilder(Person::class)->getMock();
  242. $author = $this->getMockBuilder(Access::class)->getMock();
  243. $author->method('getId')->willReturn(123);
  244. $key = 'prefix/uid/bar.txt';
  245. $file = $this->getMockBuilder(File::class)->getMock();
  246. $file->method('getName')->willReturn('bar.txt');
  247. $file->method('getOrganization')->willReturn(null);
  248. $file->method('getPerson')->willReturn($person);
  249. $file->method('getIsTemporaryFile')->willReturn(true);
  250. $file->method('getSlug')->willReturn($key);
  251. $file->method('getType')->willReturn(FileTypeEnum::NONE()->getValue());
  252. $fileStorage->expects(self::never())->method('getPrefix');
  253. $content = '123 Soleil';
  254. $size = strlen($content);
  255. $this->filesystem
  256. ->expects(self::once())
  257. ->method('write')
  258. ->with($key, $content, true)
  259. ->willReturn($size);
  260. $this->filesystem->method('has')->with($key)->willReturn(true);
  261. $file->expects(self::once())->method('setSize')->with($size)->willReturnSelf();
  262. $file->expects(self::once())->method('setStatus')->with(FileStatusEnum::READY()->getValue())->willReturnSelf();
  263. $file->expects(self::never())->method('setSlug');
  264. $file->expects(self::never())->method('setCreateDate');
  265. $file->expects(self::never())->method('setCreatedBy');
  266. $file->expects(self::once())->method('setUpdateDate')->with(self::isInstanceOf(DateTime::class))->willReturnSelf();
  267. $file->expects(self::once())->method('setUpdatedBy')->with(123)->willReturnSelf();
  268. $this->entityManager->expects(self::once())->method('flush');
  269. $returned = $fileStorage->write($file, $content, $author);
  270. $this->assertEquals($file, $returned);
  271. }
  272. /**
  273. * @see LocalStorage::write()
  274. */
  275. public function testWriteExistingButMissingFile(): void
  276. {
  277. $fileStorage = $this->getMockForMethod('write');
  278. $person = $this->getMockBuilder(Person::class)->getMock();
  279. $author = $this->getMockBuilder(Access::class)->getMock();
  280. $key = 'prefix/uid/bar.txt';
  281. $file = $this->getMockBuilder(File::class)->getMock();
  282. $file->method('getName')->willReturn('bar.txt');
  283. $file->method('getOrganization')->willReturn(null);
  284. $file->method('getPerson')->willReturn($person);
  285. $file->method('getIsTemporaryFile')->willReturn(true);
  286. $file->method('getSlug')->willReturn($key);
  287. $file->method('getType')->willReturn(FileTypeEnum::NONE()->getValue());
  288. $this->filesystem->expects(self::never())->method('write');
  289. $this->entityManager->expects(self::never())->method('flush');
  290. $this->filesystem->method('has')->with($key)->willReturn(false);
  291. $this->expectException(RuntimeException::class);
  292. $this->expectExceptionMessage('The file `' . $key . '` does not exist in the file storage');
  293. $fileStorage->write($file, '12346', $author);
  294. }
  295. /**
  296. * @see LocalStorage::write()
  297. */
  298. public function testWriteWithAccessOwner(): void {
  299. $fileStorage = $this->getMockForMethod('write');
  300. $access = $this->getMockBuilder(Access::class)->getMock();
  301. $person = $this->getMockBuilder(Person::class)->getMock();
  302. $organization = $this->getMockBuilder(Organization::class)->getMock();
  303. $author = $this->getMockBuilder(Access::class)->getMock();
  304. $author->method('getId')->willReturn(123);
  305. $file = $this->getMockBuilder(File::class)->getMock();
  306. $file->method('getName')->willReturn('bar.txt');
  307. $file->method('getOrganization')->willReturn($organization);
  308. $file->method('getPerson')->willReturn($person);
  309. $file->method('getIsTemporaryFile')->willReturn(true);
  310. $file->method('getSlug')->willReturn(null);
  311. $file->method('getType')->willReturn(FileTypeEnum::NONE()->getValue());
  312. $this->accessRepository
  313. ->expects(self::once())
  314. ->method('findOneBy')
  315. ->with(['organization' => $organization, 'person' => $person])
  316. ->willReturn($access);
  317. $fileStorage
  318. ->expects(self::once())
  319. ->method('getPrefix')
  320. ->with($access, true, FileTypeEnum::NONE()->getValue())
  321. ->willReturn('prefix/');
  322. $content = '1';
  323. $this->filesystem->method('write')->willReturn(1);
  324. $fileStorage->write($file, $content, $author);
  325. }
  326. /**
  327. * @see LocalStorage::write()
  328. */
  329. public function testWriteWithNoName(): void
  330. {
  331. $fileStorage = $this->getMockForMethod('write');
  332. $author = $this->getMockBuilder(Access::class)->getMock();
  333. $file = $this->getMockBuilder(File::class)->getMock();
  334. $file->method('getName')->willReturn('');
  335. $this->expectException(RuntimeException::class);
  336. $this->expectExceptionMessage('File has no filename');
  337. $fileStorage->write($file, '...', $author);
  338. }
  339. /**
  340. * @see LocalStorage::makeFile()
  341. */
  342. public function testMakeFile(): void {
  343. $fileStorage = $this->getMockForMethod('makeFile');
  344. $organization = $this->getMockBuilder(Organization::class)->getMock();
  345. $author = $this->getMockBuilder(Access::class)->getMock();
  346. $file = $this->getMockBuilder(File::class)->getMock();
  347. $fileStorage
  348. ->expects(self::once())
  349. ->method('prepareFile')
  350. ->with($organization, 'foo.txt', FileTypeEnum::NONE(), $author, true, 'ONLY_ORGANIZATION', 'mime/type')
  351. ->willReturn($file);
  352. $fileStorage
  353. ->expects(self::once())
  354. ->method('write')
  355. ->with($file, '...', $author)
  356. ->willReturn($file);
  357. $fileStorage->makeFile(
  358. $organization,
  359. 'foo.txt',
  360. FileTypeEnum::NONE(),
  361. '...',
  362. $author,
  363. true,
  364. 'ONLY_ORGANIZATION',
  365. 'mime/type');
  366. }
  367. /**
  368. * @see LocalStorage::softDelete()
  369. */
  370. public function testSoftdelete(): void {
  371. $fileStorage = $this->getMockForMethod('softDelete');
  372. $author = $this->getMockBuilder(Access::class)->getMock();
  373. $author->method('getId')->willReturn(123);
  374. $file = $this->getMockBuilder(File::class)->getMock();
  375. $file->method('getSlug')->willReturn('key');
  376. $file->expects(self::once())->method('setStatus')->with(FileStatusEnum::DELETED()->getValue())->willReturnSelf();
  377. $file->expects(self::once())->method('setSize')->with(0)->willReturnSelf();
  378. $file->expects(self::once())->method('setUpdatedBy')->with(123)->willReturnSelf();
  379. $returned = $fileStorage->softDelete($file, $author);
  380. $this->assertEquals($file, $returned);
  381. }
  382. /**
  383. * @see LocalStorage::hardDelete()
  384. */
  385. public function testHardDelete(): void {
  386. $fileStorage = $this->getMockForMethod('hardDelete');
  387. $file = $this->getMockBuilder(File::class)->getMock();
  388. $file->method('getSlug')->willReturn('key');
  389. $this->filesystem->expects(self::once())->method('delete')->with('key')->willReturn(true);
  390. $fileStorage->hardDelete($file);
  391. }
  392. /**
  393. * @see LocalStorage::hardDelete()
  394. */
  395. public function testHardDeleteFailed(): void {
  396. $fileStorage = $this->getMockForMethod('hardDelete');
  397. $file = $this->getMockBuilder(File::class)->getMock();
  398. $file->method('getSlug')->willReturn('key');
  399. $this->filesystem->expects(self::once())->method('delete')->with('key')->willReturn(false);
  400. $this->expectException(RuntimeException::class);
  401. $this->expectExceptionMessage('File `' . $file->getSlug() . '` could\'nt be deleted');
  402. $fileStorage->hardDelete($file);
  403. }
  404. /**
  405. * @see LocalStorage::getPrefix()
  406. */
  407. public function testGetPrefixAccess(): void {
  408. $fileStorage = $this->getMockForMethod('getPrefix');
  409. $organization = $this->getMockBuilder(Organization::class)->getMock();
  410. $organization->method('getId')->willReturn(2);
  411. $access = $this->getMockBuilder(Access::class)->getMock();
  412. $access->method('getOrganization')->willReturn($organization);
  413. $access->method('getId')->willReturn(1);
  414. $prefix = $fileStorage->getPrefix($access, false);
  415. $this->assertEquals('organization/2/1', $prefix);
  416. }
  417. /**
  418. * @see LocalStorage::getPrefix()
  419. */
  420. public function testGetPrefixOrganization(): void {
  421. $fileStorage = $this->getMockForMethod('getPrefix');
  422. $organization = $this->getMockBuilder(Organization::class)->getMock();
  423. $organization->method('getId')->willReturn(1);
  424. $prefix = $fileStorage->getPrefix($organization, false);
  425. $this->assertEquals('organization/1', $prefix);
  426. }
  427. /**
  428. * @see LocalStorage::getPrefix()
  429. */
  430. public function testGetPrefixPerson(): void {
  431. $fileStorage = $this->getMockForMethod('getPrefix');
  432. $person = $this->getMockBuilder(Person::class)->getMock();
  433. $person->method('getId')->willReturn(1);
  434. $prefix = $fileStorage->getPrefix($person, false);
  435. $this->assertEquals('person/1', $prefix);
  436. }
  437. /**
  438. * @see LocalStorage::getPrefix()
  439. */
  440. public function testGetPrefixTemp(): void {
  441. $fileStorage = $this->getMockForMethod('getPrefix');
  442. $organization = $this->getMockBuilder(Organization::class)->getMock();
  443. $organization->method('getId')->willReturn(1);
  444. $prefix = $fileStorage->getPrefix($organization, true);
  445. $this->assertEquals('temp/organization/1', $prefix);
  446. }
  447. /**
  448. * @see LocalStorage::getPrefix()
  449. */
  450. public function testGetPrefixWithType(): void {
  451. $fileStorage = $this->getMockForMethod('getPrefix');
  452. $organization = $this->getMockBuilder(Organization::class)->getMock();
  453. $organization->method('getId')->willReturn(1);
  454. $prefix = $fileStorage->getPrefix($organization, false, FileTypeEnum::LICENCE_CMF()->getValue());
  455. $this->assertEquals('organization/1/licence_cmf', $prefix);
  456. }
  457. /**
  458. * @see LocalStorage::getOrganizationAndPersonFromOwner()
  459. */
  460. public function testGetOrganizationAndPersonFromOwner(): void {
  461. $fileStorage = $this->getMockForMethod('getOrganizationAndPersonFromOwner');
  462. $organization = $this->getMockBuilder(Organization::class)->getMock();
  463. $organization->method('getId')->willReturn(2);
  464. $person = $this->getMockBuilder(Person::class)->getMock();
  465. $person->method('getId')->willReturn(1);
  466. $access = $this->getMockBuilder(Access::class)->getMock();
  467. $access->method('getOrganization')->willReturn($organization);
  468. $access->method('getPerson')->willReturn($person);
  469. $access->method('getId')->willReturn(1);
  470. $this->assertEquals([$organization, $person], $fileStorage->getOrganizationAndPersonFromOwner($access));
  471. $this->assertEquals([$organization, null], $fileStorage->getOrganizationAndPersonFromOwner($organization));
  472. $this->assertEquals([null, $person], $fileStorage->getOrganizationAndPersonFromOwner($person));
  473. }
  474. }