Jump to content

Todar

New Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by Todar

  1. This is the code given below /** * Download a url and verify the contents. * * @throws \Exception * When the file contents don't match. * * @Then the URL :url contains the following: */ public function assertUrlContent(string $url, PyStringNode $content): void { $cookies = $this->getSession()->getDriver()->getWebDriverSession()->getCookie()[0]; $cookie = new SetCookie(); $cookie->setName($cookies['name']); $cookie->setValue($cookies['value']); $cookie->setDomain($cookies['domain']); $jar = new CookieJar(); $jar->setCookie($cookie); $client = new Client(); $res = $client->request('GET', $url, [ 'cookies' => $jar, 'verify' => FALSE, ]); $expected_string = preg_replace('/\r/', '', (string) $content); $actual_string = $res->getBody()->getContents(); if ($expected_string !== $actual_string) { print_r('Expected String: ' . PHP_EOL . $expected_string . PHP_EOL); print_r('Actual String: ' . PHP_EOL . $actual_string); throw new \Exception('Contents of download do not match'); } } in one case i have to compare the data of csv and on of the item is date that i have give on. test case is And the URL "https://test2-portal.dev.local/data/measure-definitions.csv?title=&;report_nid=&;field_data_source_target_id=All" contains the following: """ "Measure name","Business description","Technical description","Data Sources",Reports,"Authored by", "Published date" "First Test Measure","business Lorem Ipsum is simply","technical Lorem Ipsum is",CHRISS,,, "Second Test Measure","business Lorem Ipsum is simply","technical Lorem Ipsum is",PHESS,,, """ and so my question what are ways to calculate the Published date as current date as expected dataand in which format I should enter it. I want to what changes I need to make in $expected_string = preg_replace('/\r/', '', (string) $content); so it calculate the current date in the expected string.
  2. I have to pass the date in one of the step as current date and compare that, but failing to achieve that test case is "And the URL "<>" contains the following: "Measure name","Business description","Technical description","Data Sources",Reports,"Authored by","Last publish date" "First Test Measure","business Lorem Ipsum is simply","technical Lorem Ipsum is",CHRISS,First Test Report,, Here one of the parameter is "Last publish date" so I have to give it as it should be comes up as current date. I am trying to give the date [[now:j F Y], but it is not working. Below is the function written for it, what change I have to do so it can have the date as well. /** * Download a url and verify the contents. * * @throws \Exception * When the file contents don't match. * * @Then the URL :url contains the following: */ public function assertUrlContent(string $url, PyStringNode $content): void { $cookies = $this->getSession()->getDriver()->getWebDriverSession()->getCookie()[0]; $cookie = new SetCookie(); $cookie->setName($cookies['name']); $cookie->setValue($cookies['value']); $cookie->setDomain($cookies['domain']); $jar = new CookieJar(); $jar->setCookie($cookie); $client = new Client(); $res = $client->request('GET', $url, [ 'cookies' => $jar, 'verify' => FALSE, ]); $expected_string = preg_replace('/\r/', '', (string) $content); $actual_string = $res->getBody()->getContents(); if ($expected_string !== $actual_string) { print_r('Expected String: ' . PHP_EOL . $expected_string . PHP_EOL); print_r('Actual String: ' . PHP_EOL . $actual_string); throw new \Exception('Contents of download do not match'); } }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.