assertGreaterThanOrEqual() public static method

Asserts that a value is greater than or equal to another value.
public static assertGreaterThanOrEqual ( mixed $expected, mixed $actual, string $message = '' )
$expected mixed
$actual mixed
$message string
 /** @test */
 public function it_can_be_added_to_faker_as_a_provider_and_used()
 {
     $faker = Factory::create();
     $faker->addProvider(new BuzzwordJobProvider($faker));
     $jobTitle = $faker->jobTitle();
     $jobTitleWords = explode(' ', $jobTitle);
     Assert::assertGreaterThanOrEqual(3, $jobTitleWords);
 }
Example #2
0
 public function toBeGreaterThanOrEqualTo($expected)
 {
     if ($this->negate) {
         a::assertLessThan($expected, $this->actual);
     } else {
         a::assertGreaterThanOrEqual($expected, $this->actual);
     }
 }
Example #3
0
 public function testGenerateHeaders()
 {
     $generator = new Generator();
     $headers = $generator->addSignatureToHeadersArray('GET', 'http://somesite.com/sample/url', ['foo' => 'bar'], 'myapi123', 'mysecret456');
     $nonce = $headers['X-TOKENLY-AUTH-NONCE'];
     PHPUnit::assertGreaterThanOrEqual(time(), $nonce);
     PHPUnit::assertEquals('myapi123', $headers['X-TOKENLY-AUTH-API-TOKEN']);
     $expected_signature = $this->expectedSignature($nonce);
     PHPUnit::assertEquals($expected_signature, $headers['X-TOKENLY-AUTH-SIGNATURE']);
     // with GET params
     $headers = $generator->addSignatureToHeadersArray('GET', 'http://somesite.com/sample/url?foo=bar', null, 'myapi123', 'mysecret456');
     $nonce = $headers['X-TOKENLY-AUTH-NONCE'];
     PHPUnit::assertGreaterThanOrEqual(time(), $nonce);
     PHPUnit::assertEquals('myapi123', $headers['X-TOKENLY-AUTH-API-TOKEN']);
     $expected_signature = $this->expectedSignature($nonce);
     PHPUnit::assertEquals($expected_signature, $headers['X-TOKENLY-AUTH-SIGNATURE']);
 }
 /**
  * @When /^el usuario "([^"]*)" tiene una sanción por la taquilla "([^"]*)" de todo el curso$/
  */
 public function elUsuarioTieneUnaSanciónPorLaTaquillaDeTodoElCurso($username, $code)
 {
     /** @var User $user */
     $user = $this->getRepository('user')->findOneBy(['username' => $username]);
     if (!$user) {
         throw new \Exception('User not found: ' . $username);
     }
     \PHPUnit_Framework_Assert::assertTrue($user->getIsPenalized());
     $this->getEntityManager()->refresh($user);
     $penalties = $user->getPenalties();
     $endSeason = TimePenalty::getEndSeasonPenalty();
     foreach ($penalties as $penalty) {
         if ($penalty instanceof TimePenalty) {
             if ($penalty->getRental()->getLocker()->getCode() == $code) {
                 \PHPUnit_Framework_Assert::assertGreaterThanOrEqual($endSeason, $penalty->getEndAt());
                 return true;
             }
         }
     }
     throw new \Exception('TimePenalty not found.');
 }
 public function testAuthenticationHeaders()
 {
     $generator = new Generator();
     $api = Phake::partialMock('Tokenly\\APIClient\\TokenlyAPI', 'https://127.0.0.1/api/v1', $generator, 'MY_CLIENT_ID', 'MY_CLIENT_SECRET');
     $headers_generated = [];
     Phake::when($api)->callRequest(Phake::anyParameters())->thenReturnCallback(function ($url, $headers, $body, $method, $options) use(&$headers_generated) {
         $response = new Requests_Response();
         $response->body = json_encode(['sample' => 'output']);
         $headers_generated = $headers;
         return $response;
     });
     $result = $api->call('GET', 'method/one', ['foo' => 'bar']);
     PHPUnit::assertEquals(['sample' => 'output'], $result);
     // check headers
     PHPUnit::assertNotEmpty($headers_generated);
     $nonce = $headers_generated['X-TOKENLY-AUTH-NONCE'];
     PHPUnit::assertGreaterThanOrEqual(time(), $nonce);
     PHPUnit::assertEquals('MY_CLIENT_ID', $headers_generated['X-TOKENLY-AUTH-API-TOKEN']);
     $expected_signature = $this->expectedSignature($nonce);
     PHPUnit::assertEquals($expected_signature, $headers_generated['X-TOKENLY-AUTH-SIGNATURE']);
 }
