-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3987 from HungDV2022/unittest_PrefixOrmResolver_find
PrefixOrmResolver::find() ユニットテスト
- Loading branch information
Showing
2 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
plugins/baser-core/tests/TestCase/Identifier/Resolver/PrefixOrmResolverTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
/** | ||
* baserCMS : Based Website Development Project <https://basercms.net> | ||
* Copyright (c) NPO baser foundation <https://baserfoundation.org/> | ||
* | ||
* @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); | ||
} | ||
} |