true() публичный статический Метод

Checks TRUE assertion.
public static true ( $actual, $description = NULL ) : void
Результат void
Пример #1
0
function _register_wrapper($namespace)
{
    $fs = new FileSystem(new Connector(new ConnectorConfig(), new PathTranslator($namespace)));
    Assert::true(Wrapper::register($fs));
    $context = stream_context_create(array('dir' => array('recursive' => true)));
    @rmdir('redis://', $context);
}
Пример #2
0
 /**
  * @param IComparable $five
  * @param IComparable $six
  */
 public function assertForComparison(IComparable $five, IComparable $six)
 {
     Assert::true($five->isLessThan($six));
     Assert::true($five->isLessThanOrEqual($six));
     Assert::false($six->isLessThan($five));
     Assert::false($six->isLessThanOrEqual($five));
     Assert::false($five->isEqual($six));
     Assert::false($six->isEqual($five));
 }
Пример #3
0
 /**
  * @param $destination
  * @param array $args
  */
 protected function assertDestination($destination, $args = array())
 {
     $appRequest = $this->seleniumContext->getSession()->presenter();
     Assert::true(empty($appRequest));
     Assert::same($destination, $appRequest->getPresenterName());
     foreach ($args as $param => $value) {
         Assert::true(array_key_exists($param, $appRequest->parameters));
         Assert::same($value, $appRequest->parameters[$param]);
     }
 }
 private function testInvalid()
 {
     $file = $this->sniffer->processFile(Tester::$setup['invalidDir'] . $this->testedFile->getName() . '.php');
     $errors = $file->getErrors();
     foreach ($this->expectedOnLines as $line) {
         Assert::true(isset($errors[$line]));
         $errorsOnLine = $errors[$line];
         $errorFound = FALSE;
         foreach ($errorsOnLine as $error) {
             if ($error[0]['message'] === $this->expectedMessage) {
                 $errorFound = TRUE;
                 break;
             }
         }
         if (!$errorFound) {
             Assert::fail('Required error message "' . $this->expectedMessage . '" not found on line "' . $line . '"');
         }
     }
 }
Пример #5
0
 public final function testRelativeRedirect()
 {
     $client = $this->createClient();
     $response = $client->process(new Request('GET', $this->baseUrl . '/relative-redirect'));
     Assert::same('Redirection finished', $response->getBody());
     Assert::same(200, $response->getCode());
     $previous = $response->getPrevious();
     Assert::type('Bitbang\\Http\\Response', $previous);
     Assert::same('Redirection made', $previous->getBody());
     Assert::same(301, $previous->getCode());
     Assert::true($previous->hasHeader('Location'));
     Assert::same('/redirected', $previous->getHeader('Location'));
     Assert::null($previous->getPrevious());
 }
Пример #6
0
// set
$s = new Set(['a']);
Assert::exception(function () use($s) {
    $s->add('a');
}, 'transit\\TransitException');
Assert::true($s->contains('a'));
$s->add(new Keyword('abc'));
$s->add('b');
$s->add(true);
Assert::equal(['a', new Keyword('abc'), 'b', true], $s->toArray());
$s->remove(new Keyword('abc'));
Assert::equal(['a', 'b', true], $s->toArray());
Assert::false($s->contains(new Keyword('abc')));
Assert::true($s->contains('a'));
Assert::true($s->contains('b'));
Assert::true($s->contains(true));
//-------------------------
class Point
{
    public $x;
    public $y;
    public function __construct($x, $y)
    {
        $this->x = $x;
        $this->y = $y;
    }
}
class Circle
{
    public $a;
    public $b;
Пример #7
0
 /**
  * @return $this
  */
 public function valid()
 {
     Assert::true($this->getObject()->isValid());
     return $this;
 }
Пример #8
0
 /**
  * @param mixed   $level
  * @param string  $message
  * @param array   $context
  */
 public function log($level, $message, array $context = [])
 {
     Assert::true($message instanceof SendException);
     Assert::same('email', $level);
 }
Пример #9
0
 /**
  * Checks assertion. Values must be true.
  * @param mixed $actual
  * @return void
  */
 public function assertTrue($actual)
 {
     Assert::true($actual);
 }
Пример #10
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;
 }
