File tree Expand file tree Collapse file tree 3 files changed +10
-1
lines changed
plugins/filesystem/local/src
tests/Unit/Plugin/Filesystem/Local/Extension Expand file tree Collapse file tree 3 files changed +10
-1
lines changed Original file line number Diff line number Diff line change 2222use Joomla \CMS \Language \Text ;
2323use Joomla \CMS \String \PunycodeHelper ;
2424use Joomla \CMS \Uri \Uri ;
25+ use Joomla \CMS \User \CurrentUserTrait ;
2526use Joomla \Component \Media \Administrator \Adapter \AdapterInterface ;
2627use Joomla \Component \Media \Administrator \Exception \FileNotFoundException ;
2728use Joomla \Component \Media \Administrator \Exception \InvalidPathException ;
3738 */
3839class LocalAdapter implements AdapterInterface
3940{
41+ use CurrentUserTrait;
42+
4043 /**
4144 * The root path to gather file information from.
4245 *
@@ -430,7 +433,7 @@ private function getDate($date = null): Date
430433 $ dateObj = Factory::getDate ($ date );
431434
432435 $ timezone = Factory::getApplication ()->get ('offset ' );
433- $ user = Factory:: getUser ();
436+ $ user = $ this -> getCurrentUser ();
434437
435438 if ($ user ->id ) {
436439 $ userTimezone = $ user ->getParam ('timezone ' );
Original file line number Diff line number Diff line change @@ -133,6 +133,7 @@ public function getAdapters()
133133 $ directoryEntity ->thumbs ,
134134 [200 , 200 ]
135135 );
136+ $ adapter ->setCurrentUser ($ this ->getApplication ()->getIdentity ());
136137
137138 $ adapters [$ adapter ->getAdapterName ()] = $ adapter ;
138139 }
Original file line number Diff line number Diff line change 1313use InvalidArgumentException ;
1414use Joomla \CMS \Application \CMSApplicationInterface ;
1515use Joomla \CMS \Language \Language ;
16+ use Joomla \CMS \User \User ;
1617use Joomla \Component \Media \Administrator \Event \MediaProviderEvent ;
1718use Joomla \Component \Media \Administrator \Provider \ProviderManager ;
1819use Joomla \Event \Dispatcher ;
@@ -104,7 +105,11 @@ public function testAdapters()
104105 {
105106 $ dispatcher = new Dispatcher ();
106107
108+ $ app = $ this ->createStub (CMSApplicationInterface::class);
109+ $ app ->method ('getIdentity ' )->willReturn (new User ());
110+
107111 $ plugin = new Local ($ dispatcher , ['params ' => ['directories ' => '[{"directory": "tests"}] ' ]], JPATH_ROOT );
112+ $ plugin ->setApplication ($ app );
108113 $ adapters = $ plugin ->getAdapters ();
109114
110115 $ this ->assertCount (1 , $ adapters );
You can’t perform that action at this time.
0 commit comments