same() public static method

Checks assertion. Values must be exactly the same.
public static same ( $expected, $actual, $description = NULL ) : void
return void
Exemplo n.º 1
0
 public function __construct($abc, $xyz, $false, $null)
 {
     \Tester\Assert::same('test', $abc);
     \Tester\Assert::same(159753, $xyz);
     \Tester\Assert::same(FALSE, $false);
     \Tester\Assert::null($null);
 }
Exemplo n.º 2
0
function routeIn(Nette\Application\IRouter $route, $url, $expectedPresenter = NULL, $expectedParams = NULL, $expectedUrl = NULL, $scriptPath = NULL)
{
    $url = new Nette\Http\UrlScript("http://example.com{$url}");
    if ($scriptPath) {
        $url->setScriptPath($scriptPath);
    }
    if ($url->getQueryParameter('presenter') === NULL) {
        $url->setQueryParameter('presenter', 'querypresenter');
    }
    $url->appendQuery(['test' => 'testvalue']);
    $httpRequest = new Nette\Http\Request($url);
    $request = $route->match($httpRequest);
    if ($request) {
        // matched
        $params = $request->getParameters();
        asort($params);
        asort($expectedParams);
        Assert::same($expectedPresenter, $request->getPresenterName());
        Assert::same($expectedParams, $params);
        $result = $route->constructUrl($request, $url);
        Assert::same($expectedUrl, $result);
    } else {
        // not matched
        Assert::null($expectedPresenter);
    }
}
Exemplo n.º 3
0
 function testExport()
 {
     Helper::$presenter->forceAjaxMode = FALSE;
     $params = $this->params + array('do' => 'grid-export-export');
     ob_start();
     Helper::request($params)->send(mock('\\Nette\\Http\\IRequest'), new \Nette\Http\Response());
     $output = ob_get_clean();
     Assert::same(file_get_contents(__DIR__ . "/files/export.expect"), $output);
 }
Exemplo n.º 4
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]);
     }
 }
Exemplo n.º 5
0
 private function assertLimit(IDataSource $source)
 {
     $all = $source->fetchAll();
     Assert::count(self::LIMIT, $all);
     Assert::count(self::FULL_USER_COUNT, $source->fetchFullData());
     Assert::count(self::FULL_USER_COUNT, $source->fetchAllForExport());
     Assert::same(self::FULL_USER_COUNT, $source->getTotalCount());
     Assert::same(self::LIMIT, $source->count());
     return $all;
 }
Exemplo n.º 6
0
 function testExport()
 {
     Helper::$presenter->forceAjaxMode = FALSE;
     $params = $this->params + array('do' => 'grid-export-export');
     ob_start();
     Helper::request($params)->send(mock('\\Nette\\Http\\IRequest'), new \Nette\Http\Response());
     $output = ob_get_clean();
     //@todo - resolve this wtf? different sorting (dibi, nette db, doctrine) vs (array source)
     $type = in_array(get_called_class(), array('Grido\\Tests\\ArraySourceTest')) ? '.array' : '';
     Assert::same(file_get_contents(__DIR__ . "/files/export{$type}.expect"), $output);
 }
Exemplo n.º 7
0
 public function testBasicFunctionality()
 {
     $inputData = ['courier' => ['name' => 'Nikola Tesla'], 'checkpoints' => [['type' => 'source', 'arrivalExpected' => '2014-10-16 19:00:00 +0200', 'arrivalReal' => '2014-10-16 19:00:00 +0200', 'departureReal' => NULL, 'estimatedDelay' => 0], ['type' => 'destination', 'arrivalExpected' => NULL, 'arrivalReal' => NULL, 'departureReal' => NULL, 'estimatedDelay' => 0]], 'isWarrantyClaim' => TRUE, 'orderId' => 12345678];
     $orderTimesDTO = new OrderTimesDTO($inputData);
     Assert::same('Nikola Tesla', $orderTimesDTO->getCourierName());
     Assert::equal(new \DateTime('2014-10-16 19:00:00 +0200'), $orderTimesDTO->getSourceCheckpoint()['arrivalExpected']);
     Assert::equal(new \DateTime('2014-10-16 19:00:00 +0200'), $orderTimesDTO->getSourceCheckpoint()['arrivalReal']);
     Assert::same(NULL, $orderTimesDTO->getSourceCheckpoint()['departureReal']);
     Assert::same(0, $orderTimesDTO->getSourceCheckpoint()['estimatedDelay']);
     Assert::same(NULL, $orderTimesDTO->getDestinationCheckpoint()['arrivalExpected']);
     Assert::same(NULL, $orderTimesDTO->getDestinationCheckpoint()['arrivalReal']);
     Assert::same(NULL, $orderTimesDTO->getDestinationCheckpoint()['departureReal']);
     Assert::same(0, $orderTimesDTO->getDestinationCheckpoint()['estimatedDelay']);
     Assert::same(TRUE, $orderTimesDTO->isIsWarrantyClaim());
 }
Exemplo n.º 8
0
 public function testExportFiltered()
 {
     $data = $this->data;
     $callback = function ($source) use($data) {
         Assert::same($data, $source);
     };
     $export = $this->grid->addExportCallback('Export', $callback, TRUE);
     $this->grid->addFilterText('name', 'Name');
     $grid = $this->grid;
     $trigger = function () use($grid) {
         $this->grid->handleExport(1);
     };
     Assert::exception($trigger, 'Ublaboo\\DataGrid\\Exception\\DataGridException', 'You have to set a data source first.');
     $this->grid->setDataSource($this->data);
     $this->grid->handleExport(1);
 }
