From 2047aaba47b25f6ea9492cf53a655d5e342e82b0 Mon Sep 17 00:00:00 2001 From: Gregor Date: Tue, 2 Jul 2024 12:10:47 +0200 Subject: [PATCH] fixed failing testCustomSelector test #3 --- .../Component/FilterComponentTest.php | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/Test/Case/Controller/Component/FilterComponentTest.php b/Test/Case/Controller/Component/FilterComponentTest.php index 510c79a..8b9f2b3 100644 --- a/Test/Case/Controller/Component/FilterComponentTest.php +++ b/Test/Case/Controller/Component/FilterComponentTest.php @@ -49,17 +49,10 @@ public function setUp(): void $this->Controller = new DocumentTestsController($request); $this->Controller->uses = array('Document'); - if (array_search($method, array('testPersistence')) !== false) { - $this->Controller->components = array( - 'Session', - 'Filter.Filter' => array('nopersist' => true) - ); - } else { - $this->Controller->components = array( - 'Session', - 'Filter.Filter' - ); - } + $this->Controller->components = array( + 'Session', + 'Filter.Filter' + ); $this->Controller->constructClasses(); $this->Controller->Session->destroy(); @@ -440,6 +433,16 @@ public function testCustomSelector(): void ) ) ); + + /** + * For some reason the mock object DocumentCategory is not found by + * ClassRegistry::init('DocumentCategory'); + * in + * FilterComponent.php:216 + * This line adds the mock object as model class for DocumentCategory. + */ + ClassRegistry::addObject('document_category', new DocumentCategory()); + $this->Controller->filters = $testSettings; $this->Controller->Components->trigger('initialize', array($this->Controller));