/**
  * @Then the queue :queueName should contain task :taskName
  *
  * @param $queueName
  * @param $taskName
  * @return bool
  */
 public function thenQueueShouldContainTask($queueName, $taskName)
 {
     $queue = $this->createQueue($queueName);
     /** @var Envelope $envelope */
     foreach ($queue->peek() as $envelope) {
         if ($taskName === $envelope->getName()) {
             Assertions::assertEquals($taskName, $envelope->getName());
             return true;
         }
     }
     Assertions::fail(sprintf('No task with name %s was found in the queue: %s', $taskName, $queueName));
     return false;
 }
 /**
  * @When I login using password grant with :username :password
  */
 public function iLoginUsingPasswordGrantWith($username, $password)
 {
     // We need to reset the headers to be able to login correctly
     $this->IamUnauthorized();
     $this->getClient()->postWithFormData('/oauth/token', ['grant_type' => 'password', 'username' => $username, 'password' => $password]);
     $responseBody = $this->getClient()->lastResponseBody;
     Assertions::assertJson($responseBody);
     $response = json_decode($responseBody, true);
     Assertions::assertArrayHasKey('access_token', $response);
     $this->setAuthorizationBearerHeader($response['access_token']);
 }
 /**
  * @Then /^it should match the following properties:$/
  */
 public function itShouldMatchTheFollowingProperties(TableNode $table)
 {
     $jsonString = $this->getClient()->lastResponseBody;
     Assertions::assertJson($jsonString);
     $json = json_decode($jsonString, true);
     foreach ($table->getRows() as list($key, $value)) {
         // So we can detect checks for null values
         $value = $value === 'null' ? null : $value;
         Assertions::assertArrayHasKey($key, $json);
         if (is_bool($json[$key])) {
             Assertions::assertEquals((bool) $value, $json[$key]);
         } else {
             Assertions::assertEquals($value, $json[$key]);
         }
     }
 }
 /**
  * @Then the subject should contain :subject
  *
  * @param string $subject
  */
 public function subjectShouldContain($subject)
 {
     $message = $this->getLastMessage();
     Assertions::assertContains($subject, $message['subject']);
 }