feat: add content package value object
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace WPContentSync\Tests\Unit\Package;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use WPContentSync\Package\ContentPackage;
|
||||
|
||||
class ContentPackageTest extends TestCase {
|
||||
public function test_it_normalizes_package_arrays(): void {
|
||||
$package = ContentPackage::fromArray(
|
||||
array(
|
||||
'schema_version' => '1.0',
|
||||
'generated_at' => '2026-04-26T20:30:00+00:00',
|
||||
'source' => array(
|
||||
'site_url' => 'https://example.test',
|
||||
'name' => 'Example Production',
|
||||
),
|
||||
'destination' => array(
|
||||
'site_url' => 'https://staging.example.test',
|
||||
'name' => 'Example Staging',
|
||||
),
|
||||
'manifest' => array(
|
||||
'posts' => 1,
|
||||
'terms' => 0,
|
||||
'media' => 0,
|
||||
'custom_post_types' => 0,
|
||||
),
|
||||
'records' => array(
|
||||
'posts' => array(
|
||||
array(
|
||||
'id' => 123,
|
||||
'type' => 'post',
|
||||
),
|
||||
),
|
||||
'terms' => array(),
|
||||
'media' => array(),
|
||||
'custom_post_types' => array(),
|
||||
),
|
||||
'checksums' => array(
|
||||
'records' => 'sha256:abc123',
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
self::assertSame( '1.0', $package->schemaVersion() );
|
||||
self::assertSame( '2026-04-26T20:30:00+00:00', $package->generatedAt() );
|
||||
self::assertSame( 'https://example.test', $package->source()['site_url'] );
|
||||
self::assertSame( 'https://staging.example.test', $package->destination()['site_url'] );
|
||||
self::assertSame( 1, $package->manifest()['posts'] );
|
||||
self::assertSame( 123, $package->records()['posts'][0]['id'] );
|
||||
self::assertSame( 'sha256:abc123', $package->checksums()['records'] );
|
||||
self::assertSame( $package->toArray(), ContentPackage::fromArray( $package->toArray() )->toArray() );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user