diff --git a/features/bootstrap/GuiContext.php b/features/bootstrap/GuiContext.php index 1c44f983b5..e5b9fd0662 100644 --- a/features/bootstrap/GuiContext.php +++ b/features/bootstrap/GuiContext.php @@ -123,4 +123,51 @@ class GuiContext extends MinkContext { $this->app['phraseanet.registry']->set('GV_captchas', false, \registry::TYPE_BOOLEAN); } + + /** + * @Given /^user registration is enable$/ + */ + public function userRegistrationIsEnable() + { + $databox = current($this->app['phraseanet.appbox']->get_databoxes()); + + $xml = $databox->get_sxml_structure(); + + if (!$xml) { + throw new \Exception('Invalid databox xml structure'); + } + + if (!isset($xml->caninscript)) { + + $xml->addChild('caninscript', '1'); + + $dom = new \DOMDocument(); + $dom->loadXML($xml->asXML()); + + $databox->saveStructure($dom); + } + } + + /** + * @Given /^user registration is disable/ + */ + public function userRegistrationIsDisable() + { + $databox = current($this->app['phraseanet.appbox']->get_databoxes()); + + $xml = $databox->get_sxml_structure(); + + if (!$xml) { + throw new \Exception('Invalid databox xml structure'); + } + + if (isset($xml->caninscript)) { + unset($xml->caninscript); + + $dom = new \DOMDocument(); + $dom->loadXML($xml->asXML()); + + $databox->saveStructure($dom); + } + } } diff --git a/features/register.feature b/features/register.feature new file mode 100644 index 0000000000..6225c9746a --- /dev/null +++ b/features/register.feature @@ -0,0 +1,28 @@ +Feature: Register + In order to register myself into the application + As a non authenticated user + I need to be able to submit a register form + +Scenario: Give access to register page + Given user registration is enable + And I am not authenticated + And I am on "/login/" + Then I should see an "a#link-register" element + +Scenario: Restrict access to register page if registration is not enable + Given user registration is disable + And I am not authenticated + And I am on "/login/register/" + Then I should see "Registration is not available" + +Scenario: Register form is displayed + Given user registration is enable + And I am not authenticated + And I am on "/login/register/" + Then I should see an "a#register-classic" element + When I follow "a#register-classic" + Then I should see "firstName" + And I should see "lastName" + And I should see "email" + And I should see "job" + And I should see "company" \ No newline at end of file