Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/TestApp/Model/Table/CommentsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function initialize(array $config): void
{
$this->addBehavior('Search.Search');

$this->searchManager()
$this->getBehavior('Search')->searchManager()
->value('Comments.foo')
->like('Comments.search', ['filterEmpty' => true, 'multiValue' => true])
->value('Comments.baz')
Expand Down
2 changes: 1 addition & 1 deletion tests/TestApp/Model/Table/SectionsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function initialize(array $config): void
{
$this->addBehavior('Search.Search');

$this->searchManager()
$this->getBehavior('Search')->searchManager()
->useCollection('frontend')
->value('title')
->useCollection('backend')
Expand Down
15 changes: 15 additions & 0 deletions tests/TestCase/Controller/Component/SearchComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,21 @@ protected function _execute(array $data = []): bool
}
};

// CakePHP 5.3+ uses process() instead of _execute()
if (method_exists(SearchForm::class, 'process')) {
$mock = new class extends SearchForm
{
public static $called = false;

protected function process(array $data = []): bool
{
static::$called = true;

return true;
}
};
}

$this->Search->setConfig('formClass', $mock::class);

$this->Controller->setRequest($request);
Expand Down
12 changes: 6 additions & 6 deletions tests/TestCase/Model/Behavior/SearchBehaviorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public function testFinder()
'search' => 'b',
'group' => 'main',
];
$this->assertFalse($this->Articles->isSearch());
$this->assertFalse($this->Articles->getBehavior('Search')->isSearch());

$query = $this->Articles->find('search', search: $queryString);
$this->assertEquals(3, $query->clause('where')->count());
Expand All @@ -204,7 +204,7 @@ public function testFinder()
],
);
$this->assertEquals(2, $query->clause('where')->count());
$this->assertTrue($this->Articles->isSearch());
$this->assertTrue($this->Articles->getBehavior('Search')->isSearch());
}

/**
Expand All @@ -227,7 +227,7 @@ public function testEmptyValues()
$this->Articles->addBehavior('Search.Search', [
'emptyValues' => ['a'],
]);
$this->Articles->searchManager()
$this->Articles->getBehavior('Search')->searchManager()
->value('foo')
->like('search')
->value('baz')
Expand All @@ -239,7 +239,7 @@ public function testEmptyValues()
$this->Articles->addBehavior('Search.Search', [
'emptyValues' => ['a', '0'],
]);
$this->Articles->searchManager()
$this->Articles->getBehavior('Search')->searchManager()
->value('foo')
->like('search')
->value('baz')
Expand Down Expand Up @@ -315,14 +315,14 @@ public static function collectionFinderProvider()
*/
public function testSearchManager()
{
$manager = $this->Articles->searchManager();
$manager = $this->Articles->getBehavior('Search')->searchManager();
$this->assertInstanceOf('\Search\Manager', $manager);
}

public function testExtraParams(): void
{
$result = [];
$manager = $this->Articles->searchManager();
$manager = $this->Articles->getBehavior('Search')->searchManager();
$manager->callback('field1', [
'callback' => function (SelectQuery $query, array $args) use (&$result) {
$result = $args;
Expand Down