diff options
-rwxr-xr-x | apps/files_encryption/lib/helper.php | 11 | ||||
-rw-r--r-- | tests/lib/appframework/middleware/MiddlewareTest.php | 6 | ||||
-rw-r--r-- | tests/lib/appframework/middleware/security/SecurityMiddlewareTest.php | 13 | ||||
-rw-r--r-- | tests/phpunit-autotest.xml | 1 |
4 files changed, 22 insertions, 9 deletions
diff --git a/apps/files_encryption/lib/helper.php b/apps/files_encryption/lib/helper.php index 787a6ea5539..1bd21f92573 100755 --- a/apps/files_encryption/lib/helper.php +++ b/apps/files_encryption/lib/helper.php @@ -367,9 +367,14 @@ class Helper { $post = 0; if(count($_POST) > 0) { $post = 1; - } - header('Location: ' . $location . '?p=' . $post . '&errorCode=' . $errorCode); - exit(); + } + + if(defined('PHPUNIT_RUN') and PHPUNIT_RUN) { + throw new \Exception("Encryption error: $errorCode"); + } + + header('Location: ' . $location . '?p=' . $post . '&errorCode=' . $errorCode); + exit(); } /** diff --git a/tests/lib/appframework/middleware/MiddlewareTest.php b/tests/lib/appframework/middleware/MiddlewareTest.php index 7a93c0d4dda..c315f9cf3f7 100644 --- a/tests/lib/appframework/middleware/MiddlewareTest.php +++ b/tests/lib/appframework/middleware/MiddlewareTest.php @@ -44,8 +44,10 @@ class MiddlewareTest extends \PHPUnit_Framework_TestCase { protected function setUp(){ $this->middleware = new ChildMiddleware(); - $this->api = $this->getMock('OC\AppFramework\DependencyInjection\DIContainer', - array(), array('test')); + $this->api = $this->getMockBuilder( + 'OC\AppFramework\DependencyInjection\DIContainer') + ->disableOriginalConstructor() + ->getMock(); $this->controller = $this->getMock('OCP\AppFramework\Controller', array(), array($this->api, new Request())); diff --git a/tests/lib/appframework/middleware/security/SecurityMiddlewareTest.php b/tests/lib/appframework/middleware/security/SecurityMiddlewareTest.php index dae6135dc54..6473d304029 100644 --- a/tests/lib/appframework/middleware/security/SecurityMiddlewareTest.php +++ b/tests/lib/appframework/middleware/security/SecurityMiddlewareTest.php @@ -39,7 +39,10 @@ class SecurityMiddlewareTest extends \PHPUnit_Framework_TestCase { private $request; public function setUp() { - $api = $this->getMock('OC\AppFramework\DependencyInjection\DIContainer', array(), array('test')); + $api = $this->getMockBuilder( + 'OC\AppFramework\DependencyInjection\DIContainer') + ->disableOriginalConstructor() + ->getMock(); $this->controller = $this->getMock('OCP\AppFramework\Controller', array(), array($api, new Request())); @@ -297,7 +300,11 @@ class SecurityMiddlewareTest extends \PHPUnit_Framework_TestCase { public function testAfterExceptionReturnsRedirect(){ - $api = $this->getMock('OC\AppFramework\DependencyInjection\DIContainer', array(), array('test')); + $api = $this->getMockBuilder( + 'OC\AppFramework\DependencyInjection\DIContainer') + ->disableOriginalConstructor() + ->getMock(); + $serverMock = $this->getMock('\OC\Server', array('getNavigationManager')); $api->expects($this->once())->method('getServer') ->will($this->returnValue($serverMock)); @@ -309,7 +316,7 @@ class SecurityMiddlewareTest extends \PHPUnit_Framework_TestCase { array('server' => array('HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'))); $this->middleware = new SecurityMiddleware($api, $this->request); $response = $this->middleware->afterException($this->controller, 'test', - $this->secException); + $this->secException); $this->assertTrue($response instanceof RedirectResponse); } diff --git a/tests/phpunit-autotest.xml b/tests/phpunit-autotest.xml index a893e96ad97..766f2b7ba10 100644 --- a/tests/phpunit-autotest.xml +++ b/tests/phpunit-autotest.xml @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="utf-8" ?> <phpunit bootstrap="bootstrap.php" - strict="true" verbose="true" timeoutForSmallTests="900" timeoutForMediumTests="900" |