/** * @Then All users with a pending and outdated activation should be removed */ public function allUsersWithAPendingAndOutdatedActivationShouldBeRemoved() { $em = $this->getEntityManager(); for ($i = 0; $i < 2; ++$i) { Assertion::eq(null, $em->getRepository('Account:User')->findOneBy(['username' => (string) $i])); } Assertion::notEq(null, $em->getRepository('Account:User')->findOneBy(['username' => 'foo'])); }
/** * @Then I should have an activation email */ public function iShouldHaveAnActivationEmail() { $client = $this->recentClient; /** @var \Symfony\Bundle\SwiftMailerBundle\DataCollector\MessageDataCollector $mailCollector */ $mailCollector = $client->getProfile()->getCollector('swiftmailer'); Assertion::eq(1, $mailCollector->getMessageCount()); /** @var \Swift_Message $message */ $message = $mailCollector->getMessages()[0]; Assertion::eq($message->getSubject(), 'Sententiaregum Notifications'); Assertion::eq(key($message->getTo()), '*****@*****.**'); $crawler = new Crawler(); $crawler->addContent($message->getChildren()[1]->getBody()); Assertion::count($message->getChildren(), 2); Assertion::eq(1, $crawler->filter('#n-ac-l-p')->count()); Assertion::notEq(0, preg_match('/!\\/activate\\/(.*)/', $message->getChildren()[0]->getBody())); }
/** * @Then /^I should've gotten an email$/ */ public function checkEmail() { /** @var \Symfony\Bundle\SwiftmailerBundle\DataCollector\MessageDataCollector $profile */ $profile = $this->apiContext->getProfile()->getCollector('swiftmailer'); Assertion::eq(1, $profile->getMessageCount()); /** @var \Swift_Message $message */ $message = $profile->getMessages()[0]; // user registers as "de", so email should be in german Assertion::eq($message->getSubject(), 'Benachrichtigungen von Sententiaregum'); Assertion::eq(key($message->getTo()), '*****@*****.**'); $crawler = new Crawler(); $crawler->addContent($message->getChildren()[1]->getBody()); Assertion::count($message->getChildren(), 2); Assertion::eq(1, $crawler->filter('#n-ac-l-p')->count()); Assertion::notEq(0, preg_match('/\\/activate\\/(.*)/', $message->getChildren()[0]->getBody())); }
/** * @param string $key * @return int */ public function delete($key) { Assertion::notNull(self::$redis, "Redis connection hasn't been set"); Assertion::string($key, "Number key must be a string"); Assertion::notEq($key, "", "Number key must be a non empty string"); $key = $this->identifier . "::" . $key; self::$redis->sRemove($this->identifier, $key); self::$redis->delete($key); return $this->getCurrentNumber(); }