/** * @param string $presenterName is fully qualified presenter name (module:module:presenter) * @param string $action * @param string $method * @param array $params * @param array $post * @return Application\IResponse */ public function assertFormSubmitted($presenterName, $action, $method = 'GET', $params = array(), $post = array()) { $presenter = $this->createPresenter($presenterName); $res = $this->processRequest($presenter, $presenterName, $action, $method, $params, $post); Assert::type('Nette\\Application\\Responses\\RedirectResponse', $res); return $res; }
public function testFetchLastRawRows() { $source = $this->createArraySourceWithDataStructure(); Assert::exception(function () use($source) { $source->fetchLastRawRows(); }, InvalidStateException::class); $source->fetchAll(); $rawData = $source->fetchLastRawRows(); Assert::count(self::FULL_USER_COUNT, $rawData); foreach ($rawData as $item) { Assert::type(ArrayHash::class, $item); } }
protected static function matchCounts(IFilterSource $source, $filteredCount, $fullCount, $rawClassType) { static $lastRowsDescription = 'Output from fetchLastRawRows after %s'; $users = $source->fetchAll(); if (count($users) > 0) { Assert::type(ArrayHash::class, reset($users)); } Assert::count($filteredCount, $users, 'Output from fetchAll'); $lastRows = $source->fetchLastRawRows(); if (count($lastRows) > 0) { Assert::type($rawClassType, reset($lastRows)); } Assert::count($filteredCount, $lastRows, sprintf($lastRowsDescription, 'fetchAll')); $fullData = $source->fetchFullData(); if (count($fullData) > 0) { Assert::type(ArrayHash::class, reset($fullData)); } Assert::count($fullCount, $fullData, 'Output from fetchFullData'); $lastRows = $source->fetchLastRawRows(); if (count($lastRows) > 0) { Assert::type($rawClassType, reset($lastRows)); } Assert::count($fullCount, $lastRows, sprintf($lastRowsDescription, 'fetchFullData')); }
/** * @param string $destination * @param array $params * @param array $post * * @return \Nette\Application\Responses\TextResponse * @throws \Exception */ protected function checkSitemap($destination, $params = [], $post = []) { /** @var \Nette\Application\Responses\TextResponse $response */ $response = $this->check($destination, $params, $post); if (!$this->__testbench_exception) { Assert::same(200, $this->getReturnCode()); Assert::type('Nette\\Application\\Responses\\TextResponse', $response); Assert::type('Nette\\Application\\UI\\ITemplate', $response->getSource()); $dom = @\Tester\DomQuery::fromHtml($response->getSource()); // @ - not valid HTML Assert::true($dom->has('urlset')); Assert::true($dom->has('url')); Assert::true($dom->has('loc')); } return $response; }
/** * @param $type * @return $this */ public function type($type) { Assert::type($type, $this->getObject()); return $this; }
/** * @return \Nette\Http\Session */ protected function getSession() { Assert::type('Nette\\Http\\Session', $this->session); return $this->session; }
public function testFetchLastRawRows() { $source = new NetteDbTableSource($this->tableName, 'id', $this->user, $this->context); Assert::exception(function () use($source) { $source->fetchLastRawRows(); }, InvalidStateException::class); $source->fetchAll(); $rawData = $source->fetchLastRawRows(); Assert::count(self::FULL_USER_COUNT, $rawData); foreach ($rawData as $item) { Assert::type(Database\Table\ActiveRow::class, $item); } }
/** * @eventListener onDeepArray * @param int[][] $array */ public function onDeepArray($array) { Assert::type('array', $array); foreach ($array as $innerArray) { Assert::type('array', $innerArray); foreach ($innerArray as $int) { Assert::type('int', $int); } } $this->onDeepArrayCalled = TRUE; }
public final function testOnRequestOnResponse() { $client = $this->createClient(); $insideRequest = NULL; $client->onRequest(function (Request $request) use(&$insideRequest) { $insideRequest = $request; }); $insideResponse = NULL; $client->onResponse(function (Response $response) use(&$insideResponse) { $insideResponse = $response; }); Assert::null($insideRequest); Assert::null($insideResponse); $client->process(new Request('GET', $this->baseUrl . '/ping')); Assert::type('Bitbang\\Http\\Request', $insideRequest); Assert::type('Bitbang\\Http\\Response', $insideResponse); }
/** * @param $name * @return $this */ public function hasComponent($name) { $c = $this->getObject(); Assert::type('Nette\\ComponentModel\\IComponent', $c[$name]); return $this; }
public function __construct($a, $b, $c) { \Tester\Assert::type(\Mrtnzlml\Tests\Service2::class, $a); \Tester\Assert::same(159753, $b); \Tester\Assert::same('%', $c); }
/** * @param string $destination fully qualified presenter name (module:module:presenter) * @param array $params provided to the presenter usually via URL * @param array $post provided to the presenter via POST * * @return \Nette\Application\Responses\TextResponse * @throws \Exception */ protected function checkSitemap($destination, $params = [], $post = []) { /** @var \Nette\Application\Responses\TextResponse $response */ $response = $this->check($destination, $params, $post); if (!$this->__testbench_exception) { Assert::same(200, $this->getReturnCode()); Assert::type('Nette\\Application\\Responses\\TextResponse', $response); Assert::type('Nette\\Application\\UI\\ITemplate', $response->getSource()); $xml = \Tester\DomQuery::fromXml($response->getSource()); Assert::same('urlset', $xml->getName(), 'root element is'); $url = $xml->children(); Assert::same('url', $url->getName(), "child of 'urlset'"); Assert::same('loc', $url->children()->getName(), "child of 'url'"); } return $response; }
public static function isOf($expected) { return static::match(function ($arg) use($expected) { Assert::type($expected, $arg); }); }
public function assertRedirect(IResponse $response) { Assert::type(RedirectResponse::class, $response); }
public function testFetchLastRawRows() { $source = new DoctrineSource(User::class, self::OWN_PRIMARY_KEY, $this->user, $this->columnMapping); Assert::exception(function () use($source) { $source->fetchLastRawRows(); }, InvalidStateException::class); $source->fetchAll(); $rawData = $source->fetchLastRawRows(); Assert::count(self::FULL_USER_COUNT, $rawData); foreach ($rawData as $item) { Assert::type(User::class, $item); } }