1 | <?php declare(strict_types = 1); |
||||||
2 | |||||||
3 | namespace Apicart\FQL\Tests\Tokenizer; |
||||||
4 | |||||||
5 | use Apicart\FQL\Tokenizer\AbstractTokenExtractor; |
||||||
6 | use Apicart\FQL\Tokenizer\Full; |
||||||
7 | use Apicart\FQL\Tokenizer\Text; |
||||||
8 | use Apicart\FQL\Tokenizer\Tokenizer; |
||||||
9 | use PHPUnit\Framework\TestCase; |
||||||
10 | use ReflectionClass; |
||||||
11 | use RuntimeException; |
||||||
12 | |||||||
13 | final class TokenizerTest extends TestCase |
||||||
14 | { |
||||||
15 | |||||||
16 | public function testExtractThrowsExceptionPCRE(): void |
||||||
17 | { |
||||||
18 | self::expectException(RuntimeException::class); |
||||||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||||||
19 | self::expectExceptionMessage('PCRE regex error code: 2'); |
||||||
0 ignored issues
–
show
The method
PHPUnit\Framework\TestCa...xpectExceptionMessage() is not static, but was called statically.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
20 | |||||||
21 | $extractorMock = $this->getMockBuilder(AbstractTokenExtractor::class) |
||||||
0 ignored issues
–
show
The function
PHPUnit\Framework\MockOb...ckBuilder::setMethods() has been deprecated: https://github.com/sebastianbergmann/phpunit/pull/3687
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This function has been deprecated. The supplier of the function has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead. ![]() |
|||||||
22 | ->setMethods(['getExpressionTypeMap']) |
||||||
23 | ->getMockForAbstractClass(); |
||||||
24 | |||||||
25 | $extractorMock->expects(self::once()) |
||||||
26 | ->method('getExpressionTypeMap') |
||||||
27 | ->willReturn([ |
||||||
28 | '/(?:\D+|<\d+>)*[!?]/' => Tokenizer::TOKEN_WHITESPACE, |
||||||
29 | ]); |
||||||
30 | |||||||
31 | /** @var AbstractTokenExtractor $extractor */ |
||||||
32 | $extractor = $extractorMock; |
||||||
33 | $extractor->extract('foobar foobar foobar', 0); |
||||||
34 | } |
||||||
35 | |||||||
36 | |||||||
37 | public function testFullExtractTermTokenThrowsException(): void |
||||||
38 | { |
||||||
39 | self::expectException(RuntimeException::class); |
||||||
0 ignored issues
–
show
The method
PHPUnit\Framework\TestCase::expectException() is not static, but was called statically.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
40 | self::expectExceptionMessage('Could not extract term token from the given data'); |
||||||
0 ignored issues
–
show
The method
PHPUnit\Framework\TestCa...xpectExceptionMessage() is not static, but was called statically.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
41 | |||||||
42 | $extractor = new Full(); |
||||||
43 | $reflectedClass = new ReflectionClass($extractor); |
||||||
44 | $reflectedProperty = $reflectedClass->getProperty('expressionTypeMap'); |
||||||
45 | $reflectedProperty->setAccessible(true); |
||||||
46 | $reflectedProperty->setValue([ |
||||||
47 | '/(?<lexeme>foobar)/' => Tokenizer::TOKEN_TERM, |
||||||
48 | ]); |
||||||
49 | $extractor->extract('foobar', 0); |
||||||
50 | } |
||||||
51 | |||||||
52 | |||||||
53 | public function testTextExtractTermTokenThrowsException(): void |
||||||
54 | { |
||||||
55 | self::expectException(RuntimeException::class); |
||||||
0 ignored issues
–
show
The method
PHPUnit\Framework\TestCase::expectException() is not static, but was called statically.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
56 | self::expectExceptionMessage('Could not extract term token from the given data'); |
||||||
0 ignored issues
–
show
The method
PHPUnit\Framework\TestCa...xpectExceptionMessage() is not static, but was called statically.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
57 | |||||||
58 | $extractor = new Text(); |
||||||
59 | $reflectedClass = new ReflectionClass($extractor); |
||||||
60 | $reflectedProperty = $reflectedClass->getProperty('expressionTypeMap'); |
||||||
61 | $reflectedProperty->setAccessible(true); |
||||||
62 | $reflectedProperty->setValue([ |
||||||
63 | '/(?<lexeme>foobar)/' => Tokenizer::TOKEN_TERM, |
||||||
64 | ]); |
||||||
65 | $extractor->extract('foobar', 0); |
||||||
66 | } |
||||||
67 | |||||||
68 | } |
||||||
69 |