1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-07 21:56:33 +02:00

feat(tests): add tests for Actions

This commit is contained in:
Awilum
2021-09-28 22:08:39 +03:00
parent be877e052b
commit da869cc1a9

View File

@@ -0,0 +1,33 @@
<?php
declare(strict_types = 1);
use Flextype\Actions;
test('test getInstance() method', function() {
$this->assertInstanceOf(Actions::class, Actions::getInstance());
});
test('test registry() helper', function() {
$this->assertEquals(Actions::getInstance(), registry());
$this->assertInstanceOf(Actions::class, registry());
});
test('test actions uniqueness', function() {
$firstCall = Actions::getInstance();
$secondCall = Actions::getInstance();
$this->assertInstanceOf(Actions::class, $firstCall);
$this->assertSame($firstCall, $secondCall);
});
test('test macro() method', function (): void {
Actions::getInstance()->set('foo', 'bar');
Actions::macro('customMethod', function() {
return $this->count();
});
$registry = Actions::getInstance();
$this->assertEquals(1, $registry->customMethod());
});