Exemplo n.º 9
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.º 10
0
 public function testTotalCount()
 {
     $source = new NetteDbTableSource($this->tableName, 'id', $this->user, $this->context);
     Assert::same(self::FULL_USER_COUNT, $source->getTotalCount());
 }
Exemplo n.º 11
0
 /**
  * @dataProvider dataObjectClasses
  */
 public function testGetId($class)
 {
     $metadata = $this->getMetadataFor($class);
     $className = 'Tests\\NForms\\Models\\' . $class;
     $object = new $className();
     Assert::same(NULL, $metadata->getId($object));
     $object->id = '123';
     Assert::same('123', $metadata->getId($object));
 }
Exemplo n.º 12
0
 /**
  * @Then /^u?vidím (komponentu|stránku) (.+)$/
  */
 public function willSeeComponent($type, $componentName)
 {
     $page = $this->getCurrentPage();
     switch ($type) {
         case 'komponentu':
             if ($page instanceof ComponentElement) {
                 // mam primo komponentu
                 Assert::same($componentName, $page->getName());
                 //if ($componentName === $page->getName()) return; // ok
             } elseif ($page instanceof PageElement) {
                 if (!$page->tryFindComponent($componentName)) {
                     Assert::fail("Komponenta '{$componentName}' nenalezena");
                 }
                 // jinak ok
             } else {
                 Assert::fail("Expected a component '{$componentName}', but got something else: " . get_class($page));
             }
             break;
         case 'stránku':
             if ($page instanceof ComponentElement) {
                 Assert::fail("Expected page, component");
             }
             Assert::same($componentName, $page->getName());
             break;
         default:
             throw new \InvalidArgumentException();
     }
 }
Exemplo n.º 13
0
 public function __construct($a, $b, $c)
 {
     \Tester\Assert::type(\Mrtnzlml\Tests\Service2::class, $a);
     \Tester\Assert::same(159753, $b);
     \Tester\Assert::same('%', $c);
 }
 protected function assertBuilder($expected, QueryBuilder $builder)
 {
     $args = $builder->getQueryParameters();
     array_unshift($args, $builder->getQuerySql());
     Assert::same($expected, $args);
 }
Exemplo n.º 15
0
 public function assertDetached(Mesour\Components\ComponentModel\IContainer $parent)
 {
     Assert::same($this->detachedContains, $parent);
 }
Exemplo n.º 16
0
<?php

require_once __DIR__ . '/../vendor/autoload.php';
use Bazo\Trustpay\Api\Client;
use Tester\Assert;
$aid = '9876543210';
$ref = '1234567890';
$key = 'abcd1234';
$amount = 123.45;
$currency = Bazo\Trustpay\Currency::EUR;
$client = new Client($aid, $key, $currency, $mode = Client::MODE_TEST);
$url = $client->generatePaymentURI($amount, Bazo\Trustpay\Language::SLOVAK, $ref);
$expected = 'https://test.trustpay.eu/mapi/pay.aspx?AID=9876543210&AMT=123.45&CUR=EUR&REF=1234567890&SIG=DF174E635DABBFF7897A82822521DD739AE8CC2F83D65F6448DD2FF991481EA3&LNG=sk&DSC=';
Assert::same($expected, $url);
Exemplo n.º 17
0
<?php

require __DIR__ . '/../bootstrap.php';
use Tester\Assert;
$sniff = 'cs.Namespaces.UseDeclaration';
$cs = runPhpcs($sniff, <<<CONTENT
<?php
use A,
\tB;


//
CONTENT
);
Assert::same(array('MultipleDeclarations'), $cs->rules);
$cs = runPhpcs($sniff, <<<CONTENT
<?php

use Bar;
class Foo {}
CONTENT
);
Assert::same(array('SpaceAfterLastUse'), $cs->rules);
Exemplo n.º 18
0
 /**
  * @param  ITemplate  $html
  * @param  string     $wwwDir
  * @return Nette\Mailer\Message
  */
 public function create(ITemplate $html, $wwwDir = NULL)
 {
     $html->setFile(__DIR__ . '/templates/message.latte');
     Assert::same($wwwDir, $html->wwwDir);
     return (new \Nette\Mail\Message())->setHtmlBody($html->__toString(1), $wwwDir)->addTo('*****@*****.**');
 }
Exemplo n.º 19
0
 /**
  * Checks assertion. Values must be exactly the same.
  * @param mixed $expected
  * @param mixed $actual
  * @return void
  */
 public function assertSame($expected, $actual)
 {
     Assert::same($expected, $actual);
 }
Exemplo n.º 20
0
 public final function testcoderPassing()
 {
     $coder = new Bitbang\Http\Coders\DefaultCoder();
     $response = $this->createClient()->process(new Request('GET', $this->baseUrl . '/200', [], NULL, $coder));
     Assert::same($coder, $response->getCoder());
 }
Exemplo n.º 21
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);
 }
Exemplo n.º 22
0
 public function handleChangeArrayRequired(array $page)
 {
     $this->handleCalled = true;
     Assert::same($page, Mesour\ComponentsTests\HandlesTest::$testArr);
 }
Exemplo n.º 23
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");
Exemplo n.º 24
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;
 }