Initial import from aternosorg/codex-minecraft
This commit is contained in:
40
test/tests/Detective/WeightedSinglePatternDetectorTest.php
Normal file
40
test/tests/Detective/WeightedSinglePatternDetectorTest.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Aternos\Codex\Test\Tests\Detective;
|
||||
|
||||
use Aternos\Codex\Detective\WeightedSinglePatternDetector;
|
||||
use Aternos\Codex\Log\File\StringLogFile;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class WeightedSinglePatternDetectorTest extends TestCase
|
||||
{
|
||||
public function testDetect(): void
|
||||
{
|
||||
$this->assertEquals(1, (new WeightedSinglePatternDetector())
|
||||
->setLogFile(new \Aternos\Codex\Log\File\PathLogFile(__DIR__ . '/../../data/simple.log'))
|
||||
->setPattern('/This/')
|
||||
->setWeight(1)
|
||||
->detect()
|
||||
);
|
||||
|
||||
$this->assertEquals(0.5, (new WeightedSinglePatternDetector())
|
||||
->setLogFile(new \Aternos\Codex\Log\File\PathLogFile(__DIR__ . '/../../data/simple.log'))
|
||||
->setPattern('/This/')
|
||||
->setWeight(0.5)
|
||||
->detect()
|
||||
);
|
||||
|
||||
$this->assertEquals(0, (new WeightedSinglePatternDetector())
|
||||
->setLogFile(new \Aternos\Codex\Log\File\PathLogFile(__DIR__ . '/../../data/simple.log'))
|
||||
->setPattern('/This/')
|
||||
->setWeight(0)
|
||||
->detect()
|
||||
);
|
||||
|
||||
$this->assertFalse((new WeightedSinglePatternDetector())
|
||||
->setLogFile(new StringLogFile("You cannot detect this."))
|
||||
->setPattern('/missing/')
|
||||
->detect()
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user