-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #3141 【5.1】必須項目を入力せずに保存ボタンを押下すると保存されてしまう【アクセスルールグループ>アクセスルールグループ新…
…規登録】 (#3150) Co-authored-by: Đỗ Văn Hùng <[email protected]>
- Loading branch information
1 parent
55e8a14
commit 16e6519
Showing
3 changed files
with
111 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
85 changes: 85 additions & 0 deletions
85
plugins/baser-core/tests/TestCase/Model/Table/PermissionsGroupsTableTest.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,85 @@ | ||
<?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\Model\Table; | ||
|
||
use BaserCore\Model\Table\PermissionGroupsTable; | ||
use BaserCore\TestSuite\BcTestCase; | ||
use CakephpFixtureFactories\Scenario\ScenarioAwareTrait; | ||
|
||
/** | ||
* Class PermissionGroupsTableTest | ||
* @property PermissionGroupsTable $PermissionGroupsTable | ||
*/ | ||
class PermissionsGroupsTableTest extends BcTestCase | ||
{ | ||
/** | ||
* ScenarioAwareTrait | ||
*/ | ||
use ScenarioAwareTrait; | ||
|
||
/** | ||
* Set Up | ||
* | ||
* @return void | ||
*/ | ||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
$this->PermissionGroupsTable = $this->getTableLocator()->get('BaserCore.PermissionGroups'); | ||
} | ||
|
||
/** | ||
* Tear Down | ||
* | ||
* @return void | ||
*/ | ||
public function tearDown(): void | ||
{ | ||
unset($this->PermissionGroupsTable); | ||
parent::tearDown(); | ||
} | ||
|
||
/** | ||
* Test initialize | ||
*/ | ||
public function testInitialize() | ||
{ | ||
$this->assertEquals('permission_groups', $this->PermissionGroupsTable->getTable()); | ||
$this->assertEquals('name', $this->PermissionGroupsTable->getDisplayField()); | ||
$this->assertEquals('id', $this->PermissionGroupsTable->getPrimaryKey()); | ||
$this->assertIsBool($this->PermissionGroupsTable->hasBehavior('Timestamp')); | ||
$this->assertEquals('Permissions', $this->PermissionGroupsTable->getAssociation('Permissions')->getName()); | ||
} | ||
|
||
/** | ||
* Test validationDefault | ||
* | ||
* @return void | ||
*/ | ||
public function testValidationDefault() | ||
{ | ||
$validator = $this->PermissionGroupsTable->getValidator('default'); | ||
$errors = $validator->validate([ | ||
'name' => '', | ||
]); | ||
|
||
$this->assertEquals('ルールグループ名を入力してください。', current($errors['name'])); | ||
|
||
$validator = $this->PermissionGroupsTable->getValidator('default'); | ||
$errors = $validator->validate([ | ||
'name' => str_repeat('a', 61), | ||
]); | ||
|
||
$this->assertEquals('ルールグループ名は60文字以内で入力してください。', current($errors['name'])); | ||
} | ||
|
||
} |
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