koel/tests/Helpers.php

31 lines
687 B
PHP
Raw Normal View History

2024-01-11 12:41:33 +00:00
<?php
namespace Tests;
use App\Models\User;
function create_user(array $attributes = []): User
{
return User::factory()->create($attributes);
}
function create_admin(array $attributes = []): User
{
return User::factory()->admin()->create($attributes);
}
2024-03-30 16:49:25 +00:00
function create_user_prospect(array $attributes = []): User
{
return User::factory()->prospect()->create($attributes);
}
2024-01-11 12:41:33 +00:00
function test_path(string $path = ''): string
{
return base_path('tests' . DIRECTORY_SEPARATOR . ltrim($path, DIRECTORY_SEPARATOR));
}
2024-03-19 22:48:12 +00:00
function read_as_data_url(string $path): string
{
return 'data:' . mime_content_type($path) . ';base64,' . base64_encode(file_get_contents($path));
}