37 lines
1.2 KiB
PHP
37 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Models;
|
|
|
|
use App\Actions\Git\GitProviderKey;
|
|
use App\Models\RepositoryConnection;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
class RepositoryConnectionTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
/**
|
|
* Ensure the repository connection factory creates a project-scoped Gitea link.
|
|
*/
|
|
public function test_factory_creates_a_project_repository_connection(): void
|
|
{
|
|
$repositoryConnection = RepositoryConnection::factory()->create();
|
|
|
|
$this->assertSame(GitProviderKey::Gitea, $repositoryConnection->fresh()->provider);
|
|
$this->assertNotNull($repositoryConnection->project_id);
|
|
$this->assertNotSame('', $repositoryConnection->repository_full_name);
|
|
}
|
|
|
|
/**
|
|
* Ensure repository connections belong to a project.
|
|
*/
|
|
public function test_repository_connections_belong_to_a_project(): void
|
|
{
|
|
$repositoryConnection = RepositoryConnection::factory()->create();
|
|
|
|
$this->assertTrue($repositoryConnection->project()->exists());
|
|
$this->assertTrue($repositoryConnection->project->is($repositoryConnection->fresh()->project));
|
|
}
|
|
}
|