31 lines
1,000 B
PHP
31 lines
1,000 B
PHP
<?php
|
|
|
|
namespace App\Tests\Entity;
|
|
|
|
use App\Entity\ScriptMapping;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class ScriptMappingTest extends TestCase
|
|
{
|
|
public function testDefaultsAreUsableForNewMapping(): void
|
|
{
|
|
$mapping = new ScriptMapping();
|
|
|
|
self::assertSame('main', $mapping->getGitRef());
|
|
self::assertTrue($mapping->isActive());
|
|
self::assertSame('never_synced', $mapping->getLastSyncStatus());
|
|
self::assertNull($mapping->getLastSuccessfulSyncAt());
|
|
self::assertNull($mapping->getLastSyncError());
|
|
}
|
|
|
|
public function testSyncFailureDoesNotClearPreviousCacheKey(): void
|
|
{
|
|
$mapping = new ScriptMapping();
|
|
$mapping->setCacheKey('scripts/1.sh');
|
|
$mapping->markSyncFailed('git fetch failed');
|
|
|
|
self::assertSame('scripts/1.sh', $mapping->getCacheKey());
|
|
self::assertSame('failed', $mapping->getLastSyncStatus());
|
|
self::assertSame('git fetch failed', $mapping->getLastSyncError());
|
|
}
|
|
}
|