From 5c371a6d0b3a2bfcf6d0e0d0971afb2503d18297 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 4 Mar 2015 09:43:37 +0100 Subject: [PATCH] Fix form tests --- .../forms/Config/Authentication/DbBackendFormTest.php | 10 ++++++++-- .../Config/Authentication/LdapBackendFormTest.php | 10 ++++++++-- .../forms/Config/Resource/LdapResourceFormTest.php | 10 ++++++++-- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/test/php/application/forms/Config/Authentication/DbBackendFormTest.php b/test/php/application/forms/Config/Authentication/DbBackendFormTest.php index 2dc7fb5a0..b7d1ea3c1 100644 --- a/test/php/application/forms/Config/Authentication/DbBackendFormTest.php +++ b/test/php/application/forms/Config/Authentication/DbBackendFormTest.php @@ -31,7 +31,10 @@ class DbBackendFormTest extends BaseTestCase ->shouldReceive('count') ->andReturn(2); - $form = new DbBackendForm(); + $form = Mockery::mock('Icinga\Forms\Config\Authentication\DbBackendForm[getView]'); + $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')); @@ -53,7 +56,10 @@ class DbBackendFormTest extends BaseTestCase ->shouldReceive('count') ->andReturn(0); - $form = new DbBackendForm(); + $form = Mockery::mock('Icinga\Forms\Config\Authentication\DbBackendForm[getView]'); + $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')); diff --git a/test/php/application/forms/Config/Authentication/LdapBackendFormTest.php b/test/php/application/forms/Config/Authentication/LdapBackendFormTest.php index 561d61b1c..d31033ba9 100644 --- a/test/php/application/forms/Config/Authentication/LdapBackendFormTest.php +++ b/test/php/application/forms/Config/Authentication/LdapBackendFormTest.php @@ -31,7 +31,10 @@ class LdapBackendFormTest extends BaseTestCase Mockery::mock('overload:Icinga\Authentication\Backend\LdapUserBackend') ->shouldReceive('assertAuthenticationPossible')->andReturnNull(); - $form = new LdapBackendForm(); + $form = Mockery::mock('Icinga\Forms\Config\Authentication\LdapBackendForm[getView]'); + $form->shouldReceive('getView->escape') + ->with(Mockery::type('string')) + ->andReturnUsing(function ($s) { return $s; }); $form->setTokenDisabled(); $form->setResources(array('test_ldap_backend')); $form->populate(array('resource' => 'test_ldap_backend')); @@ -52,7 +55,10 @@ class LdapBackendFormTest extends BaseTestCase Mockery::mock('overload:Icinga\Authentication\Backend\LdapUserBackend') ->shouldReceive('assertAuthenticationPossible')->andThrow(new AuthenticationException); - $form = new LdapBackendForm(); + $form = Mockery::mock('Icinga\Forms\Config\Authentication\LdapBackendForm[getView]'); + $form->shouldReceive('getView->escape') + ->with(Mockery::type('string')) + ->andReturnUsing(function ($s) { return $s; }); $form->setTokenDisabled(); $form->setResources(array('test_ldap_backend')); $form->populate(array('resource' => 'test_ldap_backend')); diff --git a/test/php/application/forms/Config/Resource/LdapResourceFormTest.php b/test/php/application/forms/Config/Resource/LdapResourceFormTest.php index f6d823046..d074f1b3b 100644 --- a/test/php/application/forms/Config/Resource/LdapResourceFormTest.php +++ b/test/php/application/forms/Config/Resource/LdapResourceFormTest.php @@ -29,7 +29,10 @@ class LdapResourceFormTest extends BaseTestCase Mockery::mock()->shouldReceive('testCredentials')->once()->andReturn(true)->getMock() ); - $form = new LdapResourceForm(); + $form = Mockery::mock('Icinga\Forms\Config\Resource\LdapResourceForm[getView]'); + $form->shouldReceive('getView->escape') + ->with(Mockery::type('string')) + ->andReturnUsing(function ($s) { return $s; }); $form->setTokenDisabled(); $this->assertTrue( @@ -48,7 +51,10 @@ class LdapResourceFormTest extends BaseTestCase Mockery::mock()->shouldReceive('testCredentials')->once()->andThrow('\Exception')->getMock() ); - $form = new LdapResourceForm(); + $form = Mockery::mock('Icinga\Forms\Config\Resource\LdapResourceForm[getView]'); + $form->shouldReceive('getView->escape') + ->with(Mockery::type('string')) + ->andReturnUsing(function ($s) { return $s; }); $form->setTokenDisabled(); $this->assertFalse(