2929use OCA \User_LDAP \AccessFactory ;
3030use OCA \User_LDAP \Connection ;
3131use OCA \User_LDAP \Helper ;
32+ use OCA \User_LDAP \ILDAPWrapper ;
3233use Symfony \Component \Console \Command \Command ;
3334use Symfony \Component \Console \Input \InputArgument ;
3435use Symfony \Component \Console \Input \InputInterface ;
@@ -40,29 +41,35 @@ class TestConfig extends Command {
4041 protected const BINDFAILURE = 2 ;
4142 protected const SEARCHFAILURE = 3 ;
4243
43- /** @var AccessFactory */
44- protected $ accessFactory ;
44+ protected AccessFactory $ accessFactory ;
45+ protected Helper $ helper ;
46+ protected ILDAPWrapper $ ldap ;
4547
46- public function __construct (AccessFactory $ accessFactory ) {
48+ public function __construct (
49+ AccessFactory $ accessFactory ,
50+ Helper $ helper ,
51+ ILDAPWrapper $ ldap
52+ ) {
4753 $ this ->accessFactory = $ accessFactory ;
54+ $ this ->helper = $ helper ;
55+ $ this ->ldap = $ ldap ;
4856 parent ::__construct ();
4957 }
5058
51- protected function configure () {
59+ protected function configure (): void {
5260 $ this
5361 ->setName ('ldap:test-config ' )
5462 ->setDescription ('tests an LDAP configuration ' )
5563 ->addArgument (
56- 'configID ' ,
57- InputArgument::REQUIRED ,
58- 'the configuration ID '
59- )
64+ 'configID ' ,
65+ InputArgument::REQUIRED ,
66+ 'the configuration ID '
67+ )
6068 ;
6169 }
6270
6371 protected function execute (InputInterface $ input , OutputInterface $ output ): int {
64- $ helper = new Helper (\OC ::$ server ->getConfig (), \OC ::$ server ->getDatabaseConnection ());
65- $ availableConfigs = $ helper ->getServerConfigurationPrefixes ();
72+ $ availableConfigs = $ this ->helper ->getServerConfigurationPrefixes ();
6673 $ configID = $ input ->getArgument ('configID ' );
6774 if (!in_array ($ configID , $ availableConfigs )) {
6875 $ output ->writeln ('Invalid configID ' );
@@ -94,8 +101,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
94101 * Tests the specified connection
95102 */
96103 protected function testConfig (string $ configID ): int {
97- $ lw = new \OCA \User_LDAP \LDAP ();
98- $ connection = new Connection ($ lw , $ configID );
104+ $ connection = new Connection ($ this ->ldap , $ configID );
99105
100106 // Ensure validation is run before we attempt the bind
101107 $ connection ->getConfiguration ();
0 commit comments