protected function execute(InputInterface $input, OutputInterface $output) { $authBackends = $this->backendService->getAuthMechanisms(); $storageBackends = $this->backendService->getBackends(); $data = ['authentication' => array_map([$this, 'serializeAuthBackend'], $authBackends), 'storage' => array_map([$this, 'serializeAuthBackend'], $storageBackends)]; $type = $input->getArgument('type'); $backend = $input->getArgument('backend'); if ($type) { if (!isset($data[$type])) { $output->writeln('<error>Invalid type "' . $type . '". Possible values are "authentication" or "storage"</error>'); return 1; } $data = $data[$type]; if ($backend) { if (!isset($data[$backend])) { $output->writeln('<error>Unknown backend "' . $backend . '" of type "' . $type . '"</error>'); return 1; } $data = $data[$backend]; } } $this->writeArrayInOutputFormat($input, $output, $data); }
public function testAuthMechanismProvider() { $service = new BackendService($this->config, $this->l10n); $backend1 = $this->getAuthMechanismMock('\\Foo\\Bar'); $backend2 = $this->getAuthMechanismMock('\\Bar\\Foo'); $providerMock = $this->getMock('\\OCA\\Files_External\\Lib\\Config\\IAuthMechanismProvider'); $providerMock->expects($this->once())->method('getAuthMechanisms')->willReturn([$backend1, $backend2]); $service->registerAuthMechanismProvider($providerMock); $this->assertEquals($backend1, $service->getAuthMechanism('identifier:\\Foo\\Bar')); $this->assertEquals($backend2, $service->getAuthMechanism('identifier:\\Bar\\Foo')); $this->assertCount(2, $service->getAuthMechanisms()); }