Skip to content

Commit

Permalink
Merge branch 'dev-5.1' into 5.1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuring committed Jun 23, 2024
2 parents d6437bd + 2f9d947 commit 84b2f2c
Show file tree
Hide file tree
Showing 23 changed files with 309 additions and 83 deletions.
1 change: 1 addition & 0 deletions plugins/baser-core/src/Model/Entity/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public function isAdminTheme(): bool
* @return bool
* @checked
* @noTodo
* @unitTest
*/
public function hasType(array|string $types): bool
{
Expand Down
3 changes: 3 additions & 0 deletions plugins/baser-core/src/Utility/BcUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,7 @@ public static function getAdminThemeList()
* @return string
* @checked
* @noTodo
* @unitTest
*/
public static function getSubDomain($host = null)
{
Expand Down Expand Up @@ -1123,6 +1124,7 @@ public static function getContentsItem(): array
* @return boolean
* @checked
* @noTodo
* @unitTest
*/
public static function isInstalled()
{
Expand Down Expand Up @@ -2092,6 +2094,7 @@ public static function getRequestPrefix(ServerRequestInterface $request)
* @return bool
* @checked
* @noTodo
* @unitTest
*/
public static function isDebug(): bool
{
Expand Down
1 change: 1 addition & 0 deletions plugins/baser-core/src/Vendor/CKEditorStyleParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public static function parse($css)
* @return array
* @checked
* @noTodo
* @unitTest
*/
private static function parseCode($code)
{
Expand Down
1 change: 1 addition & 0 deletions plugins/baser-core/src/View/BcFrontEmailView.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class BcFrontEmailView extends View
* @checked
* @unitTest
* @noTodo
* @unitTest
*/
public function initialize(): void
{
Expand Down
1 change: 1 addition & 0 deletions plugins/baser-core/src/View/Helper/BcArrayHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public function addText($array, $prefix = '', $suffix = '')
* @param string $add
* @checked
* @noTodo
* @unitTest
*/
private function __addText(&$value, $key, $add)
{
Expand Down
22 changes: 22 additions & 0 deletions plugins/baser-core/src/View/Helper/BcBaserHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,7 @@ public function setCategoryTitle($on = true)
* @return string meta タグ用のキーワード
* @checked
* @noTodo
* @unitTest
*/
public function getKeywords()
{
Expand All @@ -912,6 +913,7 @@ public function getKeywords()
* @return string meta タグ用の説明文
* @checked
* @noTodo
* @unitTest
*/
public function getDescription()
{
Expand Down Expand Up @@ -1085,6 +1087,7 @@ public function contentsTitle()
* @return void
* @checked
* @noTodo
* @unitTest
*/
public function title($separator = '', $categoryTitleOn = null)
{
Expand All @@ -1097,6 +1100,7 @@ public function title($separator = '|', $categoryTitleOn = null)
* @return void
* @checked
* @noTodo
* @unitTest
*/
public function metaKeywords()
{
Expand All @@ -1109,6 +1113,7 @@ public function metaKeywords()
* @return void
* @checked
* @noTodo
* @unitTest
*/
public function metaDescription()
{
Expand All @@ -1123,6 +1128,7 @@ public function metaDescription()
* @return void
* @checked
* @noTodo
* @unitTest
*/
public function rss($title, $link)
{
Expand Down Expand Up @@ -1168,6 +1174,7 @@ public function isHome()
* @return void
* @checked
* @noTodo
* @unitTest
*/
public function header($data = [], $options = [])
{
Expand Down Expand Up @@ -1205,6 +1212,7 @@ public function header($data = [], $options = [])
* @return void
* @checked
* @noTodo
* @unitTest
*/
public function footer($data = [], $options = [])
{
Expand Down Expand Up @@ -1261,6 +1269,7 @@ public function pagination($name = 'default', $data = [], $options = [])
* @return void
* @checked
* @noTodo
* @unitTest
*/
public function content()
{
Expand Down Expand Up @@ -1368,6 +1377,7 @@ public function scripts()
* @return void
* @checked
* @noTodo
* @unitTest
*/
public function func()
{
Expand Down Expand Up @@ -1420,6 +1430,7 @@ public function xmlHeader($attrib = [])
* @return void
* @checked
* @noTodo
* @unitTest
*/
public function icon()
{
Expand Down Expand Up @@ -1519,6 +1530,7 @@ public function copyYear($begin)
* @return string|false
* @checked
* @noTodo
* @unitTest
*/
public function getSitePrefix(): string|false
{
Expand Down Expand Up @@ -1655,6 +1667,7 @@ public function cacheHeader($expire = null, $type = 'html')
* @return string プロトコルから始まるURL
* @checked
* @noTodo
* @unitTest
*/
public function getUri($url)
{
Expand Down Expand Up @@ -1783,6 +1796,7 @@ public function mark($search, $text, $name = 'strong', $attributes = [], $escape
* @doc
* @checked
* @noTodo
* @unitTest ラッパーメソッドのためユニットテスト不要
*/
public function contentsMenu($id = null, $level = null, $currentId = null)
{
Expand Down Expand Up @@ -1852,6 +1866,7 @@ public function getContentsMenu($id = null, $level = null, $currentId = null, $o
* @return mixed コンテンツデータ
* @checked
* @noTodo
* @unitTest
*/
public function _unsetIndexInContentsMenu($contents, $children = false)
{
Expand All @@ -1877,6 +1892,7 @@ public function _unsetIndexInContentsMenu($contents, $children = false)
* @return void
* @checked
* @noTodo
* @unitTest ラッパーメソッドのためユニットテスト不要
*/
public function globalMenu($level = 1, $options = [])
{
Expand Down Expand Up @@ -1942,6 +1958,7 @@ public function getGlobalMenu($level = 5, $options = [])
* @param int $siteId サイトID
* @checked
* @noTodo
* @unitTest ラッパーメソッドのためユニットテストはスキップする
*/
public function sitemap($siteId = 0)
{
Expand Down Expand Up @@ -2254,6 +2271,7 @@ public function getGoogleMaps($data = [])
* @return void
* @checked
* @noTodo
* @unitTest
*/
public function listNum($data = [], $options = [])
{
Expand All @@ -2269,6 +2287,7 @@ public function listNum($data = [], $options = [])
* @return void
* @checked
* @noTodo
* @unitTest ラッパーメソッドのためユニットテストはスキップする
*/
public function siteSearchForm($data = [], $options = [])
{
Expand Down Expand Up @@ -2389,6 +2408,7 @@ public function getUrlParams()
* @return string
* @checked
* @noTodo
* @unitTest
*/
public function getCurrentPrefix()
{
Expand Down Expand Up @@ -2486,6 +2506,7 @@ public function getRelatedSiteLinks($id = null, $excludeIds = [])
* @param int $id コンテンツID
* @checked
* @noTodo
* @unitTest ラッパーメソッドのためユニットテストはスキップする
*/
public function relatedSiteLinks($id = null, $excludeIds = [])
{
Expand Down Expand Up @@ -2616,6 +2637,7 @@ public function setHomeTitle($title = null)
* @param bool $useGloss 光沢有無
* @checked
* @noTodo
* @unitTest
*/
public function webClipIcon($fileName = 'apple-touch-icon-precomposed.png', $useGloss = false)
{
Expand Down
1 change: 1 addition & 0 deletions plugins/baser-core/src/View/Helper/BcContentsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ protected function _getExistsTitles()
* @return string
* @checked
* @noTodo
* @unitTest
*/
public function getJsonItems()
{
Expand Down
3 changes: 2 additions & 1 deletion plugins/baser-core/src/View/Helper/BcFreezeHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ public function number($fieldName, $options = [])
* @return string htmlタグ
* @checked
* @noTodo
* @unitTest
*/
public function password($fieldName, $options = [])
{
Expand All @@ -560,7 +561,7 @@ public function password($fieldName, $options = [])
} else {
$value = $this->getSourceValue($fieldName);
}
$value = preg_replace('/./', '*', $value);
$value = $value !== null ? preg_replace('/./', '*', $value) : '';
return parent::hidden($fieldName, $options) . h($value);
} else {
return parent::password($fieldName, $options);
Expand Down
23 changes: 23 additions & 0 deletions plugins/baser-core/tests/TestCase/Model/Entity/PluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,27 @@ public function testIsPlugin()
$this->assertFalse($this->Plugin->isPlugin());
}

/**
* @dataProvider hasTypeDataProvider
*/
public function test_hasType($type, $types, $expected)
{
$this->Plugin->type = $type;
$result = $this->Plugin->hasType($types);
$this->assertEquals($expected, $result);
}

public static function hasTypeDataProvider()
{
return [
[null, ['exampleType'], false],
['exampleType', ['exampleType'], true],
['exampleType', ['otherType'], false],
[['exampleType', 'anotherType'], ['exampleType'], true],
[['exampleType', 'anotherType'], ['anotherType'], true],
[['exampleType', 'anotherType'], ['differentType'], false]
];
}


}
26 changes: 20 additions & 6 deletions plugins/baser-core/tests/TestCase/Utility/BcUtilTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -817,12 +817,6 @@ public function testGetCurrentDomain()
*/
public function testGetSubDomain($host, $currentHost, $expects, $message)
{

// TODO ucmitz移行時に未実装のため代替措置
// >>>
$this->markTestIncomplete('このテストは、まだ実装されていません。');
// <<<

Configure::write('BcEnv.mainDomain', 'localhost');
if ($currentHost) {
Configure::write('BcEnv.host', $currentHost);
Expand Down Expand Up @@ -1550,5 +1544,25 @@ public function test_getLoggedInUsers()
$this->assertEquals('baser admin', $result['Api/Admin']->name);
}

public function test_isInstalled()
{
// Set the 'BcEnv.isInstalled' configuration to true
Configure::write('BcEnv.isInstalled', true);
$this->assertTrue(BcUtil::isInstalled());

// Set the 'BcEnv.isInstalled' configuration to false
Configure::write('BcEnv.isInstalled', false);
$this->assertFalse(BcUtil::isInstalled());
}

public function test_isDebug()
{
// Set the debug configuration to true
Configure::write('debug', true);
$this->assertTrue(BcUtil::isDebug());

// Set the debug configuration to false
Configure::write('debug', false);
$this->assertFalse(BcUtil::isDebug());
}
}
26 changes: 26 additions & 0 deletions plugins/baser-core/tests/TestCase/View/BcFrontEmailViewTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace BaserCore\Test\TestCase\View;

use BaserCore\TestSuite\BcTestCase;
use BaserCore\View\BcFrontEmailView;

class BcFrontEmailViewTest extends BcTestCase
{
public function setUp(): void
{
parent::setUp();
$this->BcFrontEmailView = new BcFrontEmailView($this->getRequest());
}

public function tearDown(): void
{
unset($this->BcFrontEmailView);
parent::tearDown();
}

public function testInitialize(): void
{
$this->assertNotEmpty($this->BcFrontEmailView->BcHtml);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,24 @@ public function testAddText()
$this->assertEquals($expect, $result);
}

public function test_addTextWithPrefixAndSuffix()
{
$value = 'test';
$this->execPrivateMethod($this->Helper, '__addText', [&$value, null, "prefix-,-suffix"]);
$this->assertEquals("prefix-test-suffix", $value);
}

public function test_addTextWithOnlyPrefix()
{
$value = 'test';
$this->execPrivateMethod($this->Helper, '__addText', [&$value, null, "prefix-,"]);
$this->assertEquals("prefix-test", $value);
}

public function test_AddTextWithOnlySuffix()
{
$value = 'test';
$this->execPrivateMethod($this->Helper, '__addText', [&$value, null, ",-suffix"]);
$this->assertEquals("test-suffix", $value);
}
}
Loading

0 comments on commit 84b2f2c

Please sign in to comment.