From 7eab09c2a214acb89cae3eb56aa59b3805d4db7c Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 18 Nov 2014 16:06:39 +0100 Subject: [PATCH] Tests: Fix ApplicationBootstrap mock --- library/Icinga/Test/BaseTestCase.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Test/BaseTestCase.php b/library/Icinga/Test/BaseTestCase.php index 41cd1099c..c70bc5cd9 100644 --- a/library/Icinga/Test/BaseTestCase.php +++ b/library/Icinga/Test/BaseTestCase.php @@ -158,11 +158,17 @@ namespace Icinga\Test { ->andReturnUsing(function ($name, $default) { return $default; })->byDefault(); $responseMock = Mockery::mock('Icinga\Web\Response')->shouldDeferMissing(); - // Can't express this as demeter chains. See: https://github.com/padraic/mockery/issues/59 $bootstrapMock = Mockery::mock('Icinga\Application\ApplicationBootstrap')->shouldDeferMissing(); + $libDir = dirname(self::$libDir); $bootstrapMock->shouldReceive('getFrontController')->andReturn($bootstrapMock) ->shouldReceive('getApplicationDir')->andReturn(self::$appDir) + ->shouldReceive('getLibraryDir')->andReturnUsing(function ($subdir = null) use ($libDir) { + if ($subdir !== null) { + $libDir .= '/' . ltrim($subdir, '/'); + } + return $libDir; + }) ->shouldReceive('getRequest')->andReturn($requestMock) ->shouldReceive('getResponse')->andReturn($responseMock);