Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/vendor/
.phpunit.cache/
composer.lock
25 changes: 0 additions & 25 deletions Component.php

This file was deleted.

26 changes: 0 additions & 26 deletions ComponentInterface.php

This file was deleted.

49 changes: 0 additions & 49 deletions ComponentStorage.php

This file was deleted.

13 changes: 9 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -36,6 +36,11 @@
"lint:test": "pint --test",
"test": "pest"
},
"config": {
"allow-plugins": {
"pestphp/pest-plugin": true
}
},
"minimum-stability": "stable",
"prefer-stable": true
}
17 changes: 17 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="Unit">
<directory>tests/Unit</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>src</directory>
</include>
</source>
</phpunit>
18 changes: 9 additions & 9 deletions src/Contracts/ComponentInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
8 changes: 4 additions & 4 deletions src/Models/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
];
}
}
6 changes: 3 additions & 3 deletions src/Services/ComponentStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -20,7 +20,7 @@ public function store(ComponentInterface $component): Component
'description' => $component->getDescription(),
'metadata' => $component->getMetadata(),
'status' => 'installed',
'installed_at' => now()
'installed_at' => now(),
]
);
}
Expand All @@ -46,4 +46,4 @@ public function isInstalled(string $name): bool
->where('status', 'installed')
->exists();
}
}
}
3 changes: 3 additions & 0 deletions tests/Pest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

declare(strict_types=1);
60 changes: 60 additions & 0 deletions tests/Unit/ComponentContractTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

declare(strict_types=1);

use ConduitIo\Core\Contracts\ComponentInterface;

it('implements the component contract', function () {
$component = new class implements ComponentInterface
{
public function getName(): string
{
return 'demo';
}

public function getVersion(): string
{
return '1.0.0';
}

public function getDescription(): string
{
return 'Demo component';
}

public function getCommands(): array
{
return [];
}

public function install(): bool
{
return true;
}

public function uninstall(): bool
{
return true;
}

public function isInstalled(): bool
{
return true;
}

public function validate(): bool
{
return true;
}

public function getMetadata(): array
{
return ['source' => 'test'];
}
};

expect($component->getName())->toBe('demo')
->and($component->getVersion())->toBe('1.0.0')
->and($component->getCommands())->toBe([])
->and($component->getMetadata())->toBe(['source' => 'test']);
});
Loading