|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace Detain\MyAdminWebuzo\Tests; |
| 6 | + |
| 7 | +use PHPUnit\Framework\TestCase; |
| 8 | + |
| 9 | +/** |
| 10 | + * Tests verifying all expected source files exist in the package. |
| 11 | + * |
| 12 | + * Ensures the package distribution is complete. |
| 13 | + */ |
| 14 | +class FileExistenceTest extends TestCase |
| 15 | +{ |
| 16 | + /** |
| 17 | + * @var string |
| 18 | + */ |
| 19 | + private string $srcDir; |
| 20 | + |
| 21 | + protected function setUp(): void |
| 22 | + { |
| 23 | + $this->srcDir = dirname(__DIR__) . '/src'; |
| 24 | + } |
| 25 | + |
| 26 | + /** |
| 27 | + * Data provider for source file existence checks. |
| 28 | + * |
| 29 | + * @return array<string, array{0: string}> |
| 30 | + */ |
| 31 | + public function sourceFileProvider(): array |
| 32 | + { |
| 33 | + return [ |
| 34 | + 'Plugin.php' => ['Plugin.php'], |
| 35 | + 'sdk.php' => ['sdk.php'], |
| 36 | + 'webuzo_sdk.php' => ['webuzo_sdk.php'], |
| 37 | + 'webuzo.functions.inc.php' => ['webuzo.functions.inc.php'], |
| 38 | + 'webuzo_configure.php' => ['webuzo_configure.php'], |
| 39 | + 'webuzo_scripts.php' => ['webuzo_scripts.php'], |
| 40 | + 'webuzo_edit_installation.php' => ['webuzo_edit_installation.php'], |
| 41 | + 'webuzo_add_domain.php' => ['webuzo_add_domain.php'], |
| 42 | + 'webuzo_remove_domain.php' => ['webuzo_remove_domain.php'], |
| 43 | + 'webuzo_list_domains.php' => ['webuzo_list_domains.php'], |
| 44 | + 'webuzo_list_backups.php' => ['webuzo_list_backups.php'], |
| 45 | + 'webuzo_list_installed_scripts.php' => ['webuzo_list_installed_scripts.php'], |
| 46 | + 'webuzo_list_installed_sysapps.php' => ['webuzo_list_installed_sysapps.php'], |
| 47 | + 'webuzo_list_sysapps.php' => ['webuzo_list_sysapps.php'], |
| 48 | + 'webuzo_install_sysapp.php' => ['webuzo_install_sysapp.php'], |
| 49 | + 'webuzo_import_script.php' => ['webuzo_import_script.php'], |
| 50 | + 'webuzo_remove_script.php' => ['webuzo_remove_script.php'], |
| 51 | + 'webuzo_view_script.php' => ['webuzo_view_script.php'], |
| 52 | + 'webuzo_view_sysapps.php' => ['webuzo_view_sysapps.php'], |
| 53 | + 'webuzo_randomPassword.php' => ['webuzo_randomPassword.php'], |
| 54 | + 'webuzo_update_logo.php' => ['webuzo_update_logo.php'], |
| 55 | + ]; |
| 56 | + } |
| 57 | + |
| 58 | + /** |
| 59 | + * Test that each expected source file exists. |
| 60 | + * |
| 61 | + * @dataProvider sourceFileProvider |
| 62 | + */ |
| 63 | + public function testSourceFileExists(string $filename): void |
| 64 | + { |
| 65 | + $this->assertFileExists( |
| 66 | + $this->srcDir . '/' . $filename, |
| 67 | + "Source file {$filename} should exist in src/" |
| 68 | + ); |
| 69 | + } |
| 70 | + |
| 71 | + /** |
| 72 | + * Test that composer.json exists. |
| 73 | + */ |
| 74 | + public function testComposerJsonExists(): void |
| 75 | + { |
| 76 | + $this->assertFileExists(dirname(__DIR__) . '/composer.json'); |
| 77 | + } |
| 78 | + |
| 79 | + /** |
| 80 | + * Test that README.md exists. |
| 81 | + */ |
| 82 | + public function testReadmeExists(): void |
| 83 | + { |
| 84 | + $this->assertFileExists(dirname(__DIR__) . '/README.md'); |
| 85 | + } |
| 86 | +} |
0 commit comments