diff --git a/test/php/application/forms/Config/UserBackend/DbBackendFormTest.php b/test/php/application/forms/Config/UserBackend/DbBackendFormTest.php deleted file mode 100644 index cc6919c93..000000000 --- a/test/php/application/forms/Config/UserBackend/DbBackendFormTest.php +++ /dev/null @@ -1,104 +0,0 @@ -setUpResourceFactoryMock(); - Mockery::mock('overload:Icinga\Authentication\User\DbUserBackend') - ->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)); - $form->shouldReceive('getView->escape') - ->with(Mockery::type('string')) - ->andReturnUsing(function ($s) { - return $s; - }); - $form->setTokenDisabled(); - $form->setResources(array('test_db_backend')); - $form->populate(array('resource' => 'test_db_backend')); - - $this->assertTrue( - DbBackendForm::isValidUserBackend($form), - 'DbBackendForm claims that a valid user backend with users is not valid' - ); - } - - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ - public function testInvalidBackendIsNotValid() - { - $this->setUpResourceFactoryMock(); - Mockery::mock('overload:Icinga\Authentication\User\DbUserBackend') - ->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)); - $form->shouldReceive('getView->escape') - ->with(Mockery::type('string')) - ->andReturnUsing(function ($s) { - return $s; - }); - $form->setTokenDisabled(); - $form->setResources(array('test_db_backend')); - $form->populate(array('resource' => 'test_db_backend')); - - $this->assertFalse( - DbBackendForm::isValidUserBackend($form), - 'DbBackendForm claims that an invalid user backend without users is valid' - ); - } - - protected function setUpResourceFactoryMock() - { - Mockery::mock('alias:Icinga\Data\ResourceFactory') - ->shouldReceive('createResource') - ->andReturn(Mockery::mock('Icinga\Data\Db\DbConnection')) - ->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); - } -}