|
59 | 59 |
|
60 | 60 | expect($config->getConfigValue('title'))->toBeNull(); |
61 | 61 | }); |
| 62 | + |
| 63 | +it('returns empty array when no discovery paths configured', function () { |
| 64 | + config(['page-builder-plugin.global_blocks_discovery_paths' => []]); |
| 65 | + |
| 66 | + $method = new ReflectionMethod(GlobalBlockConfig::class, 'discoverGlobalBlocks'); |
| 67 | + $method->setAccessible(true); |
| 68 | + |
| 69 | + $blocks = $method->invoke(new GlobalBlockConfig()); |
| 70 | + |
| 71 | + expect($blocks)->toBe([]); |
| 72 | +}); |
| 73 | + |
| 74 | +it('processes glob patterns correctly', function () { |
| 75 | + config(['page-builder-plugin.global_blocks_discovery_paths' => ['tests/non-existent/*/path']]); |
| 76 | + |
| 77 | + $method = new ReflectionMethod(GlobalBlockConfig::class, 'discoverGlobalBlocks'); |
| 78 | + $method->setAccessible(true); |
| 79 | + |
| 80 | + $blocks = $method->invoke(new GlobalBlockConfig()); |
| 81 | + |
| 82 | + expect($blocks)->toBe([]); |
| 83 | +}); |
| 84 | + |
| 85 | +it('processes direct paths correctly', function () { |
| 86 | + config(['page-builder-plugin.global_blocks_discovery_paths' => ['tests/non-existent/direct/path']]); |
| 87 | + |
| 88 | + $method = new ReflectionMethod(GlobalBlockConfig::class, 'discoverGlobalBlocks'); |
| 89 | + $method->setAccessible(true); |
| 90 | + |
| 91 | + $blocks = $method->invoke(new GlobalBlockConfig()); |
| 92 | + |
| 93 | + expect($blocks)->toBe([]); |
| 94 | +}); |
| 95 | + |
| 96 | +it('handles mixed path types in configuration', function () { |
| 97 | + config(['page-builder-plugin.global_blocks_discovery_paths' => [ |
| 98 | + 'non/existent/direct/path', |
| 99 | + 'non/existent/*/glob/path' |
| 100 | + ]]); |
| 101 | + |
| 102 | + $method = new ReflectionMethod(GlobalBlockConfig::class, 'discoverGlobalBlocks'); |
| 103 | + $method->setAccessible(true); |
| 104 | + |
| 105 | + $blocks = $method->invoke(new GlobalBlockConfig()); |
| 106 | + |
| 107 | + expect($blocks)->toBe([]); |
| 108 | +}); |
| 109 | + |
| 110 | +it('correctly identifies glob patterns by checking for asterisk', function () { |
| 111 | + config(['page-builder-plugin.global_blocks_discovery_paths' => ['test/path/without/asterisk']]); |
| 112 | + |
| 113 | + $method = new ReflectionMethod(GlobalBlockConfig::class, 'discoverGlobalBlocks'); |
| 114 | + $method->setAccessible(true); |
| 115 | + |
| 116 | + $blocks = $method->invoke(new GlobalBlockConfig()); |
| 117 | + |
| 118 | + expect($blocks)->toBe([]); |
| 119 | +}); |
0 commit comments