fix(classifier): iterate all email candidates per field; document method contract
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -29,4 +29,18 @@ final class ClassifierDropTest extends Cf7stgTestCase
|
||||
{
|
||||
self::assertFalse(Classifier::has_valid_email_anywhere([]));
|
||||
}
|
||||
|
||||
public function test_has_valid_email_anywhere_finds_email_embedded_in_text(): void
|
||||
{
|
||||
$fields = ['your-message' => 'reach me at user@domain.com thanks'];
|
||||
self::assertTrue(Classifier::has_valid_email_anywhere($fields));
|
||||
}
|
||||
|
||||
public function test_has_valid_email_anywhere_finds_second_email_when_first_invalid(): void
|
||||
{
|
||||
// First candidate is "alice@in" which is not a valid email; second is valid.
|
||||
// Without preg_match_all, the method would return false here.
|
||||
$fields = ['msg' => 'try alice@in or bob@example.com'];
|
||||
self::assertTrue(Classifier::has_valid_email_anywhere($fields));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user