diff --git a/plugins/baser-core/src/Identifier/Resolver/PrefixOrmResolver.php b/plugins/baser-core/src/Identifier/Resolver/PrefixOrmResolver.php index 8d2b47d002..8052942f6a 100644 --- a/plugins/baser-core/src/Identifier/Resolver/PrefixOrmResolver.php +++ b/plugins/baser-core/src/Identifier/Resolver/PrefixOrmResolver.php @@ -34,6 +34,7 @@ class PrefixOrmResolver extends OrmResolver implements ResolverInterface * @return array|EntityInterface|null * @checked * @noTodo + * @unitTest */ public function find(array $conditions, $type = self::TYPE_AND): \ArrayAccess|array|null { diff --git a/plugins/baser-core/tests/TestCase/Identifier/Resolver/PrefixOrmResolverTest.php b/plugins/baser-core/tests/TestCase/Identifier/Resolver/PrefixOrmResolverTest.php new file mode 100644 index 0000000000..7793cdcd45 --- /dev/null +++ b/plugins/baser-core/tests/TestCase/Identifier/Resolver/PrefixOrmResolverTest.php @@ -0,0 +1,70 @@ + + * Copyright (c) NPO baser foundation + * + * @copyright Copyright (c) NPO baser foundation + * @link https://basercms.net baserCMS Project + * @since 5.0.0 + * @license https://basercms.net/license/index.html MIT License + */ +namespace BaserCore\Test\TestCase\Identifier\Resolver; + +use BaserCore\Identifier\Resolver\PrefixOrmResolver; +use BaserCore\Test\Factory\UserFactory; +use BaserCore\TestSuite\BcTestCase; +use CakephpFixtureFactories\Scenario\ScenarioAwareTrait; + +/** + * Class PrefixOrmResolverTest + * @property PrefixOrmResolver $PrefixOrmResolver + * + */ +class PrefixOrmResolverTest extends BcTestCase +{ + /** + * ScenarioAwareTrait + */ + use ScenarioAwareTrait; + + /** + * Set Up + * + * @return void + */ + public function setUp(): void + { + parent::setUp(); + $this->PrefixOrmResolver = new PrefixOrmResolver(); + } + + /** + * Tear Down + * + * @return void + */ + public function tearDown(): void + { + parent::tearDown(); + } + + /** + * testInitialize + * + * @return void + */ + public function testFind(): void + { + //準備 + UserFactory::make(['id' => 1, 'name' => 'user_test'])->persist(); + $this->PrefixOrmResolver->setConfig('prefix', 'test'); + + //正常テスト + $rs = $this->PrefixOrmResolver->find(['id' => 'test_1']); + $this->assertEquals('user_test', $rs->name); + + //異常テスト  + $rs = $this->PrefixOrmResolver->find(['id' => 'user_1']); + $this->assertNull($rs); + } +}