/**
  * @param TableNode $table
  *
  * @Given /^(?:the )?response should contain the following data:$/
  */
 public function theResponseShouldContainTheFollowingData(TableNode $table)
 {
     $response = json_decode($this->getBrowser()->getLastResponse()->getContent(), true);
     foreach ($table->getHash() as $data) {
         assertArrayHasKey($data['key'], $response);
         assertEquals($response[$data['key']], $data['value']);
     }
 }
Пример #2
0
 /**
  * @Then json response body should contain property :arg1 equal to :arg2
  */
 public function jsonResponseBodyShouldContainPropertyEqualTo($arg1, $arg2)
 {
     $responseData = json_decode($this->client->getResponse()->getContent(), true);
     $nestedProperties = explode('->', $arg1);
     $foundValue = $responseData;
     foreach ($nestedProperties as $property) {
         assertArrayHasKey($property, $foundValue);
         $foundValue = $foundValue[$property];
     }
     assertEquals($arg2, $foundValue);
 }
Пример #3
0
 /**
  * @todo come back to testing this...
  */
 public function test_it_can_compile_index_data()
 {
     $this->Request->shouldReceive('url')->andReturn('someUrl');
     $this->Filesystem->shouldReceive('exists')->once()->andReturn(true)->shouldReceive('directories')->once()->andReturnSelf()->shouldReceive('files')->once()->andReturnSelf();
     $output = $this->Repository->compileIndexData(['capable' => true]);
     assertInternalType('array', $output);
     assertArrayHasKey('crumbs', $output);
     assertArrayHasKey('categories', $output);
     assertArrayHasKey('media-items', $output);
     assertArrayHasKey('searched-items', $output);
 }
 /**
  * @Then /^I should get these and more:$/
  */
 public function iShouldGetTheseAndMore(TableNode $table)
 {
     foreach ($table->getHash() as $row) {
         assertArrayHasKey($row['lang'], $this->languages, 'Language ' . $row['lang'] . ' must be among available languages.');
         assertEquals($row['title'], $this->languages[$row['lang']]);
     }
     foreach ($this->languages as $code => $title) {
         assertNotEmpty($title);
     }
     assertGreaterThan(10, count($this->languages), 'There are missing languages for sure!');
 }
 /**
  * Follow redirect instructions.
  *
  * @param   string  $page
  *
  * @return  void
  *
  * @Then /^I (?:am|should be) redirected(?: to "([^"]*)")?$/
  */
 public function iAmRedirected($page = null)
 {
     $headers = $this->getSession()->getResponseHeaders();
     assertArrayHasKey('Location', $headers, 'The response contains a "Location" header');
     if (null !== $page) {
         assertEquals($headers['Location'][0], $this->locatePath($page), 'The "Location" header points to the correct URI');
     }
     $client = $this->getClient();
     $client->followRedirects(true);
     $client->followRedirect();
 }
Пример #6
0
 /**
  * @Given /^Unpack files to the same directory:$/
  */
 public function unpackFilesToTheSameDirectory(PyStringNode $string)
 {
     $expectedFiles = $string->getLines();
     $this->pagesDir = $this->package->unpack($expectedFiles);
     assertFileExists($this->pagesDir);
     chdir($this->pagesDir);
     $foundFiles = array_flip(glob('*.html'));
     assertCount(count($expectedFiles), $foundFiles);
     foreach ($expectedFiles as $file) {
         assertArrayHasKey($file, $foundFiles);
     }
 }
 /**
  * Assert that the response view has a given piece of bound data.
  *
  * @param  string|array  $key
  * @param  mixed  $value
  * @return void
  */
 public function assertViewHas($key, $value = null)
 {
     if (is_array($key)) {
         return $this->assertViewHasAll($key);
     }
     $response = $this->client->getResponse();
     if (!isset($response->original) || !$response->original instanceof View) {
         return assertTrue(false, 'The response was not a view.');
     }
     if (is_null($value)) {
         assertArrayHasKey($key, $response->original->getData());
     } else {
         assertEquals($value, $response->original->{$key});
     }
 }
Пример #8
0
 public function test_it_can_get_available_rules_list()
 {
     $results = $this->PermissionsRepository->availableRulesList();
     assertInternalType('array', $results);
     assertArrayHasKey('isLoggedIn', $results);
 }
 /**
  * @Then Assert the array :arg1 has key :key
  * @param array $arg1
  * @param string $key
  */
 public function assertArrayHasKey(array $arg1, $key)
 {
     assertArrayHasKey($key, $arg1, sprintf("Assert the array [%s] have key [%s], but have [%s].", print_r($arg1, true), $key, join(',', array_keys($arg1))));
 }
Пример #10
0
 /**
  * Checks that response body contains JSON from PyString.
  *
  * @param PyStringNode $jsonString
  *
  * @Then /^(?:the )?response should contain json:$/
  */
 public function theResponseShouldContainJson(PyStringNode $jsonString)
 {
     $etalon = json_decode($this->replacePlaceHolder($jsonString->getRaw()), true);
     $actual = json_decode($this->browser->getLastResponse()->getContent(), true);
     if (null === $etalon) {
         throw new \RuntimeException("Can not convert etalon to json:\n" . $this->replacePlaceHolder($jsonString->getRaw()));
     }
     assertCount(count($etalon), $actual);
     foreach ($actual as $key => $needle) {
         assertArrayHasKey($key, $etalon);
         assertEquals($etalon[$key], $actual[$key]);
     }
 }
Пример #11
0
 /**
  * @Then /^there should be "([^"]*)" parameter$/
  */
 public function thereShouldBeParameter($key)
 {
     assertArrayHasKey($key, $this->containerParameters);
     $this->parameterKey = $key;
 }
Пример #12
0
 public function testToArrayWithName()
 {
     $this->person->firstName = 'Tyler';
     $array = $this->hydrator->toArray($this->person, $this->metadata);
     assertArrayHasKey('first_name', $array);
     assertInternalType('string', $array['first_name']);
     assertEquals('Tyler', $array['first_name']);
 }
 /**
  * @Then the response should contain a :field_name entry
  */
 public function theResponseShouldContainAEntry($field_name)
 {
     assertArrayHasKey($field_name, $this->response->json());
 }