Skip to content
Snippets Groups Projects
Commit f0fc16b5 authored by Igor Melnikov's avatar Igor Melnikov
Browse files

MAGETWO-61240: Fix \Magento\Sniffs\Translation\ConstantUsageSniff

Fixing static test
parent 7da9b37d
Branches
No related merge requests found
......@@ -27,7 +27,7 @@ class ConstantUsageSniff implements \PHP_CodeSniffer_Sniff
}
/**
* Copied from \Generic_Sniffs_Files_LineLengthSniff
* Copied from \Generic_Sniffs_Files_LineLengthSniff, minor changes made
*
* {@inheritDoc}
*/
......@@ -35,7 +35,7 @@ class ConstantUsageSniff implements \PHP_CodeSniffer_Sniff
{
$tokens = $phpcsFile->getTokens();
// Make sure this is the first open tag.
// Make sure this is the first open tag
$previousOpenTag = $phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1));
if ($previousOpenTag !== false) {
return;
......@@ -45,19 +45,16 @@ class ConstantUsageSniff implements \PHP_CodeSniffer_Sniff
$currentLineContent = '';
$currentLine = 1;
$trim = (strlen($phpcsFile->eolChar) * -1);
for (; $tokenCount < $phpcsFile->numTokens; $tokenCount++) {
if ($tokens[$tokenCount]['line'] === $currentLine) {
$currentLineContent .= $tokens[$tokenCount]['content'];
} else {
$currentLineContent = substr($currentLineContent, 0, $trim);
$this->checkIfFirstArgumentConstant($phpcsFile, ($tokenCount - 1), $currentLineContent);
$currentLineContent = $tokens[$tokenCount]['content'];
$currentLine++;
}
}
$currentLineContent = substr($currentLineContent, 0, $trim);
$this->checkIfFirstArgumentConstant($phpcsFile, ($tokenCount - 1), $currentLineContent);
}
......
......@@ -43,7 +43,6 @@ class ConstantUsageSniffTest extends \PHPUnit_Framework_TestCase
$this->fileMock->expects($this->once())
->method('getTokens')
->willReturn($tokens);
$this->fileMock->eolChar = 2;
$this->fileMock->numTokens = count($tokens);
$this->fileMock->expects($this->exactly($numIncorrectUsages))
->method('addError')
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment