From f8f8a4c84844f1b9c06a0df4f9eadb5edc98fa94 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 24 Jul 2015 10:51:33 +0200 Subject: [PATCH] Drop DbBackendFormTest It's redundant now, we should test the inspection code directly instead. --- .../Config/UserBackend/DbBackendFormTest.php | 104 ------------------ 1 file changed, 104 deletions(-) delete mode 100644 test/php/application/forms/Config/UserBackend/DbBackendFormTest.php 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); - } -}