Permalink
Browse files

API remove base_url context parameter

use MinkExtension base_url instead
  • Loading branch information...
1 parent 07eba2f commit c1a078e76a43e5cc069661bf25cde80d2dc89e59 @michalochman committed Aug 8, 2012
View
1 behat.yml
@@ -2,7 +2,6 @@
default:
context:
parameters:
- base_url: http://localhost
admin_url: /admin/
login_url: /Security/login
screenshot_path: features/screenshots/
View
2 features/bootstrap/SilverStripe/Test/Behaviour/BasicContext.php
@@ -188,7 +188,7 @@ public function stepIShouldBeRedirectedTo($url)
$client->followRedirects(true);
$client->followRedirect();
- $url = $this->getMainContext()->joinUrlParts($this->context['base_url'], $url);
+ $url = $this->getMainContext()->joinUrlParts($this->getMainContext()->getBaseUrl(), $url);
assertTrue($this->getMainContext()->isCurrentUrlSimilarTo($url), sprintf('Current URL is not %s', $url));
}
View
6 features/bootstrap/SilverStripe/Test/Behaviour/LoginContext.php
@@ -53,8 +53,8 @@ public function getSession($name = null)
*/
public function stepIAmLoggedIn()
{
- $admin_url = $this->getMainContext()->joinUrlParts($this->context['base_url'], $this->context['admin_url']);
- $login_url = $this->getMainContext()->joinUrlParts($this->context['base_url'], $this->context['login_url']);
+ $admin_url = $this->getMainContext()->joinUrlParts($this->getMainContext()->getBaseUrl(), $this->context['admin_url']);
+ $login_url = $this->getMainContext()->joinUrlParts($this->getMainContext()->getBaseUrl(), $this->context['login_url']);
$this->getSession()->visit($admin_url);
@@ -111,7 +111,7 @@ public function stepIAmNotLoggedIn()
*/
public function stepILogInWith($email, $password)
{
- $login_url = $this->getMainContext()->joinUrlParts($this->context['base_url'], $this->context['login_url']);
+ $login_url = $this->getMainContext()->joinUrlParts($this->getMainContext()->getBaseUrl(), $this->context['login_url']);
$this->getSession()->visit($login_url);
View
14 features/bootstrap/SilverStripe/Test/Behaviour/SilverStripeContext.php
@@ -74,7 +74,7 @@ public function before(ScenarioEvent $event)
throw new \LogicException('Context\'s $database_name has to be set when implementing SilverStripeAwareContextInterface.');
}
- $setdb_url = $this->joinUrlParts($this->context['base_url'], '/dev/tests/setdb');
+ $setdb_url = $this->joinUrlParts($this->getBaseUrl(), '/dev/tests/setdb');
$setdb_url = sprintf('%s?database=%s', $setdb_url, $this->database_name);
$this->getSession()->visit($setdb_url);
}
@@ -299,6 +299,18 @@ public function isCurrentUrlSimilarTo($url)
}
/**
+ * Returns base URL parameter set in MinkExtension.
+ * It simplifies configuration by allowing to specify this parameter
+ * once but makes code dependent on MinkExtension.
+ *
+ * @return string
+ */
+ public function getBaseUrl()
+ {
+ return $this->getMinkParameter('base_url') ?: '';
+ }
+
+ /**
* Joins URL parts into an URL using forward slash.
* Forward slash usages are normalised to one between parts.
* This method takes variable number of parameters.

0 comments on commit c1a078e

Please sign in to comment.