Example #6
0
 /**
  * @Then /^I should see a table containing the following rows:$/
  */
 public function iShouldSeeATableContainingTheFollowingRows(TableNode $table)
 {
     $output = $this->getOutputAsArray();
     $expectedRows = $table->getRows();
     $foundRows = 0;
     foreach ($expectedRows as $row) {
         foreach ($output as $line) {
             $foundCells = 0;
             foreach ($row as $cell) {
                 if (!$cell) {
                     $foundCells++;
                     continue;
                 }
                 if (false !== strpos($line, $cell)) {
                     $foundCells++;
                 }
             }
             if ($foundCells == count($row)) {
                 $foundRows++;
             }
         }
     }
     \PHPUnit_Framework_Assert::assertGreaterThanOrEqual(count($expectedRows), $foundRows, $this->getOutput());
 }
 public function testCreatePost()
 {
     //fwrite(STDOUT, __METHOD__ . "\n");
     PHPUnit_Framework_Assert::assertNotNull(self::$postPDO);
     $newPostItem = array('id' => null, 'forumId' => self::$forumId, 'userId' => SELF::USER_ID, 'title' => 'TestPost.0', 'content' => 'This is a test post item.0', 'contentType' => 'text/plain');
     $forumPostItemId = self::$postPDO->createForumPostEntry($newPostItem);
     PHPUnit_Framework_Assert::assertNotNull($forumPostItemId);
     PHPUnit_Framework_Assert::assertGreaterThanOrEqual(0, $forumPostItemId);
     $newPostItem['id'] = $forumPostItemId;
     return $newPostItem;
 }
Example #8
0
 /**
  * Checks that response body contains JSON from PyString.
  *
  * Do not check that the response body /only/ contains the JSON from PyString,
  *
  * @param PyStringNode $jsonString
  *
  * @throws \RuntimeException
  *
  * @Then /^(?:the )?response should contain json:$/
  */
 public function theResponseShouldContainJson(PyStringNode $jsonString)
 {
     $etalon = json_decode($this->replacePlaceHolder($jsonString->getRaw()), true);
     $actual = json_decode($this->getResponse()->getBody(), true);
     if (null === $etalon) {
         throw new \RuntimeException("Can not convert etalon to json:\n" . $this->replacePlaceHolder($jsonString->getRaw()));
     }
     Assertions::assertGreaterThanOrEqual(count($etalon), count($actual));
     foreach ($etalon as $key => $needle) {
         if (is_array($needle)) {
             foreach ($needle as $k => $v) {
                 if (is_array($v) && in_array('id', array_keys($v))) {
                     continue 2;
                 }
             }
         }
         if (in_array($key, ['id', 'updated_at', 'created_at', 'start_at', 'end_at', 'slug'])) {
             continue;
         }
         Assertions::assertArrayHasKey($key, $actual);
         Assertions::assertEquals($etalon[$key], $actual[$key]);
     }
 }
 /**
  * Checks that response body contains JSON from PyString.
  *
  * Do not check that the response body /only/ contains the JSON from PyString,
  *
  * @param PyStringNode $jsonString
  *
  * @throws \RuntimeException
  *
  * @Then /^(?:the )?response should contain json:$/
  */
 public function theResponseShouldContainJson(PyStringNode $jsonString)
 {
     $etalon = json_decode($this->replacePlaceHolder($jsonString->getRaw()), true);
     $actual = $this->response->json();
     if (null === $etalon) {
         throw new \RuntimeException("Can not convert etalon to json:\n" . $this->replacePlaceHolder($jsonString->getRaw()));
     }
     Assertions::assertGreaterThanOrEqual(count($etalon), count($actual));
     foreach ($etalon as $key => $needle) {
         Assertions::assertArrayHasKey($key, $actual);
         Assertions::assertEquals($etalon[$key], $actual[$key]);
     }
 }
