8 use PHP_CodeSniffer\Files\File;
20 private $constantUsageSniff;
24 $this->fileMock = $this->createMock(File::class);
37 $tokens = $this->tokenizeString($fileContent);
38 $this->fileMock->expects($this->once())
39 ->method(
'findPrevious')
45 $this->fileMock->expects($this->once())
48 $this->fileMock->numTokens = count(
$tokens);
49 $this->fileMock->expects($this->exactly($numIncorrectUsages))
52 'Constants are not allowed as the first argument of translation function, use string literal instead',
56 $this->constantUsageSniff->process($this->fileMock, $stackPtr);
65 private function tokenizeString($fileContent)
68 $tokens = token_get_all($fileContent);
72 $snifferTokens[
$i][
'line'] = $lineNumber;
74 $trimmedContent = trim(
$content,
' ');
75 if ($trimmedContent == PHP_EOL || $trimmedContent == PHP_EOL . PHP_EOL) {
79 return $snifferTokens;
89 'incorrect_arguments.txt',
93 'correct_arguments.txt',
defined('TESTS_BP')||define('TESTS_BP' __DIR__
testProcessIncorrectArguments($file, $numIncorrectUsages)