mirror of
https://github.com/Karaka-Management/oms-Search.git
synced 2026-01-26 08:48:41 +00:00
49 lines
1.5 KiB
PHP
49 lines
1.5 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of PHP CS Fixer.
|
|
*
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
|
* Dariusz Rumiński <dariusz.ruminski@gmail.com>
|
|
*
|
|
* This source file is subject to the MIT license that is bundled
|
|
* with this source code in the file LICENSE.
|
|
*/
|
|
|
|
namespace PhpCsFixer\Tests\Test\Assert;
|
|
|
|
use PhpCsFixer\Tokenizer\Token;
|
|
use PhpCsFixer\Tokenizer\Tokens;
|
|
|
|
/**
|
|
* @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
|
|
*
|
|
* @internal
|
|
*/
|
|
trait AssertTokensTrait
|
|
{
|
|
private static function assertTokens(Tokens $expectedTokens, Tokens $inputTokens)
|
|
{
|
|
foreach ($expectedTokens as $index => $expectedToken) {
|
|
$inputToken = $inputTokens[$index];
|
|
|
|
static::assertTrue(
|
|
$expectedToken->equals($inputToken),
|
|
sprintf("The token at index %d must be:\n%s,\ngot:\n%s.", $index, $expectedToken->toJson(), $inputToken->toJson())
|
|
);
|
|
|
|
$expectedTokenKind = $expectedToken->isArray() ? $expectedToken->getId() : $expectedToken->getContent();
|
|
static::assertTrue(
|
|
$inputTokens->isTokenKindFound($expectedTokenKind),
|
|
sprintf(
|
|
'The token kind %s (%s) must be found in tokens collection.',
|
|
$expectedTokenKind,
|
|
\is_string($expectedTokenKind) ? $expectedTokenKind : Token::getNameForId($expectedTokenKind)
|
|
)
|
|
);
|
|
}
|
|
|
|
static::assertSame($expectedTokens->count(), $inputTokens->count(), 'Both collections must have the same length.');
|
|
}
|
|
}
|