Skip to content

Instantly share code, notes, and snippets.

@elnur
Created March 16, 2013 22:40
Show Gist options
  • Save elnur/5178641 to your computer and use it in GitHub Desktop.
Save elnur/5178641 to your computer and use it in GitHub Desktop.
/**
* @Given /^I am logged in$/
*/
public function iAmLoggedIn()
{
$user = $this->aUser();
$this->userManager->save($user);
$this->currentUser = $user;
}
/**
* @Given /^a user "([^"]*)"$/
*/
public function aUserExists($name)
{
$user = $this->aUser([
'displayName' => $name,
]);
$this->userManager->save($user);
$this->user = $user;
}
/**
* @Given /^I have a tip$/
*/
public function iHaveATip()
{
$tip = $this->aTip([
'author' => $this->currentUser,
]);
$this->tipManager->save($tip);
$this->tip = $tip;
}
/**
* @Given /^he has a tip$/
*/
public function heHasATip()
{
$tip = $this->aTip([
'author' => $this->user,
]);
$this->tipManager->save($tip);
$this->tip = $tip;
}
/**
* @Given /^the tip has (\d+) likes?$/
*/
public function theTipHasLikes($count)
{
assertEquals($count, $this->tip->getLikesCount($count));
}
/**
* @When /^I liked? the tip$/
*/
public function iLikeTheTip()
{
try {
$this->likeManager->like($this->currentUser, $this->tip);
} catch (Exception $e) {
}
}
/**
* @Given /^I liked the tip (\d+) minutes ago$/
*/
public function iLikedTheTipMinutesAgo($minutes)
{
$this->likeManager->save(new Like([
'user' => $this->currentUser,
'tip' => $this->tip,
'createdAt' => new DateTime(sprintf('-%d minutes', $minutes)),
]));
}
/**
* @When /^I dislike the tip$/
*/
public function iDislikeTheTip()
{
try {
$this->likeManager->dislike($this->currentUser, $this->tip);
} catch (Exception $e) {
}
}
/**
* @Then /^the tip should have (\d+) likes?$/
*/
public function theTipShouldHaveLikes($count)
{
assertEquals($count, $this->tip->getLikesCount());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment