@@ -22,99 +22,99 @@ |
||
| 22 | 22 | use Test\TestCase; |
| 23 | 23 | |
| 24 | 24 | class LoadAdditionalListenerTest extends TestCase { |
| 25 | - protected LoggerInterface&MockObject $logger; |
|
| 26 | - protected LoadAdditionalScriptsEvent&MockObject $event; |
|
| 27 | - protected IManager&MockObject $shareManager; |
|
| 28 | - protected IFactory&MockObject $factory; |
|
| 29 | - protected InitialStateService&MockObject $initialStateService; |
|
| 30 | - protected IConfig&MockObject $config; |
|
| 31 | - |
|
| 32 | - protected function setUp(): void { |
|
| 33 | - parent::setUp(); |
|
| 34 | - |
|
| 35 | - $this->logger = $this->createMock(LoggerInterface::class); |
|
| 36 | - $this->event = $this->createMock(LoadAdditionalScriptsEvent::class); |
|
| 37 | - $this->shareManager = $this->createMock(IManager::class); |
|
| 38 | - $this->factory = $this->createMock(IFactory::class); |
|
| 39 | - $this->initialStateService = $this->createMock(InitialStateService::class); |
|
| 40 | - $this->config = $this->createMock(IConfig::class); |
|
| 41 | - |
|
| 42 | - /* Empty static array to avoid inter-test conflicts */ |
|
| 43 | - \OC_Util::$styles = []; |
|
| 44 | - self::invokePrivate(Util::class, 'scripts', [[]]); |
|
| 45 | - self::invokePrivate(Util::class, 'scriptDeps', [[]]); |
|
| 46 | - self::invokePrivate(Util::class, 'scriptsInit', [[]]); |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - protected function tearDown(): void { |
|
| 50 | - parent::tearDown(); |
|
| 51 | - |
|
| 52 | - \OC_Util::$styles = []; |
|
| 53 | - self::invokePrivate(Util::class, 'scripts', [[]]); |
|
| 54 | - self::invokePrivate(Util::class, 'scriptDeps', [[]]); |
|
| 55 | - self::invokePrivate(Util::class, 'scriptsInit', [[]]); |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - public function testHandleIgnoresNonMatchingEvent(): void { |
|
| 59 | - $listener = new LoadAdditionalListener(); |
|
| 60 | - $event = $this->createMock(Event::class); |
|
| 61 | - |
|
| 62 | - // Should not throw or call anything |
|
| 63 | - $listener->handle($event); |
|
| 64 | - |
|
| 65 | - $this->assertTrue(true); // No exception means pass |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - public function testHandleWithLoadAdditionalScriptsEvent(): void { |
|
| 69 | - $listener = new LoadAdditionalListener(); |
|
| 70 | - |
|
| 71 | - $this->shareManager->method('shareApiEnabled')->willReturn(false); |
|
| 72 | - $this->factory->method('findLanguage')->willReturn('language_mock'); |
|
| 73 | - $this->config->method('getSystemValueBool')->willReturn(true); |
|
| 74 | - |
|
| 75 | - $this->overwriteService(IManager::class, $this->shareManager); |
|
| 76 | - $this->overwriteService(IFactory::class, $this->factory); |
|
| 77 | - $this->overwriteService(InitialStateService::class, $this->initialStateService); |
|
| 78 | - $this->overwriteService(IConfig::class, $this->config); |
|
| 79 | - |
|
| 80 | - $scriptsBefore = Util::getScripts(); |
|
| 81 | - $this->assertNotContains('files_sharing/l10n/language_mock', $scriptsBefore); |
|
| 82 | - $this->assertNotContains('files_sharing/js/additionalScripts', $scriptsBefore); |
|
| 83 | - $this->assertNotContains('files_sharing/js/init', $scriptsBefore); |
|
| 84 | - $this->assertNotContains('files_sharing/css/icons', \OC_Util::$styles); |
|
| 85 | - |
|
| 86 | - // Util static methods can't be easily mocked, so just ensure no exceptions |
|
| 87 | - $listener->handle($this->event); |
|
| 88 | - |
|
| 89 | - // assert array $scripts contains the expected scripts |
|
| 90 | - $scriptsAfter = Util::getScripts(); |
|
| 91 | - $this->assertContains('files_sharing/l10n/language_mock', $scriptsAfter); |
|
| 92 | - $this->assertContains('files_sharing/js/additionalScripts', $scriptsAfter); |
|
| 93 | - $this->assertNotContains('files_sharing/js/init', $scriptsAfter); |
|
| 94 | - |
|
| 95 | - $this->assertContains('files_sharing/css/icons', \OC_Util::$styles); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - public function testHandleWithLoadAdditionalScriptsEventWithShareApiEnabled(): void { |
|
| 99 | - $listener = new LoadAdditionalListener(); |
|
| 100 | - |
|
| 101 | - $this->shareManager->method('shareApiEnabled')->willReturn(true); |
|
| 102 | - $this->config->method('getSystemValueBool')->willReturn(true); |
|
| 103 | - |
|
| 104 | - $this->overwriteService(IManager::class, $this->shareManager); |
|
| 105 | - $this->overwriteService(InitialStateService::class, $this->initialStateService); |
|
| 106 | - $this->overwriteService(IConfig::class, $this->config); |
|
| 107 | - $this->overwriteService(IFactory::class, $this->factory); |
|
| 108 | - |
|
| 109 | - $scriptsBefore = Util::getScripts(); |
|
| 110 | - $this->assertNotContains('files_sharing/js/init', $scriptsBefore); |
|
| 111 | - |
|
| 112 | - // Util static methods can't be easily mocked, so just ensure no exceptions |
|
| 113 | - $listener->handle($this->event); |
|
| 114 | - |
|
| 115 | - $scriptsAfter = Util::getScripts(); |
|
| 116 | - |
|
| 117 | - // assert array $scripts contains the expected scripts |
|
| 118 | - $this->assertContains('files_sharing/js/init', $scriptsAfter); |
|
| 119 | - } |
|
| 25 | + protected LoggerInterface&MockObject $logger; |
|
| 26 | + protected LoadAdditionalScriptsEvent&MockObject $event; |
|
| 27 | + protected IManager&MockObject $shareManager; |
|
| 28 | + protected IFactory&MockObject $factory; |
|
| 29 | + protected InitialStateService&MockObject $initialStateService; |
|
| 30 | + protected IConfig&MockObject $config; |
|
| 31 | + |
|
| 32 | + protected function setUp(): void { |
|
| 33 | + parent::setUp(); |
|
| 34 | + |
|
| 35 | + $this->logger = $this->createMock(LoggerInterface::class); |
|
| 36 | + $this->event = $this->createMock(LoadAdditionalScriptsEvent::class); |
|
| 37 | + $this->shareManager = $this->createMock(IManager::class); |
|
| 38 | + $this->factory = $this->createMock(IFactory::class); |
|
| 39 | + $this->initialStateService = $this->createMock(InitialStateService::class); |
|
| 40 | + $this->config = $this->createMock(IConfig::class); |
|
| 41 | + |
|
| 42 | + /* Empty static array to avoid inter-test conflicts */ |
|
| 43 | + \OC_Util::$styles = []; |
|
| 44 | + self::invokePrivate(Util::class, 'scripts', [[]]); |
|
| 45 | + self::invokePrivate(Util::class, 'scriptDeps', [[]]); |
|
| 46 | + self::invokePrivate(Util::class, 'scriptsInit', [[]]); |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + protected function tearDown(): void { |
|
| 50 | + parent::tearDown(); |
|
| 51 | + |
|
| 52 | + \OC_Util::$styles = []; |
|
| 53 | + self::invokePrivate(Util::class, 'scripts', [[]]); |
|
| 54 | + self::invokePrivate(Util::class, 'scriptDeps', [[]]); |
|
| 55 | + self::invokePrivate(Util::class, 'scriptsInit', [[]]); |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + public function testHandleIgnoresNonMatchingEvent(): void { |
|
| 59 | + $listener = new LoadAdditionalListener(); |
|
| 60 | + $event = $this->createMock(Event::class); |
|
| 61 | + |
|
| 62 | + // Should not throw or call anything |
|
| 63 | + $listener->handle($event); |
|
| 64 | + |
|
| 65 | + $this->assertTrue(true); // No exception means pass |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + public function testHandleWithLoadAdditionalScriptsEvent(): void { |
|
| 69 | + $listener = new LoadAdditionalListener(); |
|
| 70 | + |
|
| 71 | + $this->shareManager->method('shareApiEnabled')->willReturn(false); |
|
| 72 | + $this->factory->method('findLanguage')->willReturn('language_mock'); |
|
| 73 | + $this->config->method('getSystemValueBool')->willReturn(true); |
|
| 74 | + |
|
| 75 | + $this->overwriteService(IManager::class, $this->shareManager); |
|
| 76 | + $this->overwriteService(IFactory::class, $this->factory); |
|
| 77 | + $this->overwriteService(InitialStateService::class, $this->initialStateService); |
|
| 78 | + $this->overwriteService(IConfig::class, $this->config); |
|
| 79 | + |
|
| 80 | + $scriptsBefore = Util::getScripts(); |
|
| 81 | + $this->assertNotContains('files_sharing/l10n/language_mock', $scriptsBefore); |
|
| 82 | + $this->assertNotContains('files_sharing/js/additionalScripts', $scriptsBefore); |
|
| 83 | + $this->assertNotContains('files_sharing/js/init', $scriptsBefore); |
|
| 84 | + $this->assertNotContains('files_sharing/css/icons', \OC_Util::$styles); |
|
| 85 | + |
|
| 86 | + // Util static methods can't be easily mocked, so just ensure no exceptions |
|
| 87 | + $listener->handle($this->event); |
|
| 88 | + |
|
| 89 | + // assert array $scripts contains the expected scripts |
|
| 90 | + $scriptsAfter = Util::getScripts(); |
|
| 91 | + $this->assertContains('files_sharing/l10n/language_mock', $scriptsAfter); |
|
| 92 | + $this->assertContains('files_sharing/js/additionalScripts', $scriptsAfter); |
|
| 93 | + $this->assertNotContains('files_sharing/js/init', $scriptsAfter); |
|
| 94 | + |
|
| 95 | + $this->assertContains('files_sharing/css/icons', \OC_Util::$styles); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + public function testHandleWithLoadAdditionalScriptsEventWithShareApiEnabled(): void { |
|
| 99 | + $listener = new LoadAdditionalListener(); |
|
| 100 | + |
|
| 101 | + $this->shareManager->method('shareApiEnabled')->willReturn(true); |
|
| 102 | + $this->config->method('getSystemValueBool')->willReturn(true); |
|
| 103 | + |
|
| 104 | + $this->overwriteService(IManager::class, $this->shareManager); |
|
| 105 | + $this->overwriteService(InitialStateService::class, $this->initialStateService); |
|
| 106 | + $this->overwriteService(IConfig::class, $this->config); |
|
| 107 | + $this->overwriteService(IFactory::class, $this->factory); |
|
| 108 | + |
|
| 109 | + $scriptsBefore = Util::getScripts(); |
|
| 110 | + $this->assertNotContains('files_sharing/js/init', $scriptsBefore); |
|
| 111 | + |
|
| 112 | + // Util static methods can't be easily mocked, so just ensure no exceptions |
|
| 113 | + $listener->handle($this->event); |
|
| 114 | + |
|
| 115 | + $scriptsAfter = Util::getScripts(); |
|
| 116 | + |
|
| 117 | + // assert array $scripts contains the expected scripts |
|
| 118 | + $this->assertContains('files_sharing/js/init', $scriptsAfter); |
|
| 119 | + } |
|
| 120 | 120 | } |
@@ -8,15 +8,15 @@ |
||
| 8 | 8 | require_once __DIR__ . '/../lib/base.php'; |
| 9 | 9 | |
| 10 | 10 | function enableApp($app) { |
| 11 | - (new \OC_App())->enable($app); |
|
| 12 | - echo "Enabled application {$app}\n"; |
|
| 11 | + (new \OC_App())->enable($app); |
|
| 12 | + echo "Enabled application {$app}\n"; |
|
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | foreach (new \DirectoryIterator(__DIR__ . '/../apps/') as $file) { |
| 16 | - if ($file->isDot()) { |
|
| 17 | - continue; |
|
| 18 | - } |
|
| 19 | - if (!file_exists($file->getPathname() . '/.git')) { |
|
| 20 | - enableApp($file->getFilename()); |
|
| 21 | - } |
|
| 16 | + if ($file->isDot()) { |
|
| 17 | + continue; |
|
| 18 | + } |
|
| 19 | + if (!file_exists($file->getPathname() . '/.git')) { |
|
| 20 | + enableApp($file->getFilename()); |
|
| 21 | + } |
|
| 22 | 22 | } |
@@ -5,18 +5,18 @@ |
||
| 5 | 5 | * SPDX-License-Identifier: AGPL-3.0-or-later |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -require_once __DIR__ . '/../lib/base.php'; |
|
| 8 | +require_once __DIR__.'/../lib/base.php'; |
|
| 9 | 9 | |
| 10 | 10 | function enableApp($app) { |
| 11 | 11 | (new \OC_App())->enable($app); |
| 12 | 12 | echo "Enabled application {$app}\n"; |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | -foreach (new \DirectoryIterator(__DIR__ . '/../apps/') as $file) { |
|
| 15 | +foreach (new \DirectoryIterator(__DIR__.'/../apps/') as $file) { |
|
| 16 | 16 | if ($file->isDot()) { |
| 17 | 17 | continue; |
| 18 | 18 | } |
| 19 | - if (!file_exists($file->getPathname() . '/.git')) { |
|
| 19 | + if (!file_exists($file->getPathname().'/.git')) { |
|
| 20 | 20 | enableApp($file->getFilename()); |
| 21 | 21 | } |
| 22 | 22 | } |