className()); self::assertSame('et_pb_is_allowed', $function->member()); self::assertSame('et_pb_is_allowed()', $function->label()); self::assertSame('ET\Builder\Packages\GlobalData\GlobalData', $method->className()); self::assertSame('get_global_colors', $method->member()); self::assertSame('GlobalData::get_global_colors()', $method->label()); self::assertSame('ET_Core_PageResource', (new Call('\ET_Core_PageResource::remove_static_resources', 3))->className()); } public function testMirrorLabel(): void { $function = new Mirror('tb-api-save', 'includes/api.php', 'et_theme_builder_api_save', null, 'Vorlagenliste'); $method = new Mirror('vb-flags', 'x.php', 'update', 'SyncToServerController', 'Kennzeichen'); self::assertSame('et_theme_builder_api_save()', $function->label()); self::assertSame('SyncToServerController::update()', $method->label()); } public function testNamesListEveryDeclaredDiviName(): void { $manifest = new Manifest( DiviAreas::LIBRARY, calls: [new Call('et_pb_is_allowed', 1), new Call('ET\Builder\GlobalLayout::is_global_layout_template', 1)], constants: ['ET_BUILDER_PRODUCT_VERSION'], postTypes: ['et_pb_layout'], taxonomies: ['scope'], blockTypes: ['divi/global-layout'], keys: ['_et_pb_module_type'] ); self::assertSame( ['et_pb_is_allowed', 'ET\Builder\GlobalLayout', 'ET_BUILDER_PRODUCT_VERSION', 'et_pb_layout', 'scope', '_et_pb_module_type'], $manifest->names() ); self::assertSame('Bibliothek', $manifest->area); } public function testPlainConstantNamesBecomeRequirementsWithALabel(): void { $manifest = new Manifest( DiviAreas::CATALOG, constants: ['ET_BUILDER_PRODUCT_VERSION', new ConstantRequirement('ET_OTHER', [DiviFeature::Roles])] ); self::assertSame( ['ET_BUILDER_PRODUCT_VERSION', 'ET_OTHER'], array_map(static fn (ConstantRequirement $constant): string => $constant->name, $manifest->constants) ); self::assertSame('Konstante ET_OTHER', $manifest->constants[1]->label()); self::assertSame([], $manifest->constants[0]->features()); self::assertSame([DiviFeature::Roles], $manifest->constants[1]->features()); self::assertSame(['ET_BUILDER_PRODUCT_VERSION', 'ET_OTHER'], $manifest->names()); } public function testRequirementsAreCallsConstantsAndMirrorsInThatOrder(): void { $call = new Call('et_pb_is_allowed', 1); $mirror = new Mirror('m', 'a.php', 'a', null, 'Terme'); $manifest = new Manifest(DiviAreas::LIBRARY, calls: [$call], constants: ['ET_X'], mirrors: [$mirror]); $requirements = $manifest->requirements(); self::assertCount(3, $requirements); self::assertSame($call, $requirements[0]); self::assertSame('Konstante ET_X', $requirements[1]->label()); self::assertSame($mirror, $requirements[2]); } public function testFeaturesOfPrefersTheOwnFeaturesOverTheManifestDefault(): void { $own = new Call('et_a', null, [DiviFeature::PageWrite, DiviFeature::ThemeBuilderWrite]); $inherited = new Call('et_b'); $mirror = new Mirror('m', 'a.php', 'a', null, 'x', [DiviFeature::LibraryWrite]); $manifest = new Manifest( DiviAreas::PAGES, calls: [$own, $inherited], constants: ['ET_X'], mirrors: [$mirror], features: [DiviFeature::PageRead] ); self::assertSame([DiviFeature::PageWrite, DiviFeature::ThemeBuilderWrite], $manifest->featuresOf($own)); self::assertSame([DiviFeature::PageRead], $manifest->featuresOf($inherited)); self::assertSame([DiviFeature::PageRead], $manifest->featuresOf($manifest->constants[0])); self::assertSame([DiviFeature::LibraryWrite], $manifest->featuresOf($mirror)); } public function testWithoutAnyFeaturesAnEntryHasNone(): void { $call = new Call('et_a'); self::assertSame([], (new Manifest(DiviAreas::PAGES, calls: [$call]))->featuresOf($call)); } public function testGlobalsAreRequirementsAndNames(): void { $manifest = new Manifest(DiviAreas::PAGES, globals: [new GlobalRequirement('wp_cache_clear_cache')]); self::assertSame('wp_cache_clear_cache', $manifest->names()[0]); self::assertSame('Globale Variable wp_cache_clear_cache', $manifest->requirements()[0]->label()); } }