Fix form tests

This commit is contained in:
Johannes Meyer 2015-03-04 09:43:37 +01:00
parent ff263946c8
commit 5c371a6d0b
3 changed files with 24 additions and 6 deletions

View File

@ -31,7 +31,10 @@ class DbBackendFormTest extends BaseTestCase
->shouldReceive('count') ->shouldReceive('count')
->andReturn(2); ->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->setTokenDisabled();
$form->setResources(array('test_db_backend')); $form->setResources(array('test_db_backend'));
$form->populate(array('resource' => 'test_db_backend')); $form->populate(array('resource' => 'test_db_backend'));
@ -53,7 +56,10 @@ class DbBackendFormTest extends BaseTestCase
->shouldReceive('count') ->shouldReceive('count')
->andReturn(0); ->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->setTokenDisabled();
$form->setResources(array('test_db_backend')); $form->setResources(array('test_db_backend'));
$form->populate(array('resource' => 'test_db_backend')); $form->populate(array('resource' => 'test_db_backend'));

View File

@ -31,7 +31,10 @@ class LdapBackendFormTest extends BaseTestCase
Mockery::mock('overload:Icinga\Authentication\Backend\LdapUserBackend') Mockery::mock('overload:Icinga\Authentication\Backend\LdapUserBackend')
->shouldReceive('assertAuthenticationPossible')->andReturnNull(); ->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->setTokenDisabled();
$form->setResources(array('test_ldap_backend')); $form->setResources(array('test_ldap_backend'));
$form->populate(array('resource' => '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') Mockery::mock('overload:Icinga\Authentication\Backend\LdapUserBackend')
->shouldReceive('assertAuthenticationPossible')->andThrow(new AuthenticationException); ->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->setTokenDisabled();
$form->setResources(array('test_ldap_backend')); $form->setResources(array('test_ldap_backend'));
$form->populate(array('resource' => 'test_ldap_backend')); $form->populate(array('resource' => 'test_ldap_backend'));

View File

@ -29,7 +29,10 @@ class LdapResourceFormTest extends BaseTestCase
Mockery::mock()->shouldReceive('testCredentials')->once()->andReturn(true)->getMock() 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(); $form->setTokenDisabled();
$this->assertTrue( $this->assertTrue(
@ -48,7 +51,10 @@ class LdapResourceFormTest extends BaseTestCase
Mockery::mock()->shouldReceive('testCredentials')->once()->andThrow('\Exception')->getMock() 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(); $form->setTokenDisabled();
$this->assertFalse( $this->assertFalse(