/**
  * @Given /^I am logged in$/
  */
 public function stepIAmLoggedIn()
 {
     $c = $this->getMainContext();
     $adminUrl = $c->joinUrlParts($c->getBaseUrl(), $c->getAdminUrl());
     $loginUrl = $c->joinUrlParts($c->getBaseUrl(), $c->getLoginUrl());
     $this->getSession()->visit($adminUrl);
     if (0 == strpos($this->getSession()->getCurrentUrl(), $loginUrl)) {
         $this->stepILogInWith('admin', 'password');
         assertStringStartsWith($adminUrl, $this->getSession()->getCurrentUrl());
     }
 }
 /**
  * @Then /([^\s]+) should start with ([^\s]+)/
  */
 public function shouldStartWith($key, $value)
 {
     if (property_exists($this, 'error')) {
         throw $this->error;
     }
     $this->result ?: array();
     assertNotEmpty($this->result, 'No results received.');
     $result = array_reduce(explode('.', $key), function ($o, $k) {
         if (property_exists($o, $k)) {
             return $o->{$k};
         } else {
             return '';
         }
     }, $this->result[0]);
     assertStringStartsWith($value, $result);
 }
Exemple #3
0
});
$steps->Then('/([^\\s]+) should be (.+)$/', function ($world, $key, $value) {
    if (property_exists($world, 'error')) {
        throw $world->error;
    }
    $world->result ?: array();
    assertNotEmpty($world->result, 'No results received.');
    $results = array_map(function ($o) use($key) {
        if (property_exists($o, $key)) {
            return $o->{$key};
        } else {
            return '';
        }
    }, $world->result);
    assertEquals(implode(',', $results), $value);
});
$steps->Then('/([^\\s]+) should start with ([^\\s]+)/', function ($world, $key, $value) {
    if (property_exists($world, 'error')) {
        throw $world->error;
    }
    $world->result ?: array();
    assertNotEmpty($world->result, 'No results received.');
    $result = array_reduce(explode('.', $key), function ($o, $k) {
        if (property_exists($o, $k)) {
            return $o->{$k};
        } else {
            return '';
        }
    }, $world->result[0]);
    assertStringStartsWith($value, $result);
});