diff options
Diffstat (limited to 'tests/integration/features/bootstrap/FeatureContext.php')
-rw-r--r-- | tests/integration/features/bootstrap/FeatureContext.php | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php index 321a4de..6b9cfb9 100644 --- a/tests/integration/features/bootstrap/FeatureContext.php +++ b/tests/integration/features/bootstrap/FeatureContext.php @@ -12,10 +12,26 @@ use GuzzleHttp\Message\ResponseInterface; * Defines application features from the specific context. */ class FeatureContext implements Context, SnippetAcceptingContext { + use BasicStructure; use Provisioning; /** + * @Given /^list of notifiers (is|is not) empty$/ + */ + public function hasNotifiers($noNotifiers) { + if ($noNotifiers === 'is') { + $response = $this->setTestingValue('DELETE', 'apps/notifications/testing/notifiers', null); + PHPUnit_Framework_Assert::assertEquals(200, $response->getStatusCode()); + PHPUnit_Framework_Assert::assertEquals(200, (int) $this->getOCSResponse($response)); + } else { + $response = $this->setTestingValue('POST', 'apps/notifications/testing/notifiers', null); + PHPUnit_Framework_Assert::assertEquals(200, $response->getStatusCode()); + PHPUnit_Framework_Assert::assertEquals(200, (int) $this->getOCSResponse($response)); + } + } + + /** * @BeforeSuite */ public static function addFilesToSkeleton() { @@ -28,4 +44,31 @@ class FeatureContext implements Context, SnippetAcceptingContext { public static function removeFilesFromSkeleton() { // The path to the skeleton files does not match, and we don't need them } + + /** + * @AfterScenario + */ + public function removeDebugConfigs() { + $response = $this->setTestingValue('DELETE', 'apps/notifications/testing', null); + PHPUnit_Framework_Assert::assertEquals(200, $response->getStatusCode()); + PHPUnit_Framework_Assert::assertEquals(200, (int) $this->getOCSResponse($response)); + } + + protected function setTestingValue($verb, $url, $body) { + $fullUrl = $this->baseUrl . "v2.php/" . $url; + $client = new Client(); + $options = [ + 'auth' => $this->adminUser, + ]; + if ($body instanceof \Behat\Gherkin\Node\TableNode) { + $fd = $body->getRowsHash(); + $options['body'] = $fd; + } + + try { + return $client->send($client->createRequest($verb, $fullUrl, $options)); + } catch (\GuzzleHttp\Exception\ClientException $ex) { + return $ex->getResponse(); + } + } } |