b5c939e9e4
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
47 lines
1.6 KiB
PHP
47 lines
1.6 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace Cf7stg\Tests;
|
|
|
|
use Cf7stg\Classifier;
|
|
|
|
final class ClassifierDropTest extends Cf7stgTestCase
|
|
{
|
|
public function test_has_valid_email_anywhere_finds_gmail(): void
|
|
{
|
|
$fields = ['some-key' => 'pasha@gmail.com'];
|
|
self::assertTrue(Classifier::has_valid_email_anywhere($fields));
|
|
}
|
|
|
|
public function test_has_valid_email_anywhere_finds_in_array_value(): void
|
|
{
|
|
$fields = ['x' => ['noise', 'info@some-domain.com']];
|
|
self::assertTrue(Classifier::has_valid_email_anywhere($fields));
|
|
}
|
|
|
|
public function test_has_valid_email_anywhere_returns_false_for_invalid(): void
|
|
{
|
|
$fields = ['email' => 'not-an-email', 'x' => 'AB'];
|
|
self::assertFalse(Classifier::has_valid_email_anywhere($fields));
|
|
}
|
|
|
|
public function test_has_valid_email_anywhere_returns_false_when_empty(): void
|
|
{
|
|
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));
|
|
}
|
|
}
|