Example #10
0
 public function greaterOrEquals($expected)
 {
     a::assertGreaterThanOrEqual($expected, $this->actual, $this->description);
 }
Example #11
0
 /**
  * @param $expected
  * @param $actual
  * @param $description
  */
 protected function assertGreaterOrEquals($expected, $actual, $description)
 {
     \PHPUnit_Framework_Assert::assertGreaterThanOrEqual($expected, $actual, $description);
 }
 /**
  * @Then the api/API result should contain at least :count item(s)
  * @Then the api/API result contains at least :count item(s)
  */
 public function theResultContainsAtLeastItems($count)
 {
     $result = $this->getApiResult();
     Assert::assertContainsOnly('array', $result);
     Assert::assertGreaterThanOrEqual($count, count($result));
 }
Example #13
0
 public function isGreaterOrEqualTo($expected)
 {
     Assert::assertGreaterThanOrEqual($expected, $this->actual, $this->description);
     return $this;
 }
Example #14
0
 /**
  * @Then the response should contain json:
  */
 public function theResponseShouldContainJson(PyStringNode $jsonString)
 {
     $etalon = json_decode($jsonString->getRaw(), true);
     $a = $this->getSession()->getPage();
     //        $b = $this->getSession()->getPage()->getHtml();
     $c = $this->getSession()->getPage()->getContent();
     $actual = json_decode($this->getMink()->getSession()->getPage()->getContent(), true);
     if (null === $etalon) {
         throw new \RuntimeException("Can not convert etalon to json:\n");
     }
     Assertions::assertGreaterThanOrEqual(count($etalon), count($actual));
     foreach ($etalon as $key => $needle) {
         Assertions::assertArrayHasKey($key, $actual);
         $e = $etalon[$key];
         $g = $actual[$key];
         Assertions::assertEquals($etalon[$key], $actual[$key]);
     }
 }
 /**
  * Checks that response body contains JSON from PyString.
  *
  * Do not check that the response body /only/ contains the JSON from PyString,
  *
  * @param PyStringNode $jsonString
  *
  * @throws \RuntimeException
  *
  * @Then /^(?:the )?response should contain json:$/
  */
 public function theResponseShouldContainJson(PyStringNode $jsonString)
 {
     $expected = json_decode($this->replacePlaceHolder($jsonString->getRaw()), true);
     $actual = json_decode($this->response->getBody(), true);
     if (null === $expected) {
         throw new \RuntimeException("Can not convert expected to json:\n" . $this->replacePlaceHolder($jsonString->getRaw()));
     }
     Assertions::assertGreaterThanOrEqual(count($expected), count($actual));
     $this->assertContains($expected, $actual);
 }
Example #16
0
 /**
  * Expect that a value is greater than or equal to another value.
  *
  * @param mixed $expected
  * @param string $message
  *
  * @return Expect
  */
 public function toBeGreaterThanOrEqualTo($expected, $message = '')
 {
     Assert::assertGreaterThanOrEqual($expected, $this->value, $message);
     return $this;
 }
 /**
  * @Then Product text should be a string
  */
 public function productTextShouldBeAString()
 {
     PHPUnit::assertGreaterThanOrEqual(1, strlen($this->response->ProductText));
     PHPUnit::assertInternalType('string', $this->response->ProductText);
 }
