|
88 | 88 | ->and($jsSwitchFile)->not->toBeNull(); |
89 | 89 | }); |
90 | 90 |
|
91 | | -test('boot method publishes theme-switch-two-states PHP stub classes', function (): void { |
92 | | - // Arrange |
93 | | - $app = new Application(); |
94 | | - $provider = new BladeInlineScriptsProvider($app); |
95 | | - |
96 | | - // Act |
97 | | - $provider->boot(); |
98 | | - |
99 | | - // Assert |
100 | | - $published = ServiceProvider::$publishes[BladeInlineScriptsProvider::class] ?? []; |
101 | | - |
102 | | - $expectedClassPublishes = []; |
103 | | - foreach ($published as $source => $destination) { |
104 | | - if (str_contains($source, 'stubs/ThemeSwitchTwoStates')) { |
105 | | - $expectedClassPublishes[$source] = $destination; |
106 | | - } |
107 | | - } |
108 | | - |
109 | | - expect($expectedClassPublishes)->not->toBeEmpty(); |
110 | | - |
111 | | - // Check specific PHP stub files are published |
112 | | - $sourceFiles = array_keys($expectedClassPublishes); |
113 | | - $themeInitClass = collect($sourceFiles)->first(fn ($file) => str_contains($file, 'ThemeInitScript.php')); |
114 | | - $themeSwitchClass = collect($sourceFiles)->first(fn ($file) => str_contains($file, 'ThemeSwitchScript.php')); |
115 | | - |
116 | | - expect($themeInitClass)->not->toBeNull() |
117 | | - ->and($themeSwitchClass)->not->toBeNull(); |
118 | | -}); |
119 | | - |
120 | 91 | test('boot method publishes theme-switch-two-states JS test files', function (): void { |
121 | 92 | // Arrange |
122 | 93 | $app = new Application(); |
|
146 | 117 | ->and($themeSwitchTest)->not->toBeNull(); |
147 | 118 | }); |
148 | 119 |
|
149 | | -test('boot method publishes theme-switch-two-states PHP test files', function (): void { |
150 | | - // Arrange |
151 | | - $app = new Application(); |
152 | | - $provider = new BladeInlineScriptsProvider($app); |
153 | | - |
154 | | - // Act |
155 | | - $provider->boot(); |
156 | | - |
157 | | - // Assert |
158 | | - $published = ServiceProvider::$publishes[BladeInlineScriptsProvider::class] ?? []; |
159 | | - |
160 | | - $expectedPhpTestPublishes = []; |
161 | | - foreach ($published as $source => $destination) { |
162 | | - if (str_contains($source, 'tests/Unit/ThemeSwitchTwoStates')) { |
163 | | - $expectedPhpTestPublishes[$source] = $destination; |
164 | | - } |
165 | | - } |
166 | | - |
167 | | - expect($expectedPhpTestPublishes)->not->toBeEmpty(); |
168 | | - |
169 | | - // Check specific PHP test files are published |
170 | | - $sourceFiles = array_keys($expectedPhpTestPublishes); |
171 | | - $themeInitTest = collect($sourceFiles)->first(fn ($file) => str_contains($file, 'ThemeInitScriptTest.php')); |
172 | | - $themeSwitchTest = collect($sourceFiles)->first(fn ($file) => str_contains($file, 'ThemeSwitchScriptTest.php')); |
173 | | - |
174 | | - expect($themeInitTest)->not->toBeNull() |
175 | | - ->and($themeSwitchTest)->not->toBeNull(); |
176 | | -}); |
177 | | - |
178 | 120 | test('boot method sets up correct publish groups', function (): void { |
179 | 121 | // Arrange |
180 | 122 | $app = new Application(); |
|
187 | 129 | $groups = ServiceProvider::$publishGroups ?? []; |
188 | 130 |
|
189 | 131 | expect($groups)->toHaveKey('theme-switch-2-states-js') |
190 | | - ->and($groups)->toHaveKey('theme-switch-2-states-php') |
191 | 132 | ->and($groups)->toHaveKey('theme-switch-2-states-js-tests') |
192 | | - ->and($groups)->toHaveKey('theme-switch-2-states-php-tests') |
193 | 133 | ->and($groups)->toHaveKey('theme-switch-2-states-all'); |
194 | 134 |
|
195 | 135 | // Verify 'theme-switch-2-states-all' includes all the files |
196 | 136 | $allGroupFiles = $groups['theme-switch-2-states-all'] ?? []; |
197 | 137 | $jsFiles = $groups['theme-switch-2-states-js'] ?? []; |
198 | | - $phpFiles = $groups['theme-switch-2-states-php'] ?? []; |
199 | 138 | $jsTestFiles = $groups['theme-switch-2-states-js-tests'] ?? []; |
200 | | - $phpTestFiles = $groups['theme-switch-2-states-php-tests'] ?? []; |
201 | 139 |
|
202 | | - $expectedAllFiles = array_merge($jsFiles, $phpFiles, $jsTestFiles, $phpTestFiles); |
| 140 | + $expectedAllFiles = array_merge($jsFiles, $jsTestFiles); |
203 | 141 |
|
204 | 142 | expect(count($allGroupFiles))->toBe(count($expectedAllFiles)); |
205 | 143 | }); |
|
218 | 156 | foreach ($published as $source => $destination) { |
219 | 157 | if (str_contains($source, 'resources/js')) { |
220 | 158 | expect($destination)->toContain('resources/js/theme-switch-two-states'); |
221 | | - } elseif (str_contains($source, 'stubs/ThemeSwitchTwoStates')) { |
222 | | - expect($destination)->toContain('app/Blade/ThemeSwitchTwoStates'); |
223 | 159 | } elseif (str_contains($source, 'tests/js')) { |
224 | 160 | expect($destination)->toContain('tests/js/theme-switch-two-states'); |
| 161 | + } else { |
| 162 | + expect(false)->toBeTrue(); // Fail the test if an unexpected file is found |
225 | 163 | } |
226 | 164 | } |
227 | 165 | }); |
0 commit comments