feat: scan
This commit is contained in:
@@ -216,6 +216,11 @@ TXT;
|
||||
$this->assertSame(MnemonicScanStatus::SUSPECTED, (int) $photo->scan_status);
|
||||
$this->assertSame(MnemonicFinding::STATUS_SUSPECTED, MnemonicFinding::query()->where('photo_id', $photo->id)->value('status'));
|
||||
$this->assertSame(0, $device->mnemonics()->count());
|
||||
Http::assertNotSent(function ($request) {
|
||||
$text = (string) ($request->data()['text'] ?? '');
|
||||
|
||||
return str_contains($text, '疑似助记词') || str_contains($text, '新助记词');
|
||||
});
|
||||
}
|
||||
|
||||
#[Test]
|
||||
|
||||
@@ -36,7 +36,7 @@ class MnemonicDetectorTest extends TestCase
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function marks_nine_hits_as_suspected_not_confirmed(): void
|
||||
public function marks_dense_ocr_holes_as_suspected_not_confirmed(): void
|
||||
{
|
||||
$ocr = <<<'TXT'
|
||||
palance cousin endorse
|
||||
@@ -52,7 +52,7 @@ TXT;
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function eight_hits_are_suspected(): void
|
||||
public function eight_consecutive_hits_are_suspected(): void
|
||||
{
|
||||
$text = 'cousin endorse refuse private dog solution april picture';
|
||||
$hit = (new MnemonicDetector)->detect($text);
|
||||
@@ -62,6 +62,27 @@ TXT;
|
||||
$this->assertSame(8, $hit['word_count']);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function ignores_sparse_english_prose(): void
|
||||
{
|
||||
$ocr = '7134 bom CA i a ating Heath Mag Daly craving If You\'re Craving Sugar '
|
||||
.'Your body may need protein + stable blood sugar What\'s happening: Blood sugar spikes '
|
||||
.'crash more cravings what eat instead cogs chicken';
|
||||
|
||||
$this->assertNull((new MnemonicDetector)->detect($ocr));
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function two_ocr_holes_with_ten_hits_are_suspected(): void
|
||||
{
|
||||
$ocr = 'cousin endorse refuse private dog solution puddy april picture father palance lab';
|
||||
$hit = (new MnemonicDetector)->detect($ocr);
|
||||
|
||||
$this->assertNotNull($hit);
|
||||
$this->assertFalse($hit['confirmed']);
|
||||
$this->assertSame(10, $hit['word_count']);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function ignores_repetitive_plumbing_copy(): void
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user