39 lines
1.2 KiB
PHP
39 lines
1.2 KiB
PHP
<?php
|
|
/**
|
|
* Tests for sync operation context.
|
|
*
|
|
* @package WPContentSync
|
|
*/
|
|
|
|
namespace WPContentSync\Tests\Unit\Sync;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use WPContentSync\Sync\SyncContext;
|
|
|
|
class SyncContextTest extends TestCase {
|
|
public function test_it_builds_import_context_from_package_sites(): void {
|
|
$context = SyncContext::forImport(
|
|
array( 'site_url' => 'https://source.test' ),
|
|
array( 'site_url' => 'https://destination.test' ),
|
|
'last_write_wins',
|
|
'operation-1'
|
|
);
|
|
|
|
self::assertSame( 'import', $context->direction() );
|
|
self::assertSame( 'operation-1', $context->operationId() );
|
|
self::assertSame( 'last_write_wins', $context->conflictStrategy() );
|
|
self::assertSame( 'https://source.test', $context->sourceUrl() );
|
|
self::assertSame( 'https://destination.test', $context->destinationUrl() );
|
|
self::assertSame(
|
|
array( 'https://source.test' => 'https://destination.test' ),
|
|
$context->urlMappings()
|
|
);
|
|
}
|
|
|
|
public function test_it_falls_back_to_last_write_wins_for_invalid_strategy(): void {
|
|
$context = SyncContext::forImport( array(), array(), 'surprise', 'operation-2' );
|
|
|
|
self::assertSame( 'last_write_wins', $context->conflictStrategy() );
|
|
}
|
|
}
|