Example #18
0
 /**
  * @Then the JSON node :node should be greater than :value
  *
  * @param string $node
  * @param string $value
  */
 public function theJsonNodeShouldBeHigher($node, $value)
 {
     $json = $this->getJson();
     $actual = $this->inspector->evaluate($json, $node);
     PHPUnit::assertGreaterThanOrEqual($value, $actual, sprintf('Expected `%s` to be greater than `%s`.', $value, $actual));
 }
 /**
  * @Then the email body should contain approximately :number :element elements
  * @Then the email body should contain ~ :number :element elements
  */
 public function theEmailBodyShouldContainApproximatelyNumElements($num, $element)
 {
     $num = intval($num);
     $crawler = new Crawler($this->message->getBody());
     $found = $crawler->filter($element);
     Assert::assertGreaterThanOrEqual($num - 1, $found->count());
     Assert::assertLessThanOrEqual($num + 1, $found->count());
 }
Example #20
0
 /**
  * @Then /^the process should have ran for (\d+) seconds?$/
  */
 public function theProcessShouldHaveRanForSeconds($seconds)
 {
     PHPUnit_Framework_Assert::assertGreaterThanOrEqual(2, time() - $this->start);
 }
Example #21
0
 /**
  * @Given all the users should have a mandate with the value :iri
  *
  * @param string $iri
  */
 public function allTheUsersShouldHaveAMandateWithTheValue($iri)
 {
     $accessor = PropertyAccess::createPropertyAccessor();
     $json = $this->getSession()->getPage()->getContent();
     $users = $this->inspector->evaluate(new Json($json), 'hydra:member');
     foreach ($users as $user) {
         $count = 0;
         foreach ($user->jobs as $job) {
             if (isset($job->mandate)) {
                 if ($iri === $accessor->getValue($job->mandate, '@id')) {
                     ++$count;
                 }
             }
         }
         PHPUnit::assertGreaterThanOrEqual(1, $count, sprintf('Expected user %s to have at least one job with the mandate %s.', $accessor->getValue($user, '@id'), $iri));
     }
 }
Example #22
0
/**
 * Asserts that a value is greater than or equal to another value.
 *
 * @param  mixed   $expected
 * @param  mixed   $actual
 * @param  string  $message
 * @since  Method available since Release 3.1.0
 */
function assertGreaterThanOrEqual($expected, $actual, $message = '')
{
    return PHPUnit_Framework_Assert::assertGreaterThanOrEqual($expected, $actual, $message);
}
Example #23
0
 protected function callProtectedMusicAPI($call_fn, $expected_url_extension, $expected_params = [], $sample_response = null)
 {
     if ($sample_response === null) {
         $sample_response = ['foo' => 'bar'];
     }
     $generator = new Generator();
     // set up the mock to check headers generated
     $tokenly_api = Phake::partialMock('Tokenly\\APIClient\\TokenlyAPI', 'https://127.0.0.1/api/v1', $generator, 'MY_CLIENT_ID', 'MY_CLIENT_SECRET');
     $called_vars = [];
     Phake::when($tokenly_api)->callRequest(Phake::anyParameters())->thenReturnCallback(function ($url, $headers, $request_params, $method, $request_options) use($sample_response, &$called_vars) {
         $called_vars = [];
         $response = new Requests_Response();
         $response->body = json_encode($sample_response);
         $called_vars['headers'] = $headers;
         $called_vars['url'] = $url;
         $called_vars['params'] = $request_params;
         return $response;
     });
     $music_api = new MusicAPI($tokenly_api);
     // check API call
     $result = $call_fn($music_api);
     PHPUnit::assertEquals($sample_response, $result);
     // check called URL
     PHPUnit::assertEquals('https://127.0.0.1/api/v1/' . $expected_url_extension, $called_vars['url']);
     // check headers
     $headers_generated = $called_vars['headers'];
     PHPUnit::assertNotEmpty($headers_generated);
     $nonce = $headers_generated['X-TOKENLY-AUTH-NONCE'];
     PHPUnit::assertGreaterThanOrEqual(time(), $nonce);
     PHPUnit::assertEquals('MY_CLIENT_ID', $headers_generated['X-TOKENLY-AUTH-API-TOKEN']);
     $expected_signature = $this->expectedSignature($nonce, 'https://127.0.0.1/api/v1/' . $expected_url_extension, $expected_params);
     PHPUnit::assertEquals($expected_signature, $headers_generated['X-TOKENLY-AUTH-SIGNATURE']);
     // return the called vars
     return $called_vars;
 }