Skip to content

Commit 9f0380d

Browse files
committed
Add Test for MultiPatternDetector
1 parent b489680 commit 9f0380d

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
namespace Aternos\Codex\Test\Tests\Detector;
4+
5+
use Aternos\Codex\Detective\MultiPatternDetector;
6+
use Aternos\Codex\Log\File\StringLogFile;
7+
use PHPUnit\Framework\TestCase;
8+
9+
class MultiPatternDetectorTest extends TestCase
10+
{
11+
public function testDetectSinglePattern(): void
12+
{
13+
$this->assertTrue((new MultiPatternDetector())
14+
->setLogFile(new StringLogFile("You can detect this."))
15+
->addPattern('/detect/')
16+
->detect()
17+
);
18+
}
19+
20+
public function testDetectMultiplePatterns(): void
21+
{
22+
$this->assertTrue((new MultiPatternDetector())
23+
->setLogFile(new StringLogFile("You can detect this and this."))
24+
->addPattern('/detect/')
25+
->addPattern('/and this/')
26+
->detect()
27+
);
28+
}
29+
30+
public function testNotDetectMissingFromMultiplePatterns(): void
31+
{
32+
$this->assertFalse((new MultiPatternDetector())
33+
->setLogFile(new StringLogFile("You can detect this and this."))
34+
->addPattern('/detect/')
35+
->addPattern('/and this/')
36+
->addPattern('/but not this/')
37+
->detect()
38+
);
39+
}
40+
}

0 commit comments

Comments
 (0)