diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php
index f351412c95895985679b6e4b0c6911b6b394cfe9..aaeceff0997b260ac15cb52417cd33e12883cbc2 100644
--- a/tests/lib/Share20/ManagerTest.php
+++ b/tests/lib/Share20/ManagerTest.php
@@ -855,6 +855,9 @@ class ManagerTest extends \Test\TestCase {
 	}
 
 	public function testValidateExpirationDateEnforceTooFarIntoFuture() {
+		$this->expectException(\OCP\Share\Exceptions\GenericShareException::class);
+		$this->expectExceptionMessage('Can’t set expiration date more than 3 days in the future');
+
 		$future = new \DateTime();
 		$future->add(new \DateInterval('P7D'));
 
@@ -865,16 +868,10 @@ class ManagerTest extends \Test\TestCase {
 			->willReturnMap([
 				['core', 'shareapi_enforce_expire_date', 'no', 'yes'],
 				['core', 'shareapi_expire_after_n_days', '7', '3'],
+				['core', 'shareapi_default_expire_date', 'no', 'yes'],
 			]);
 
-		try {
-			self::invokePrivate($this->manager, 'validateExpirationDate', [$share]);
-			$this->addToAssertionCount(1);
-		} catch (\OCP\Share\Exceptions\GenericShareException $e) {
-			$this->assertEquals('Cannot set expiration date more than 3 days in the future', $e->getMessage());
-			$this->assertEquals('Cannot set expiration date more than 3 days in the future', $e->getHint());
-			$this->assertEquals(404, $e->getCode());
-		}
+		self::invokePrivate($this->manager, 'validateExpirationDate', [$share]);
 	}
 
 	public function testValidateExpirationDateEnforceValid() {