diff --git a/test/php/application/forms/Config/Authentication/DbBackendFormTest.php b/test/php/application/forms/Config/Authentication/DbBackendFormTest.php index 7474d27034..f110652947 100644 --- a/test/php/application/forms/Config/Authentication/DbBackendFormTest.php +++ b/test/php/application/forms/Config/Authentication/DbBackendFormTest.php @@ -9,6 +9,7 @@ require_once realpath(dirname(__FILE__) . '/../../../../bootstrap.php'); use Mockery; +use Zend_Config; use Icinga\Test\BaseTestCase; use Icinga\Form\Config\Authentication\DbBackendForm; @@ -67,7 +68,9 @@ public function testInvalidBackendIsNotValid() protected function setUpResourceFactoryMock() { Mockery::mock('alias:Icinga\Data\ResourceFactory') - ->shouldReceive('create') - ->andReturn(Mockery::mock('Icinga\Data\Db\DbConnection')); + ->shouldReceive('createResource') + ->andReturn(Mockery::mock('Icinga\Data\Db\DbConnection')) + ->shouldReceive('getResourceConfig') + ->andReturn(new Zend_Config(array())); } } diff --git a/test/php/application/forms/Config/Authentication/LdapBackendFormTest.php b/test/php/application/forms/Config/Authentication/LdapBackendFormTest.php index c38f26376e..2b8a90b4d5 100644 --- a/test/php/application/forms/Config/Authentication/LdapBackendFormTest.php +++ b/test/php/application/forms/Config/Authentication/LdapBackendFormTest.php @@ -9,6 +9,7 @@ require_once realpath(dirname(__FILE__) . '/../../../../bootstrap.php'); use Mockery; +use Zend_Config; use Icinga\Test\BaseTestCase; use Icinga\Form\Config\Authentication\LdapBackendForm; use Icinga\Exception\AuthenticationException; @@ -66,9 +67,9 @@ public function testInvalidBackendIsNotValid() protected function setUpResourceFactoryMock() { Mockery::mock('alias:Icinga\Data\ResourceFactory') + ->shouldReceive('createResource') + ->andReturn(Mockery::mock('Icinga\Protocol\Ldap\Connection')) ->shouldReceive('getResourceConfig') - ->andReturn(new \Zend_Config(array())) - ->shouldReceive('create') - ->andReturn(Mockery::mock('Icinga\Protocol\Ldap\Connection')); + ->andReturn(new Zend_Config(array())); } } diff --git a/test/php/application/forms/Config/Resource/LdapResourceFormTest.php b/test/php/application/forms/Config/Resource/LdapResourceFormTest.php index b17a01a063..614f38f3a7 100644 --- a/test/php/application/forms/Config/Resource/LdapResourceFormTest.php +++ b/test/php/application/forms/Config/Resource/LdapResourceFormTest.php @@ -27,11 +27,14 @@ public function tearDown() public function testValidLdapResourceIsValid() { $this->setUpResourceFactoryMock( - Mockery::mock()->shouldReceive('connect')->getMock() + Mockery::mock()->shouldReceive('testCredentials')->once()->andReturn(true)->getMock() ); + $form = new LdapResourceForm(); + $form->setTokenDisabled(); + $this->assertTrue( - LdapResourceForm::isValidResource(new LdapResourceForm()), + LdapResourceForm::isValidResource($form->create()), 'ResourceForm claims that a valid ldap resource is not valid' ); } @@ -43,11 +46,14 @@ public function testValidLdapResourceIsValid() public function testInvalidLdapResourceIsNotValid() { $this->setUpResourceFactoryMock( - Mockery::mock()->shouldReceive('connect')->once()->andThrow('\Exception')->getMock() + Mockery::mock()->shouldReceive('testCredentials')->once()->andThrow('\Exception')->getMock() ); + $form = new LdapResourceForm(); + $form->setTokenDisabled(); + $this->assertFalse( - LdapResourceForm::isValidResource(new LdapResourceForm()), + LdapResourceForm::isValidResource($form->create()), 'ResourceForm claims that an invalid ldap resource is valid' ); }