Skip to content

Commit c2b6db0

Browse files
authored
Merge pull request #54 from aternosorg/is-registry-enabled
Add getter to check if registry is enabled
2 parents 4c0569d + 56ee74a commit c2b6db0

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

‎src/GenericModel.php‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,16 @@ public static function enableRegistry(): void
335335
static::$registry = true;
336336
}
337337

338+
/**
339+
* Check if the registry is enabled
340+
*
341+
* @return bool
342+
*/
343+
public static function isRegistryEnabled(): bool
344+
{
345+
return static::$registry;
346+
}
347+
338348
/**
339349
*
340350
*

‎test/tests/GenericModelTest.php‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace Aternos\Model\Test\Tests;
4+
5+
use Aternos\Model\GenericModel;
6+
use PHPUnit\Framework\TestCase;
7+
8+
class GenericModelTest extends TestCase
9+
{
10+
public function testRegistry(): void
11+
{
12+
$this->assertTrue(GenericModel::isRegistryEnabled());
13+
GenericModel::disableRegistry();
14+
$this->assertFalse(GenericModel::isRegistryEnabled());
15+
GenericModel::enableRegistry();
16+
$this->assertTrue(GenericModel::isRegistryEnabled());
17+
}
18+
}

0 commit comments

Comments
 (0)