feat: CI/CD pipeline setup complete - Ansible playbooks updated, secrets configured, workflow ready
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use App\Framework\LiveComponents\Attributes\Poll;
|
||||
use App\Framework\Core\ValueObjects\Duration;
|
||||
|
||||
describe('Poll Attribute', function () {
|
||||
it('creates poll with default values', function () {
|
||||
$poll = new Poll();
|
||||
|
||||
expect($poll->interval)->toBe(1000);
|
||||
expect($poll->enabled)->toBeTrue();
|
||||
expect($poll->event)->toBeNull();
|
||||
expect($poll->stopOnError)->toBeFalse();
|
||||
});
|
||||
|
||||
it('creates poll with custom values', function () {
|
||||
$poll = new Poll(
|
||||
interval: 5000,
|
||||
enabled: false,
|
||||
event: 'test.event',
|
||||
stopOnError: true
|
||||
);
|
||||
|
||||
expect($poll->interval)->toBe(5000);
|
||||
expect($poll->enabled)->toBeFalse();
|
||||
expect($poll->event)->toBe('test.event');
|
||||
expect($poll->stopOnError)->toBeTrue();
|
||||
});
|
||||
|
||||
it('validates minimum interval', function () {
|
||||
new Poll(interval: 50);
|
||||
})->throws(
|
||||
InvalidArgumentException::class,
|
||||
'Poll interval must be at least 100ms'
|
||||
);
|
||||
|
||||
it('validates maximum interval', function () {
|
||||
new Poll(interval: 400000);
|
||||
})->throws(
|
||||
InvalidArgumentException::class,
|
||||
'Poll interval cannot exceed 5 minutes'
|
||||
);
|
||||
|
||||
it('accepts minimum valid interval', function () {
|
||||
$poll = new Poll(interval: 100);
|
||||
expect($poll->interval)->toBe(100);
|
||||
});
|
||||
|
||||
it('accepts maximum valid interval', function () {
|
||||
$poll = new Poll(interval: 300000);
|
||||
expect($poll->interval)->toBe(300000);
|
||||
});
|
||||
|
||||
it('returns interval as Duration', function () {
|
||||
$poll = new Poll(interval: 2500);
|
||||
$duration = $poll->getInterval();
|
||||
|
||||
expect($duration)->toBeInstanceOf(Duration::class);
|
||||
expect($duration->toMilliseconds())->toBe(2500);
|
||||
expect($duration->toSeconds())->toBe(2.5);
|
||||
});
|
||||
|
||||
it('creates new instance with different enabled state', function () {
|
||||
$poll = new Poll(interval: 1000, enabled: true);
|
||||
$disabled = $poll->withEnabled(false);
|
||||
|
||||
expect($poll->enabled)->toBeTrue();
|
||||
expect($disabled->enabled)->toBeFalse();
|
||||
expect($disabled->interval)->toBe($poll->interval);
|
||||
});
|
||||
|
||||
it('creates new instance with different interval', function () {
|
||||
$poll = new Poll(interval: 1000);
|
||||
$faster = $poll->withInterval(500);
|
||||
|
||||
expect($poll->interval)->toBe(1000);
|
||||
expect($faster->interval)->toBe(500);
|
||||
});
|
||||
|
||||
it('is readonly and immutable', function () {
|
||||
$poll = new Poll(interval: 1000);
|
||||
|
||||
expect($poll)->toBeInstanceOf(Poll::class);
|
||||
|
||||
// Verify readonly - should not be able to modify
|
||||
$reflection = new ReflectionClass($poll);
|
||||
expect($reflection->isReadOnly())->toBeTrue();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user