コード例 #1
0
 /**
  * @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());
     }
 }
コード例 #2
0
 /**
  * @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);
 }
コード例 #3
0
ファイル: api_steps.php プロジェクト: robo47/embedly-php
});
$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);
});