Пример #11
0
 /**
  * @dataProvider dataObjectClasses
  */
 public function testHasId($class)
 {
     $metadata = $this->getMetadataFor($class);
     Assert::true($metadata->hasId());
 }
Пример #12
0
 public function assertHandleCalled()
 {
     Assert::true($this->handleCalled);
 }
Пример #13
0
    $_index = $node->getIndex();
    if ($_index == ACTIVE_INDEX) {
        Assert::true($menu->isActive($node));
    } else {
        Assert::false($menu->isActive($node));
    }
    if (preg_match('~^' . $_index . '~', ACTIVE_INDEX)) {
        Assert::true($menu->isInActive($menu->findByIndex($_index)));
    } else {
        Assert::false($menu->isInActive($menu->findByIndex($_index)));
    }
}
// check bread crumb navigation ************************************************
foreach ($menu->getCrumbNavigation() as $node) {
    $_index = $node->getIndex();
    Assert::true((bool) preg_match('~^' . $_index . '~', ACTIVE_INDEX));
}
Assert::equal(ACTIVE_INDEX, $_index);
/**
 * RECURSIVE RENDER ************************************************************
 * *****************************************************************************
 */
Assert::matchFile(__DIR__ . '/data/menu.html', buildHtmlRecursiveMenu($menu));
/**
 * CYCLE RENDER ****************************************************************
 * *****************************************************************************
 */
Assert::matchFile(__DIR__ . '/data/menu.html', buildHtmlCycleMenu($menu->getIndexes(), $menu));
// RecursiveTreeIterator not work for php 5.4
$tree = new RecursiveTreeIterator($menu, RecursiveTreeIterator::BYPASS_KEY | RecursiveTreeIterator::BYPASS_CURRENT);
Assert::matchFile(__DIR__ . '/data/menu.html', buildHtmlCycleMenu($tree, $menu));
Пример #14
0
<?php

use Tester\Assert;
require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/Token.php";
//valid value
$value = str_repeat('BeerNowThere0sATemporarySolution', 2);
$tokenFoo = new Token($value);
Assert::same("BeerNowThere0sATemporarySolutionBeerNowThere0sATemporarySolution", $tokenFoo->getValue());
//compare with another object of same value
$tokenBar = new Token("BeerNowThere0sATemporarySolutionBeerNowThere0sATemporarySolution");
$areSame = $tokenBar->sameValueAs($tokenFoo);
Assert::true($areSame);
//compare with another object of different value
$value = str_repeat('CraftBeerLovers0', 4);
//
$tokenPub = new Token($value);
Assert::same("CraftBeerLovers0CraftBeerLovers0CraftBeerLovers0CraftBeerLovers0", $tokenPub->getValue());
$areSame = $tokenPub->sameValueAs($tokenBar);
Assert::false($areSame);
//invalid values
Assert::exception(function () {
    new Token(null);
}, InvalidArgumentException::class, "Token must be not empty");
Assert::exception(function () {
    new Token("InvalidTokenLength123456789");
}, InvalidArgumentException::class, "Token must be 64 characters long");
Assert::exception(function () {
    $value = str_repeat('?!@#$%^&', 8);
    new Token($value);
}, InvalidArgumentException::class, "Token must be valid base_64");
Пример #15
0
<?php

use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
Assert::true(TRUE);
Пример #16
0
 /**
  * @param mixed $value
  * @throws AssertException
  */
 public static function floatAsStringPositive($value)
 {
     Assert::true(is_string($value));
     Assert::true(is_numeric($value), 'Not numeric value.');
     Assert::true($value > 0, 'Rate cannot be zero.');
 }
Пример #17
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 checkRss($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::fromXml($response->getSource());
         Assert::true($dom->has('rss'), "missing 'rss' element");
         Assert::true($dom->has('channel'), "missing 'channel' element");
         Assert::true($dom->has('title'), "missing 'title' element");
         Assert::true($dom->has('link'), "missing 'link' element");
         Assert::true($dom->has('item'), "missing 'item' element");
     }
     return $response;
 }
Пример #18
0
 public function testTrueIsTrue()
 {
     Assert::true(TRUE);
 }