setUpResourceFactoryMock( Mockery::mock()->shouldReceive('connect')->andReturn(Mockery::self()) ->shouldReceive('disconnect')->getMock() ); $this->assertTrue( LivestatusResourceForm::isValidResource(new LivestatusResourceForm()), 'ResourceForm claims that a valid livestatus resource is not valid' ); } /** * @runInSeparateProcess * @preserveGlobalState disabled */ public function testInvalidLivestatusResourceIsNotValid() { $this->setUpResourceFactoryMock( Mockery::mock()->shouldReceive('connect')->once()->andThrow('\Exception')->getMock() ); $this->assertFalse( LivestatusResourceForm::isValidResource(new LivestatusResourceForm()), 'ResourceForm claims that an invalid livestatus resource is valid' ); } protected function setUpResourceFactoryMock($resourceMock) { Mockery::mock('alias:Icinga\Data\ResourceFactory') ->shouldReceive('createResource') ->with(Mockery::type('Icinga\Data\ConfigObject')) ->andReturn($resourceMock); } }