Skip to content

Commit

Permalink
ユニットテストの失敗を調整
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuring committed Apr 23, 2024
1 parent 098b723 commit 8357a91
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
7 changes: 5 additions & 2 deletions plugins/baser-core/tests/TestCase/PluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace BaserCore\Test\TestCase;

use App\Application;
use Authentication\Middleware\AuthenticationMiddleware;
use BaserCore\BaserCorePlugin;
use BaserCore\Service\SiteConfigsServiceInterface;
use BaserCore\TestSuite\BcTestCase;
Expand All @@ -22,6 +23,7 @@
use Cake\Event\EventManager;
use Cake\Http\Middleware\CsrfProtectionMiddleware;
use Cake\Http\MiddlewareQueue;
use Cake\Routing\Middleware\RoutingMiddleware;
use Cake\Routing\Router;
use Cake\Filesystem\File;

Expand Down Expand Up @@ -175,9 +177,10 @@ public function testMiddleware(): void
{
$middleware = new MiddlewareQueue();
$middleware->add(CsrfProtectionMiddleware::class);
$middleware->add(RoutingMiddleware::class);
$middlewareQueue = $this->Plugin->middleware($middleware);
$this->assertInstanceOf(BcRequestFilterMiddleware::class, $middlewareQueue->current());
$this->assertEquals(6, $middlewareQueue->count());
$this->assertInstanceOf(AuthenticationMiddleware::class, $middlewareQueue->current());
$this->assertEquals(7, $middlewareQueue->count());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,14 @@ public function saveSearchIndex($searchIndex)
}
$searchIndex['model'] = Inflector::classify($this->table->getAlias());
// タグ、空白を除外
$searchIndex['detail'] = str_replace(["\r\n", "\r", "\n", "\t", "\s"], '', trim(strip_tags($searchIndex['detail'])));

// MySQLの場合、検索テーブル'detail'では半角65535以上の文字数は保存できないため、オーバーした分はカットする。※str_ends_with()は php8系~
$db = ConnectionManager::get('default')->config()['driver'];
if (str_ends_with($db, 'Mysql') && mb_strlen($searchIndex['detail']) >= 21845) {
$searchIndex['detail'] = mb_substr($searchIndex['detail'],0, 21844);
if(!empty($searchIndex['detail'])) {
$searchIndex['detail'] = str_replace(["\r\n", "\r", "\n", "\t", "\s"], '', trim(strip_tags($searchIndex['detail'])));
// MySQLの場合、検索テーブル'detail'では半角65535以上の文字数は保存できないため、オーバーした分はカットする。※str_ends_with()は php8系~
$db = ConnectionManager::get('default')->config()['driver'];
if (str_ends_with($db, 'Mysql') && mb_strlen($searchIndex['detail']) >= 21845) {
$searchIndex['detail'] = mb_substr($searchIndex['detail'], 0, 21844);
}
}

// 検索用データとして保存
Expand Down

0 comments on commit 8357a91

Please sign in to comment.