You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
szkp-map-service/tests/Unit/VenueAdminCredentialsTest.php

39 lines
1.3 KiB

<?php
namespace Tests\Unit;
use App\Support\VenueAdminCredentials;
use Tests\TestCase;
class VenueAdminCredentialsTest extends TestCase
{
public function test_same_venue_name_yields_different_random_passwords(): void
{
$name = '苏州青少年科技馆';
$first = VenueAdminCredentials::randomPassword();
$second = VenueAdminCredentials::randomPassword();
$this->assertNotSame($first, $second);
$this->assertSame(
VenueAdminCredentials::acronymFromVenueName($name),
VenueAdminCredentials::acronymFromVenueName($name)
);
}
public function test_random_password_meets_strength_rules(): void
{
$password = VenueAdminCredentials::randomPassword();
$this->assertGreaterThanOrEqual(12, strlen($password));
$this->assertMatchesRegularExpression('/[A-Z]/', $password);
$this->assertMatchesRegularExpression('/[a-z]/', $password);
$this->assertMatchesRegularExpression('/[0-9]/', $password);
$this->assertMatchesRegularExpression('/[^A-Za-z0-9]/', $password);
}
public function test_legacy_acronym_password_helper_is_removed(): void
{
$this->assertFalse(method_exists(VenueAdminCredentials::class, 'passwordFromAcronym'));
}
}