feat(wpmc S2): register ACF group list_shortcode for shortcode-town
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -26,4 +26,47 @@ final class FieldGroupTest extends TestCase
|
||||
|
||||
self::assertTrue(true, 'do_register must not call acf_add_local_field_group when ACF is missing');
|
||||
}
|
||||
|
||||
public function test_do_register_calls_acf_add_local_field_group_with_expected_structure(): void
|
||||
{
|
||||
\Brain\Monkey\Functions\when('function_exists')->alias(function ($name) {
|
||||
return $name === 'acf_add_local_field_group';
|
||||
});
|
||||
|
||||
$captured = null;
|
||||
\Brain\Monkey\Functions\expect('acf_add_local_field_group')
|
||||
->once()
|
||||
->with(\Mockery::on(function ($group) use (&$captured) {
|
||||
$captured = $group;
|
||||
return true;
|
||||
}));
|
||||
|
||||
FieldGroup::do_register();
|
||||
|
||||
self::assertSame('group_wpmc_shortcode_rows', $captured['key']);
|
||||
self::assertSame('WPMultiCity / Shortcode rows', $captured['title']);
|
||||
|
||||
self::assertCount(1, $captured['fields']);
|
||||
$repeater = $captured['fields'][0];
|
||||
|
||||
self::assertSame('field_wpmc_list_shortcode', $repeater['key']);
|
||||
self::assertSame('list_shortcode', $repeater['name']);
|
||||
self::assertSame('repeater', $repeater['type']);
|
||||
self::assertCount(2, $repeater['sub_fields']);
|
||||
|
||||
[$town, $text] = $repeater['sub_fields'];
|
||||
self::assertSame('town', $town['name']);
|
||||
self::assertSame('taxonomy', $town['type']);
|
||||
self::assertSame('town', $town['taxonomy']);
|
||||
self::assertSame('id', $town['return_format']);
|
||||
self::assertSame(0, $town['allow_null']);
|
||||
|
||||
self::assertSame('text', $text['name']);
|
||||
self::assertSame('textarea', $text['type']);
|
||||
|
||||
self::assertSame(
|
||||
[[['param' => 'post_type', 'operator' => '==', 'value' => 'shortcode-town']]],
|
||||
$captured['location']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user