RAWeb icon indicating copy to clipboard operation
RAWeb copied to clipboard

Add case-insensitive collation settings to SQLite test database

Open G3mha opened this issue 1 year ago • 0 comments

Describe the bug

Originated during discussion of PR #2854

SQLite test database uses case-sensitive collation while production MySQL uses case-insensitive, causing test failures for case-insensitive string operations.

To Reproduce Steps to reproduce the behavior:

  1. Go to file tests/Feature/Api/V1/UserSummaryTest.php and add the following test case:
public function testUsernameCaseConsistency(): void
{
    $user = User::factory()->create([
        'User' => 'NicoPlaysThings',
    ]);
    $variations = [
        'NICOPLAYSTHINGS',
        'nicoplaysthings',
        'NicoPlaysThings',
    ];

    foreach ($variations as $input) {
        $response = $this->get($this->apiUrl('GetUserSummary', ['u' => $input]));
        $response->assertOk()
                ->assertJsonPath('User', 'NicoPlaysThings')
                ->assertJsonPath('LastActivity.User', 'NicoPlaysThings')
                ->assertJsonPath('UserPic', '/UserPic/NicoPlaysThings.png');
    }
}
  1. Run the test involving case-insensitive username lookups:
php artisan test tests/Feature/Api/V1/UserSummaryTest.php --filter testUsernameCaseConsistency
  1. Observe test failure due to collation mismatch
  2. See PR #2854 for the complete discussion on this error

Expected behavior

  • SQLite test database should use case-insensitive collation matching MySQL's behavior
  • Tests should pass regardless of username case variations
  • UserSummary API tests should succeed with usernames like 'NICOPLAYSTHINGS', 'nicoplaysthings', 'NicoPlaysThings'

Additional context

  • MySQL uses _ci collation by default
  • SQLite test environment needs equivalent case-insensitive configuration
  • Issue affects test coverage as case-sensitivity tests must be omitted
  • Reference PR #2854 where this caused test coverage gaps
  • Environment: PHPUnit test suite using SQLite

G3mha avatar Nov 21 '24 13:11 G3mha