1eedaa9b3c
- Drop hp_listing_core / hp_request_core / hp_vendor_core from TMDO_Post_Fields and hp_user from TMDO_Member_Fields; the HivePress AddOn registers identical definitions (PR-019/020a/033b) - Tests: core asserts it registers none of them; HP-specific core tests removed (covered by the AddOn); SyncBridgeEntityGuardTest registers its own hp_price group - Verify: core unit 633 / integration 449, HP 145/49, WC 10/22 OK - Deploy: activate the HivePress AddOn on dev20/21/22 first - PR: PR-020b
56 lines
2.4 KiB
PHP
56 lines
2.4 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
/**
|
|
* Which values the reconciler has to move.
|
|
*
|
|
* Under legacy routing a key shared by several post groups was read and
|
|
* written through the last group registered. Once lookups follow the post
|
|
* type, each scoped group must first receive the values its posts stored in
|
|
* that legacy owner's table.
|
|
*/
|
|
class PostGroupReconcilerPlanTest extends TestCase {
|
|
|
|
protected function setUp(): void {
|
|
TMDO_Entity_Registry::init();
|
|
TMDO_Entity_Registry::register_adapter( 'post', $this->createMock( TMDO_Entity_Adapter_Interface::class ) );
|
|
}
|
|
|
|
public function test_plan_lists_shared_keys_whose_legacy_owner_is_another_group(): void {
|
|
TMDO_Entity_Registry::register_group( 'post', 'listing', array( array( 'key' => 'shared', 'type' => 'text' ), array( 'key' => 'price', 'type' => 'decimal' ) ), array( 'post_types' => array( 'hp_listing' ) ) );
|
|
TMDO_Entity_Registry::register_group( 'post', 'vendor', array( array( 'key' => 'shared', 'type' => 'text' ) ), array( 'post_types' => array( 'hp_vendor' ) ) );
|
|
|
|
$this->assertSame(
|
|
array(
|
|
array(
|
|
'target' => 'listing',
|
|
'source' => 'vendor',
|
|
'key' => 'shared',
|
|
'post_types' => array( 'hp_listing' ),
|
|
),
|
|
),
|
|
TMDO_Post_Group_Reconciler::plan()
|
|
);
|
|
}
|
|
|
|
public function test_unscoped_groups_and_unshared_keys_need_no_move(): void {
|
|
TMDO_Entity_Registry::register_group( 'post', 'site', array( array( 'key' => '_edit_lock', 'type' => 'text' ) ) );
|
|
TMDO_Entity_Registry::register_group( 'post', 'listing', array( array( 'key' => 'price', 'type' => 'decimal' ) ), array( 'post_types' => array( 'hp_listing' ) ) );
|
|
|
|
$this->assertSame( array(), TMDO_Post_Group_Reconciler::plan() );
|
|
}
|
|
|
|
public function test_registry_exposes_group_post_types(): void {
|
|
TMDO_Entity_Registry::register_group( 'post', 'listing', array( array( 'key' => 'price', 'type' => 'decimal' ) ), array( 'post_types' => array( 'hp_listing' ) ) );
|
|
TMDO_Entity_Registry::register_group( 'post', 'site', array( array( 'key' => '_edit_lock', 'type' => 'text' ) ) );
|
|
|
|
$this->assertSame( array( 'hp_listing' ), TMDO_Entity_Registry::get_group_post_types( 'post', 'listing' ) );
|
|
$this->assertSame( array(), TMDO_Entity_Registry::get_group_post_types( 'post', 'site' ) );
|
|
|
|
TMDO_Entity_Registry::init();
|
|
$this->assertSame( array(), TMDO_Entity_Registry::get_group_post_types( 'post', 'listing' ) );
|
|
}
|
|
}
|