diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9c7c6b9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/vendor/ +.phpunit.cache/ +composer.lock diff --git a/Component.php b/Component.php deleted file mode 100644 index 18e0fdc..0000000 --- a/Component.php +++ /dev/null @@ -1,25 +0,0 @@ - 'array', - 'installed_at' => 'datetime' - ]; -} \ No newline at end of file diff --git a/ComponentInterface.php b/ComponentInterface.php deleted file mode 100644 index 1a236d9..0000000 --- a/ComponentInterface.php +++ /dev/null @@ -1,26 +0,0 @@ - $component->getName()], - [ - 'package_name' => $component->getName(), - 'version' => $component->getVersion(), - 'description' => $component->getDescription(), - 'metadata' => $component->getMetadata(), - 'status' => 'installed', - 'installed_at' => now() - ] - ); - } - - public function remove(string $name): bool - { - return Component::where('name', $name)->delete() > 0; - } - - public function get(string $name): ?Component - { - return Component::where('name', $name)->first(); - } - - public function all(): Collection - { - return Component::all(); - } - - public function isInstalled(string $name): bool - { - return Component::where('name', $name) - ->where('status', 'installed') - ->exists(); - } -} \ No newline at end of file diff --git a/composer.json b/composer.json index 884b6d4..303a6bc 100644 --- a/composer.json +++ b/composer.json @@ -12,13 +12,13 @@ ], "require": { "php": "^8.2.0", - "illuminate/contracts": "^11.0", - "illuminate/database": "^11.0", - "illuminate/support": "^11.0" + "illuminate/contracts": "^11.0|^12.0|^13.0", + "illuminate/database": "^11.0|^12.0|^13.0", + "illuminate/support": "^11.0|^12.0|^13.0" }, "require-dev": { "pestphp/pest": "^3.0", - "orchestra/testbench": "^9.0", + "orchestra/testbench": "^9.0|^10.0|^11.0", "laravel/pint": "^1.18" }, "autoload": { @@ -36,6 +36,11 @@ "lint:test": "pint --test", "test": "pest" }, + "config": { + "allow-plugins": { + "pestphp/pest-plugin": true + } + }, "minimum-stability": "stable", "prefer-stable": true } \ No newline at end of file diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..e067aae --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,17 @@ + + + + + tests/Unit + + + + + src + + + diff --git a/src/Contracts/ComponentInterface.php b/src/Contracts/ComponentInterface.php index 1a236d9..ea85ae2 100644 --- a/src/Contracts/ComponentInterface.php +++ b/src/Contracts/ComponentInterface.php @@ -7,20 +7,20 @@ interface ComponentInterface { public function getName(): string; - + public function getVersion(): string; - + public function getDescription(): string; - + public function getCommands(): array; - + public function install(): bool; - + public function uninstall(): bool; - + public function isInstalled(): bool; - + public function validate(): bool; - + public function getMetadata(): array; -} \ No newline at end of file +} diff --git a/src/Models/Component.php b/src/Models/Component.php index 18e0fdc..f172ed4 100644 --- a/src/Models/Component.php +++ b/src/Models/Component.php @@ -10,16 +10,16 @@ class Component extends Model { protected $fillable = [ 'name', - 'package_name', + 'package_name', 'version', 'description', 'metadata', 'installed_at', - 'status' + 'status', ]; protected $casts = [ 'metadata' => 'array', - 'installed_at' => 'datetime' + 'installed_at' => 'datetime', ]; -} \ No newline at end of file +} diff --git a/src/Services/ComponentStorage.php b/src/Services/ComponentStorage.php index a92d253..50307ad 100644 --- a/src/Services/ComponentStorage.php +++ b/src/Services/ComponentStorage.php @@ -4,8 +4,8 @@ namespace ConduitIo\Core\Services; -use ConduitIo\Core\Models\Component; use ConduitIo\Core\Contracts\ComponentInterface; +use ConduitIo\Core\Models\Component; use Illuminate\Support\Collection; class ComponentStorage @@ -20,7 +20,7 @@ public function store(ComponentInterface $component): Component 'description' => $component->getDescription(), 'metadata' => $component->getMetadata(), 'status' => 'installed', - 'installed_at' => now() + 'installed_at' => now(), ] ); } @@ -46,4 +46,4 @@ public function isInstalled(string $name): bool ->where('status', 'installed') ->exists(); } -} \ No newline at end of file +} diff --git a/tests/Pest.php b/tests/Pest.php new file mode 100644 index 0000000..174d7fd --- /dev/null +++ b/tests/Pest.php @@ -0,0 +1,3 @@ + 'test']; + } + }; + + expect($component->getName())->toBe('demo') + ->and($component->getVersion())->toBe('1.0.0') + ->and($component->getCommands())->toBe([]) + ->and($component->getMetadata())->toBe(['source' => 'test']); +});