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

Checks assertion. The identity of objects and the order of keys in the arrays are ignored.
public static equal ( $expected, $actual, $description = NULL ) : void
Результат void
Пример #1
0
 /**
  * @eventListener onFoo
  * @param int $one
  * @param int $two
  * @param int $three
  */
 public function onFoo($one, $two, $three)
 {
     Assert::equal(1, $one);
     Assert::equal(2, $two);
     Assert::equal(3, $three);
     $this->called = TRUE;
 }
Пример #2
0
 protected function matchOffset(IDataSource $source)
 {
     $source->applyLimit(self::LIMIT, self::OFFSET);
     $all_data = $this->assertLimit($source);
     $first_user = reset($all_data);
     Assert::equal((string) (self::OFFSET + 1), (string) $first_user['user_id']);
 }
Пример #3
0
 /**
  * @param $expected
  * @return $this
  */
 public function values($expected)
 {
     $values = $this->objectToArray($this->getObject()->getValues());
     $expected = $this->objectToArray($expected);
     Assert::equal($expected, $values);
     return $this;
 }
Пример #4
0
 public function testDelete()
 {
     $req = Request::create($this->baseDomain . '/test/1', Methods::DELETE);
     $app = new App(NULL, $req);
     $app->attach($this->router);
     $app->run();
     \Tester\Assert::equal('DELETE 1', $this->callResult);
 }
Пример #5
0
 /**
  * @param string $expectedJson
  * @param string $input
  */
 public static function json($expectedJson, $input)
 {
     $decodedExpectedJson = self::jsonDecode($expectedJson, 'Expected-json');
     $decodedInput = self::jsonDecode($input, 'Input-json');
     try {
         Assert::equal($decodedExpectedJson, $decodedInput);
     } catch (AssertException $e) {
         throw new AssertException('%1 should be equal to %2', self::makeJsonPretty($expectedJson), self::makeJsonPretty($input));
     }
 }
Пример #6
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());
 }
Пример #7
0
 public function testFetch()
 {
     $source = new ArraySource('users', 'id', self::$user);
     Assert::equal($source->fetch(), ArrayHash::from(reset(self::$user)));
 }
Пример #8
0
 private function validateArguments(array $actualArguments)
 {
     if (count($actualArguments) != count($this->arguments)) {
         throw new UnexpectedStateException("Unexpected number of arguments passed to {$this->methodName}()");
     }
     $i = 0;
     foreach ($this->arguments as $expectedArg) {
         $actualArg = $actualArguments[$i++];
         if ($expectedArg instanceof ArgumentMatcher) {
             if (!$expectedArg->match($actualArg)) {
                 throw new UnexpectedStateException("Argument {$i} passed to {$this->methodName}() was not expected");
             }
         } else {
             try {
                 \Tester\Assert::equal($expectedArg, $actualArg);
             } catch (\Tester\AssertException $e) {
                 throw new UnexpectedStateException("Argument {$i} passed to {$this->methodName}() was not expected");
             }
         }
     }
 }
Пример #9
0
 public function testReferencedData()
 {
     $selection = clone $this->user;
     $selection->select('users.*');
     $source = new NetteDbTableSource($this->tableName, 'id', $selection, $this->context, $this->columnMapping);
     $dataStructure = $source->getDataStructure();
     $dataStructure->renameColumn('user_addresses', 'addresses');
     $dataStructure->renameColumn('groups', 'group');
     $dataStructure->renameColumn('wallets', 'wallet');
     /** @var ManyToManyColumnStructure $companiesColumn */
     $companiesColumn = $dataStructure->getColumn('companies');
     $companiesColumn->setPattern('{name}');
     /** @var OneToManyColumnStructure $addressesColumn */
     $addressesColumn = $dataStructure->getColumn('addresses');
     $addressesColumn->setPattern('{street}, {zip} {city}, {country}');
     /** @var ManyToOneColumnStructure $groupColumn */
     $groupColumn = $dataStructure->getColumn('group');
     $groupColumn->setPattern('{name} - {type}');
     /** @var OneToOneColumnStructure $walletColumn */
     $walletColumn = $dataStructure->getColumn('wallet');
     $walletColumn->setPattern('{amount}');
     $item = $source->fetchAll();
     Assert::equal(reset($item), $firstItem = $source->fetch());
     Assert::count(self::COLUMN_COUNT, array_keys((array) $firstItem));
     Assert::count(3, $firstItem['companies']);
     Assert::equal($this->getFirstExpectedCompany(), $firstItem['companies'][0]);
     Assert::equal($this->getFirstExpectedAddress(), $firstItem['addresses'][0]);
     Assert::equal($this->getFirstExpectedGroup(), $firstItem['group']);
     Assert::equal($this->getFirstExpectedWallet(), $firstItem['wallet']);
 }
