Skip to content

Commit

Permalink
ユニットテストを調整
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuring committed Sep 7, 2024
1 parent 2a38d81 commit 385721a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
4 changes: 3 additions & 1 deletion plugins/baser-core/src/Model/Table/ContentsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,9 @@ public function beforeSave(EventInterface $event, EntityInterface $entity, Array
try {
$this->beforeSaveParentId = $this->get($entity->id)->parent_id;
} catch (RecordNotFoundException) {
$this->beforeSaveParentId = $this->getTrash($entity->id)->parent_id;
try {
$this->beforeSaveParentId = $this->getTrash($entity->id)->parent_id;
} catch (\Throwable) {}
}
}
if (!empty($entity->name)) {
Expand Down
10 changes: 5 additions & 5 deletions plugins/baser-core/src/View/Helper/BcFormHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,11 @@ public function editor($fieldName, $options = [])
'style' => 'width:99%;height:540px'
], $options);

if ($options['editor'] !== 'none') {
if(!$options['editor']) {
/** @var BcCkeditorHelper $bcCkeditor */
$bcCkeditor = $this->getView()->BcCkeditor;
return $bcCkeditor->editor($fieldName, $options);
} elseif ($options['editor'] !== 'none') {
[$plugin] = pluginSplit($options['editor']);
if (!Plugin::isLoaded($plugin)) {
$options['editor'] = 'none';
Expand All @@ -716,10 +720,6 @@ public function editor($fieldName, $options = [])
[, $editor] = pluginSplit($options['editor']);
$this->getView()->loadHelper($editor, ['className' => $className]);
}
} elseif(!$options['editor']) {
/** @var BcCkeditorHelper $bcCkeditor */
$bcCkeditor = $this->getView()->BcCkeditor;
return $bcCkeditor->editor($fieldName, $options);
}

if ($options['editor'] === 'none') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@

use ArrayObject;
use BaserCore\Service\BcDatabaseService;
use BaserCore\Test\Factory\ContentFactory;
use BaserCore\Test\Scenario\ContentsScenario;
use BaserCore\Test\Scenario\InitAppScenario;
use BaserCore\Test\Scenario\SitesScenario;
use BaserCore\Test\Scenario\SmallSetContentsScenario;
use Cake\ORM\Entity;
use CakephpFixtureFactories\Scenario\ScenarioAwareTrait;
use ReflectionClass;
use Cake\Core\Configure;
use Cake\I18n\FrozenTime;
use Cake\Validation\Validator;
use BaserCore\Model\Entity\Content;
Expand Down Expand Up @@ -289,11 +288,12 @@ public static function getUniqueNameDataProvider()
public function testBeforeSave()
{
$value = "テスト";
$data = new Entity([
ContentFactory::make([
'id' => 100,
'parent_id' => 6,
'name' => $value
]);
'name' => $value,
])->persist();
$data = ContentFactory::get(100);
$result = $this->Contents->dispatchEvent('Model.beforeSave', ['entity' => $data, 'options' => new ArrayObject()]);
$this->assertEquals(6, $this->Contents->beforeSaveParentId);
// nameフィールドがエンコードされてるかをテスト
Expand Down

0 comments on commit 385721a

Please sign in to comment.