Skip to content

Feature: Add Tests for Search and SyncNotion Actions#179

Merged
128na merged 4 commits into
masterfrom
feature/test-search-notion
Jun 2, 2026
Merged

Feature: Add Tests for Search and SyncNotion Actions#179
128na merged 4 commits into
masterfrom
feature/test-search-notion

Conversation

@128na
Copy link
Copy Markdown
Owner

@128na 128na commented Jun 2, 2026

SearchActionおよびSyncNotion Actionに対するテストを追加しました。また、SearchActionにおける除外検索の論理バグを修正しました。

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request groups search query conditions within closures in SearchAction to ensure correct logical operator precedence, and introduces comprehensive feature tests for both SearchAction and SyncAction. Feedback suggests skipping empty strings during keyword parsing to prevent redundant LIKE '%%' queries, and avoiding the use of reflection on external library classes in tests to reduce fragility.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines 39 to 41
if (str_starts_with($word, '-')) {
$word = trim(substr($word, 1));
if ($word !== '' && $word !== '0') {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

キーワードに複数の連続したスペースが含まれている場合、explode(' ', $keyword) によって空文字列 "" が生成されます。このとき、str_starts_with($word, '-')false となり、else ブロックが実行されて LIKE '%%' という不要なクエリが追加されてしまいます。

これを防ぐために、ループの先頭で空文字列をスキップすることをお勧めします。

また、日本語環境では全角スペース( )が区切り文字として使われることが多いため、将来的に全角スペースへの対応(preg_split への変更など)も検討するとより良くなります。

                if ($word === '') {
                    continue;
                }
                if (str_starts_with($word, '-')) {
                    $word = trim(substr($word, 1));
                    if ($word !== '' && $word !== '0') {

Comment on lines +55 to +56
$propertyCollection = (new \ReflectionClass(PropertyCollection::class))->newInstanceWithoutConstructor();
$this->setReadonlyProperty($propertyCollection, 'properties', ['パックセット' => $multiSelect]);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

テスト内でリフレクション(ReflectionClassReflectionProperty)を使用して、外部ライブラリ(Notion SDK)の内部プロパティや読み取り専用プロパティを強制的に設定しています。

これはライブラリの内部実装に強く依存するため、ライブラリのアップデートやPHPのバージョンアップ(特に readonly プロパティの挙動変更など)によってテストが突然破損するリスクがあります。

可能であれば、PropertyCollection も Mockery でモックするか、ライブラリが提供する公式のファクトリメソッドやビルダーを使用することを検討してください。

@128na
Copy link
Copy Markdown
Owner Author

128na commented Jun 2, 2026

AIレビューの指摘内容が妥当であったため、以下の通り修正を行いました。

  1. \SearchAction.php: キーワード検索時に空文字が渡された場合、スキップ処理(\continue;\)を追加し、不要な \LIKE '%%'\ クエリが発生しないよう改善しました。
  2. \SyncActionTest.php: 外部ライブラリ(Notion SDK)の private プロパティ等を Reflection を使って強引にモックしていた箇所を廃止し、SDK に用意されている \Database::fromArray()\ などの公式なファクトリメソッドを活用したモックに置き換えることで、テストの堅牢性を高めました。

1 similar comment
@128na
Copy link
Copy Markdown
Owner Author

128na commented Jun 2, 2026

AIレビューの指摘内容が妥当であったため、以下の通り修正を行いました。

  1. \SearchAction.php: キーワード検索時に空文字が渡された場合、スキップ処理(\continue;\)を追加し、不要な \LIKE '%%'\ クエリが発生しないよう改善しました。
  2. \SyncActionTest.php: 外部ライブラリ(Notion SDK)の private プロパティ等を Reflection を使って強引にモックしていた箇所を廃止し、SDK に用意されている \Database::fromArray()\ などの公式なファクトリメソッドを活用したモックに置き換えることで、テストの堅牢性を高めました。

@128na 128na force-pushed the feature/test-search-notion branch from 46e8907 to 395691a Compare June 2, 2026 14:36
@128na 128na merged commit 09a28e0 into master Jun 2, 2026
5 checks passed
@128na 128na deleted the feature/test-search-notion branch June 2, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants