Skip to content

Commit

Permalink
Fix form tests utilizing Mockery's partial mock functionality
Browse files Browse the repository at this point in the history
Since an update of Mockery, partial mocks do not call the constructor
of their mocked classes anymore without explicitly passing a non empty
array. This is a regression of the following bug:
mockery/mockery#144
  • Loading branch information
Johannes Meyer committed Apr 30, 2015
1 parent d27b94d commit 034421d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
Expand Up @@ -31,7 +31,8 @@ public function testValidBackendIsValid()
->shouldReceive('count')
->andReturn(2);

$form = Mockery::mock('Icinga\Forms\Config\Authentication\DbBackendForm[getView]');
// Passing array(null) is required to make Mockery call the constructor...
$form = Mockery::mock('Icinga\Forms\Config\Authentication\DbBackendForm[getView]', array(null));
$form->shouldReceive('getView->escape')
->with(Mockery::type('string'))
->andReturnUsing(function ($s) { return $s; });
Expand All @@ -56,7 +57,8 @@ public function testInvalidBackendIsNotValid()
->shouldReceive('count')
->andReturn(0);

$form = Mockery::mock('Icinga\Forms\Config\Authentication\DbBackendForm[getView]');
// Passing array(null) is required to make Mockery call the constructor...
$form = Mockery::mock('Icinga\Forms\Config\Authentication\DbBackendForm[getView]', array(null));
$form->shouldReceive('getView->escape')
->with(Mockery::type('string'))
->andReturnUsing(function ($s) { return $s; });
Expand Down
Expand Up @@ -31,7 +31,8 @@ public function testValidBackendIsValid()
Mockery::mock('overload:Icinga\Authentication\Backend\LdapUserBackend')
->shouldReceive('assertAuthenticationPossible')->andReturnNull();

$form = Mockery::mock('Icinga\Forms\Config\Authentication\LdapBackendForm[getView]');
// Passing array(null) is required to make Mockery call the constructor...
$form = Mockery::mock('Icinga\Forms\Config\Authentication\LdapBackendForm[getView]', array(null));
$form->shouldReceive('getView->escape')
->with(Mockery::type('string'))
->andReturnUsing(function ($s) { return $s; });
Expand All @@ -55,7 +56,8 @@ public function testInvalidBackendIsNotValid()
Mockery::mock('overload:Icinga\Authentication\Backend\LdapUserBackend')
->shouldReceive('assertAuthenticationPossible')->andThrow(new AuthenticationException);

$form = Mockery::mock('Icinga\Forms\Config\Authentication\LdapBackendForm[getView]');
// Passing array(null) is required to make Mockery call the constructor...
$form = Mockery::mock('Icinga\Forms\Config\Authentication\LdapBackendForm[getView]', array(null));
$form->shouldReceive('getView->escape')
->with(Mockery::type('string'))
->andReturnUsing(function ($s) { return $s; });
Expand Down
Expand Up @@ -29,7 +29,8 @@ public function testValidLdapResourceIsValid()
Mockery::mock()->shouldReceive('testCredentials')->once()->andReturn(true)->getMock()
);

$form = Mockery::mock('Icinga\Forms\Config\Resource\LdapResourceForm[getView]');
// Passing array(null) is required to make Mockery call the constructor...
$form = Mockery::mock('Icinga\Forms\Config\Resource\LdapResourceForm[getView]', array(null));
$form->shouldReceive('getView->escape')
->with(Mockery::type('string'))
->andReturnUsing(function ($s) { return $s; });
Expand All @@ -51,7 +52,8 @@ public function testInvalidLdapResourceIsNotValid()
Mockery::mock()->shouldReceive('testCredentials')->once()->andThrow('\Exception')->getMock()
);

$form = Mockery::mock('Icinga\Forms\Config\Resource\LdapResourceForm[getView]');
// Passing array(null) is required to make Mockery call the constructor...
$form = Mockery::mock('Icinga\Forms\Config\Resource\LdapResourceForm[getView]', array(null));
$form->shouldReceive('getView->escape')
->with(Mockery::type('string'))
->andReturnUsing(function ($s) { return $s; });
Expand Down

0 comments on commit 034421d

Please sign in to comment.