29 lines
814 B
PHP
29 lines
814 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Framework\Attributes\Singleton;
|
|
|
|
describe('Singleton', function () {
|
|
it('can be instantiated', function () {
|
|
$singleton = new Singleton();
|
|
|
|
expect($singleton)->toBeInstanceOf(Singleton::class);
|
|
});
|
|
|
|
it('is an attribute class', function () {
|
|
$reflection = new ReflectionClass(Singleton::class);
|
|
$attributes = $reflection->getAttributes(\Attribute::class);
|
|
|
|
expect($attributes)->toHaveCount(1);
|
|
});
|
|
|
|
it('targets class only', function () {
|
|
$reflection = new ReflectionClass(Singleton::class);
|
|
$attribute = $reflection->getAttributes(\Attribute::class)[0];
|
|
$attributeInstance = $attribute->newInstance();
|
|
|
|
expect($attributeInstance->flags)->toBe(\Attribute::TARGET_CLASS);
|
|
});
|
|
});
|