forked from baserproject/basercms
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '5.1.x' into advisory-fix-2
- Loading branch information
Showing
46 changed files
with
790 additions
and
111 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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
92 changes: 92 additions & 0 deletions
92
plugins/baser-core/tests/TestCase/Event/BcEventDispatcherTest.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,92 @@ | ||
<?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\Event; | ||
|
||
use BaserCore\Event\BcModelEventDispatcher; | ||
use BaserCore\Event\BcModelEventListener; | ||
use BaserCore\Model\Table\UsersTable; | ||
use BaserCore\TestSuite\BcTestCase; | ||
use Cake\Event\Event; | ||
use Cake\Event\EventManager; | ||
|
||
/** | ||
* Class BcEventDispatcherTest | ||
* | ||
*/ | ||
class BcEventDispatcherTest extends BcTestCase | ||
{ | ||
|
||
/** | ||
* @var EventManager|null | ||
*/ | ||
public $eventManager; | ||
|
||
/** | ||
* @var BcModelEventDispatcher|null | ||
*/ | ||
public $bcModelEventDispatcher; | ||
/** | ||
* set up | ||
* | ||
* @return void | ||
*/ | ||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
$this->eventManager = EventManager::instance(); | ||
$this->bcModelEventDispatcher = new BcModelEventDispatcher(); | ||
foreach($this->bcModelEventDispatcher->implementedEvents() as $key => $event) { | ||
$this->eventManager->off($key); | ||
} | ||
} | ||
|
||
/** | ||
* tearDown | ||
* | ||
* @return void | ||
*/ | ||
public function tearDown(): void | ||
{ | ||
parent::tearDown(); | ||
} | ||
|
||
/** | ||
* dispatch | ||
*/ | ||
public function testDispatch() | ||
{ | ||
foreach($this->bcModelEventDispatcher->implementedEvents() as $key => $event) { | ||
$this->eventManager->off($key); | ||
} | ||
|
||
$listener = $this->getMockBuilder(BcModelEventListener::class) | ||
->onlyMethods(['implementedEvents']) | ||
->addMethods(['usersBeforeFind']) | ||
->getMock(); | ||
|
||
$listener->method('implementedEvents') | ||
->willReturn(['Model.Users.beforeFind' => ['callable' => 'usersBeforeFind']]); | ||
|
||
$listener->expects($this->once()) | ||
->method('usersBeforeFind'); | ||
|
||
$this->eventManager | ||
->on($listener) | ||
->on($this->bcModelEventDispatcher) | ||
->dispatch(new Event( | ||
'Model.beforeFind', | ||
new UsersTable, | ||
[] | ||
)); | ||
} | ||
|
||
} |
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); | ||
} | ||
} |
Oops, something went wrong.