type() public static method

Checks assertion.
public static type ( $type, $value, $description = NULL ) : void
return void
Exemplo n.º 1
0
 /**
  * @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;
 }
Exemplo n.º 2
0
 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);
     }
 }
Exemplo n.º 3
0
 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'));
 }
Exemplo n.º 4
0
 /**
  * @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;
 }
Exemplo n.º 5
0
 /**
  * @param $type
  * @return $this
  */
 public function type($type)
 {
     Assert::type($type, $this->getObject());
     return $this;
 }
Exemplo n.º 6
0
 /**
  * @return \Nette\Http\Session
  */
 protected function getSession()
 {
     Assert::type('Nette\\Http\\Session', $this->session);
     return $this->session;
 }
Exemplo n.º 7
0
 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);
     }
 }
Exemplo n.º 8
0
 /**
  * @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;
 }
Exemplo n.º 9
0
 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);
 }
Exemplo n.º 10
0
 /**
  * @param $name
  * @return $this
  */
 public function hasComponent($name)
 {
     $c = $this->getObject();
     Assert::type('Nette\\ComponentModel\\IComponent', $c[$name]);
     return $this;
 }
Exemplo n.º 11
0
 public function __construct($a, $b, $c)
 {
     \Tester\Assert::type(\Mrtnzlml\Tests\Service2::class, $a);
     \Tester\Assert::same(159753, $b);
     \Tester\Assert::same('%', $c);
 }
Exemplo n.º 12
0
 /**
  * @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;
 }
Exemplo n.º 13
0
 public static function isOf($expected)
 {
     return static::match(function ($arg) use($expected) {
         Assert::type($expected, $arg);
     });
 }
Exemplo n.º 14
0
 public function assertRedirect(IResponse $response)
 {
     Assert::type(RedirectResponse::class, $response);
 }
Exemplo n.º 15
0
 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);
     }
 }