From 6d209ee20316015490b91a84ab60435ba2ca541d Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 16 Jul 2015 16:22:13 +0200 Subject: [PATCH] Fix unit DB Form unit tests broken by inspection refs #9641 --- .../Config/UserBackend/DbBackendFormTest.php | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/test/php/application/forms/Config/UserBackend/DbBackendFormTest.php b/test/php/application/forms/Config/UserBackend/DbBackendFormTest.php index d58ff8a33..f1fe7b84d 100644 --- a/test/php/application/forms/Config/UserBackend/DbBackendFormTest.php +++ b/test/php/application/forms/Config/UserBackend/DbBackendFormTest.php @@ -28,8 +28,8 @@ class DbBackendFormTest extends BaseTestCase { $this->setUpResourceFactoryMock(); Mockery::mock('overload:Icinga\Authentication\User\DbUserBackend') - ->shouldReceive('select->where->count') - ->andReturn(2); + ->shouldReceive('inspect') + ->andReturn(self::createInspector(false)); // Passing array(null) is required to make Mockery call the constructor... $form = Mockery::mock('Icinga\Forms\Config\UserBackend\DbBackendForm[getView]', array(null)); @@ -54,8 +54,8 @@ class DbBackendFormTest extends BaseTestCase { $this->setUpResourceFactoryMock(); Mockery::mock('overload:Icinga\Authentication\User\DbUserBackend') - ->shouldReceive('count') - ->andReturn(0); + ->shouldReceive('inspect') + ->andReturn(self::createInspector(true)); // Passing array(null) is required to make Mockery call the constructor... $form = Mockery::mock('Icinga\Forms\Config\UserBackend\DbBackendForm[getView]', array(null)); @@ -80,4 +80,21 @@ class DbBackendFormTest extends BaseTestCase ->shouldReceive('getResourceConfig') ->andReturn(new ConfigObject()); } + + public static function createInspector($error = false, $log = array('log')) + { + if (! $error) { + $calls = array( + 'hasError' => false, + 'toArray' => $log + ); + } else { + $calls = array( + 'hasError' => true, + 'getError' => 'Error', + 'toArray' => $log + ); + } + return Mockery::mock('Icinga\Data\Inspection', $calls); + } }