public function testHasTtl() { $this->if($object = new TestedClass($generator = new asserter\generator()))->and($response = new \mock\Symfony\Component\HttpFoundation\Response())->and($this->calling($response)->getTtl = function () use(&$ttl) { return $ttl; })->and($object->setWith($response))->and($ttl = rand(0, 100))->then->exception(function () use($object, &$value) { $object->hasTtl($value = rand(200, PHP_INT_MAX)); })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('TTL %s is not equal to %s'), $object->getAnalyzer()->getTypeOf($ttl), $object->getAnalyzer()->getTypeOf($value)))->if($ttl = uniqid())->then->object($object->hasTtl($ttl))->isIdenticalTo($object); }
/** * @param \Symfony\Bundle\FrameworkBundle\Client $client * @param \Symfony\Component\DomCrawler\Crawler $crawler * @param string $method * * @return callable */ protected function getSendRequestHandler(&$client, &$crawler, $method) { $generator = $this->getAsserterGenerator(); return function ($path, array $parameters = array(), array $files = array(), array $server = array(), $content = null, $changeHistory = true) use(&$client, &$crawler, $method, $generator) { /** @var $client \Symfony\Bundle\FrameworkBundle\Client */ $crawler = $client->request($method, $path, $parameters, $files, $server, $content, $changeHistory); $asserter = new Asserters\Response($generator); return $asserter->setWith($client->getResponse()); }; }
/** * {@inheritdoc} */ protected function getSendRequestHandler(&$client, &$crawler, $method) { $generator = $this->getAsserterGenerator(); $test = $this; return function ($path, array $parameters = array(), array $files = array(), array $server = array(), $content = null, $changeHistory = true) use(&$client, &$crawler, $method, $generator, $test) { // New client generation otherwise kernel is reboot without managers mocks $client = $test->createClient($test->clientOptions, $test->clientServer); /** @var $client \Symfony\Bundle\FrameworkBundle\Client */ $crawler = $client->request($method, $path, $parameters, $files, $server, $content, $changeHistory); $asserter = new Asserters\Response($generator); return $asserter->setWith($client->getResponse()); }; }