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.