diff --git a/build/integration/features/bootstrap/Provisioning.php b/build/integration/features/bootstrap/Provisioning.php index 935ad2a4a1d..1d0984abd72 100644 --- a/build/integration/features/bootstrap/Provisioning.php +++ b/build/integration/features/bootstrap/Provisioning.php @@ -803,13 +803,8 @@ trait Provisioning { return $extractedElementsArray; } - - /** - * @Given /^app "([^"]*)" is disabled$/ - * @param string $app - */ - public function appIsDisabled($app) { - $fullUrl = $this->baseUrl . 'v2.php/cloud/apps?filter=disabled'; + private function getAppsWithFilter($filter) { + $fullUrl = $this->baseUrl . 'v2.php/cloud/apps?filter=' . $filter; $client = new Client(); $options = []; if ($this->currentUser === 'admin') { @@ -820,7 +815,15 @@ trait Provisioning { ]; $this->response = $client->get($fullUrl, $options); - $respondedArray = $this->getArrayOfAppsResponded($this->response); + return $this->getArrayOfAppsResponded($this->response); + } + + /** + * @Given /^app "([^"]*)" is disabled$/ + * @param string $app + */ + public function appIsDisabled($app) { + $respondedArray = $this->getAppsWithFilter('disabled'); Assert::assertContains($app, $respondedArray); Assert::assertEquals(200, $this->response->getStatusCode()); } @@ -830,18 +833,7 @@ trait Provisioning { * @param string $app */ public function appIsEnabled($app) { - $fullUrl = $this->baseUrl . 'v2.php/cloud/apps?filter=enabled'; - $client = new Client(); - $options = []; - if ($this->currentUser === 'admin') { - $options['auth'] = $this->adminUser; - } - $options['headers'] = [ - 'OCS-APIREQUEST' => 'true', - ]; - - $this->response = $client->get($fullUrl, $options); - $respondedArray = $this->getArrayOfAppsResponded($this->response); + $respondedArray = $this->getAppsWithFilter('enabled'); Assert::assertContains($app, $respondedArray); Assert::assertEquals(200, $this->response->getStatusCode()); } @@ -854,18 +846,7 @@ trait Provisioning { * @param string $app */ public function appIsNotEnabled($app) { - $fullUrl = $this->baseUrl . 'v2.php/cloud/apps?filter=enabled'; - $client = new Client(); - $options = []; - if ($this->currentUser === 'admin') { - $options['auth'] = $this->adminUser; - } - $options['headers'] = [ - 'OCS-APIREQUEST' => 'true', - ]; - - $this->response = $client->get($fullUrl, $options); - $respondedArray = $this->getArrayOfAppsResponded($this->response); + $respondedArray = $this->getAppsWithFilter('enabled'); Assert::assertNotContains($app, $respondedArray); Assert::assertEquals(200, $this->response->getStatusCode()); }