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:
33
tests/src/flextype/core/ActionsTest.php
Normal file
33
tests/src/flextype/core/ActionsTest.php
Normal 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());
|
||||
});
|
Reference in New Issue
Block a user