Пример #10
0
<?php

use Bazo\Iban\IbanGenerator;
use Tester\Environment;
use Tester\Assert;
require_once '../vendor/autoload.php';
Environment::setup();
$ibanGenerator = new IbanGenerator();
//fails
Assert::equal(FALSE, $ibanGenerator->generate('1234567', '1234', '1234'));
Assert::equal(FALSE, $ibanGenerator->generate('123456', '1', '1234'));
Assert::equal(FALSE, $ibanGenerator->generate('123456', '12345678901', '1234'));
Assert::equal(FALSE, $ibanGenerator->generate('', '1234', '123'));
//correct
Assert::equal('SK0575000000190122334455', $ibanGenerator->generate(19, '122334455', '7500'));
Assert::equal('SK6202000000000122334455', $ibanGenerator->generate('', '122334455', '0200'));
Assert::equal('SK6480200000001100615760', $ibanGenerator->generate('', '1100615760', '8020'));
Пример #11
0
 public function testFileBig_LargerThen2_32bites()
 {
     Assert::equal(TESTS_BIG_FILE_SIZE, (string) $this->driver->getFileSize(TESTS_BIG_FILE_PATH), "Driver " . get_class($this->getDriver()) . " failed for file with size over 2^32 bites");
 }
Пример #12
0
 protected function matchOffset(ISource $source)
 {
     $source->applyLimit(self::LIMIT, self::OFFSET);
     $allData = $this->assertLimit($source);
     $firstUser = reset($allData);
     Assert::equal((string) (self::OFFSET + 1), (string) $firstUser[self::OWN_PRIMARY_KEY]);
 }
Пример #13
0
 public static function is($expected)
 {
     return static::match(function ($arg) use($expected) {
         Assert::equal($expected, $arg);
     });
 }
Пример #14
0
Assert::equal(['0' => 'b'], (new Map([false, 'b']))->toAssocArray());
Assert::equal(['a' => 'b'], (new Map([new Keyword('a'), 'b']))->toAssocArray());
function ct()
{
    return new Transit(new JSONReader(true), new JSONWriter(true));
}
function cr($input)
{
    return ct()->read($input);
}
function cw($input)
{
    return ct()->write($input);
}
// use assoc arrays instead of maps
Assert::equal([], cr('["^ "]'));
Assert::equal(['foo' => 'bar'], cr('["^ ","foo","bar"]'));
Assert::equal([6 => 'six'], cr('["^ ","~i6","six"]'));
Assert::equal(['1.25' => 'x'], cr('["^ ","~d1.25","x"]'));
Assert::equal(['1' => 'x'], cr('["^ ","~?t","x"]'));
Assert::equal(['0' => 'x'], cr('["^ ","~?f","x"]'));
Assert::equal(['' => 'x'], cr('["^ ","~_","x"]'));
Assert::equal(['a' => 'b'], cr('["^ ","~$a","b"]'));
Assert::equal(['a' => 'b'], cr('["^ ","~:a","b"]'));
Assert::equal(new Map([['a'], 'b']), cr('["~#cmap",[["a"],"b"]]'));
Assert::equal(new Map([new Set(['a']), 'b']), cr('["~#cmap",[["~#set",["a"]],"b"]]'));
Assert::equal(new Map([['foo' => 'bar'], 'b']), cr('["~#cmap",[["^ ","foo","bar"],"b"]]'));
Assert::equal('["^ ","key","value"]', cw(['key' => 'value']));
Assert::equal('["^ ","~i0","a","x","b"]', cw([0 => 'a', 'x' => 'b']));
Assert::equal('["a","b"]', cw([0 => 'a', '1' => 'b']));
Пример #15
0
 /**
  * @param $expected
  * @param $selector
  * @param $attribute
  * @return $this
  */
 public function xpathContainsAttribute($expected, $selector, $attribute)
 {
     if (!($el = $this->getObject()->xpath($selector))) {
         Assert::fail("Selector '{$selector}' does not exist.");
     }
     $attrs = (array) $el[0]->attributes();
     $attrs = $attrs['@attributes'];
     if (!isset($attrs[$attribute])) {
         Assert::fail("Attribute '{$attribute}' does not exist.");
     }
     Assert::equal($expected, $attrs[$attribute]);
     return $this;
 }
Пример #16
0
        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));
/**
 * HIDE ITEM *******************************************************************