diff --git a/settings/Controller/CheckSetupController.php b/settings/Controller/CheckSetupController.php index 13e7e443621..19d0e01a687 100644 --- a/settings/Controller/CheckSetupController.php +++ b/settings/Controller/CheckSetupController.php @@ -233,6 +233,19 @@ class CheckSetupController extends Controller { return ''; } + /** + * Whether the version is outdated + * + * @return bool + */ + protected function isPhpOutdated() { + if (version_compare(PHP_VERSION, '5.5.0') === -1) { + return true; + } + + return false; + } + /** * Whether the php version is still supported (at time of release) * according to: https://secure.php.net/supported-versions.php @@ -240,14 +253,7 @@ class CheckSetupController extends Controller { * @return array */ private function isPhpSupported() { - $eol = false; - - //PHP 5.4 is EOL on 14 Sep 2015 - if (version_compare(PHP_VERSION, '5.5.0') === -1) { - $eol = true; - } - - return ['eol' => $eol, 'version' => PHP_VERSION]; + return ['eol' => $this->isPhpOutdated(), 'version' => PHP_VERSION]; } /** diff --git a/tests/Core/Controller/AvatarControllerTest.php b/tests/Core/Controller/AvatarControllerTest.php index 937d8aaf17b..d45d0618230 100644 --- a/tests/Core/Controller/AvatarControllerTest.php +++ b/tests/Core/Controller/AvatarControllerTest.php @@ -19,6 +19,16 @@ * */ +namespace OC\Core\Controller; + +/** + * Overwrite is_uploaded_file in the OC\Core\Controller namespace to allow + * proper unit testing of the postAvatar call. + */ +function is_uploaded_file($filename) { + return file_exists($filename); +} + namespace Tests\Core\Controller; use OC\Core\Application; @@ -31,14 +41,6 @@ use OCP\IAvatar; use Punic\Exception; use Test\Traits\UserTrait; -/** - * Overwrite is_uploaded_file in this namespace to allow proper unit testing of - * the postAvatar call. - */ -function is_uploaded_file($filename) { - return file_exists($filename); -} - /** * Class AvatarControllerTest * @@ -68,19 +70,19 @@ class AvatarControllerTest extends \Test\TestCase { $app = new Application; $this->container = $app->getContainer(); $this->container['AppName'] = 'core'; - $this->container['AvatarManager'] = $this->getMock('OCP\IAvatarManager'); + $this->container['AvatarManager'] = $this->getMockBuilder('OCP\IAvatarManager')->getMock(); $this->container['Cache'] = $this->getMockBuilder('OC\Cache\File') ->disableOriginalConstructor()->getMock(); - $this->container['L10N'] = $this->getMock('OCP\IL10N'); + $this->container['L10N'] = $this->getMockBuilder('OCP\IL10N')->getMock(); $this->container['L10N']->method('t')->will($this->returnArgument(0)); - $this->container['UserManager'] = $this->getMock('OCP\IUserManager'); - $this->container['UserSession'] = $this->getMock('OCP\IUserSession'); - $this->container['Request'] = $this->getMock('OCP\IRequest'); - $this->container['UserFolder'] = $this->getMock('OCP\Files\Folder'); - $this->container['Logger'] = $this->getMock('OCP\ILogger'); + $this->container['UserManager'] = $this->getMockBuilder('OCP\IUserManager')->getMock(); + $this->container['UserSession'] = $this->getMockBuilder('OCP\IUserSession')->getMock(); + $this->container['Request'] = $this->getMockBuilder('OCP\IRequest')->getMock(); + $this->container['UserFolder'] = $this->getMockBuilder('OCP\Files\Folder')->getMock(); + $this->container['Logger'] = $this->getMockBuilder('OCP\ILogger')->getMock(); - $this->avatarMock = $this->getMock('OCP\IAvatar'); - $this->userMock = $this->getMock('OCP\IUser'); + $this->avatarMock = $this->getMockBuilder('OCP\IAvatar')->getMock(); + $this->userMock = $this->getMockBuilder('OCP\IUser')->getMock(); $this->avatarController = $this->container['AvatarController']; @@ -91,7 +93,7 @@ class AvatarControllerTest extends \Test\TestCase { ->willReturnMap([['userId', $this->userMock]]); $this->container['UserSession']->method('getUser')->willReturn($this->userMock); - $this->avatarFile = $this->getMock('OCP\Files\File'); + $this->avatarFile = $this->getMockBuilder('OCP\Files\File')->getMock(); $this->avatarFile->method('getContent')->willReturn('image data'); $this->avatarFile->method('getMimeType')->willReturn('image type'); $this->avatarFile->method('getEtag')->willReturn('my etag'); @@ -326,7 +328,7 @@ class AvatarControllerTest extends \Test\TestCase { * Test posting avatar from existing folder */ public function testPostAvatarFromNoFile() { - $file = $this->getMock('OCP\Files\Node'); + $file = $this->getMockBuilder('OCP\Files\Node')->getMock(); $this->container['UserFolder'] ->method('get') ->with('folder') diff --git a/tests/Core/Controller/LoginControllerTest.php b/tests/Core/Controller/LoginControllerTest.php index a322289d200..8eaa7c9843b 100644 --- a/tests/Core/Controller/LoginControllerTest.php +++ b/tests/Core/Controller/LoginControllerTest.php @@ -57,14 +57,14 @@ class LoginControllerTest extends TestCase { public function setUp() { parent::setUp(); - $this->request = $this->createMock('\\OCP\\IRequest'); - $this->userManager = $this->createMock('\\OCP\\IUserManager'); - $this->config = $this->createMock('\\OCP\\IConfig'); - $this->session = $this->createMock('\\OCP\\ISession'); + $this->request = $this->getMockBuilder('\\OCP\\IRequest')->getMock(); + $this->userManager = $this->getMockBuilder('\\OCP\\IUserManager')->getMock(); + $this->config = $this->getMockBuilder('\\OCP\\IConfig')->getMock(); + $this->session = $this->getMockBuilder('\\OCP\\ISession')->getMock(); $this->userSession = $this->getMockBuilder('\\OC\\User\\Session') ->disableOriginalConstructor() ->getMock(); - $this->urlGenerator = $this->createMock('\\OCP\\IURLGenerator'); + $this->urlGenerator = $this->getMockBuilder('\\OCP\\IURLGenerator')->getMock(); $this->twoFactorManager = $this->getMockBuilder('\OC\Authentication\TwoFactorAuth\Manager') ->disableOriginalConstructor() ->getMock(); @@ -110,7 +110,7 @@ class LoginControllerTest extends TestCase { ->method('getCookie') ->with('oc_token') ->willReturn('MyLoginToken'); - $user = $this->createMock('\\OCP\\IUser'); + $user = $this->getMockBuilder('\\OCP\\IUser')->getMock(); $user ->expects($this->once()) ->method('getUID') @@ -181,6 +181,7 @@ class LoginControllerTest extends TestCase { 'alt_login' => [], 'rememberLoginAllowed' => \OC_Util::rememberLoginAllowed(), 'rememberLoginState' => 0, + 'resetPasswordLink' => null, ], 'guest' ); @@ -217,7 +218,7 @@ class LoginControllerTest extends TestCase { ->method('getSystemValue') ->with('lost_password_link') ->willReturn(false); - $user = $this->createMock('\\OCP\\IUser'); + $user = $this->getMockBuilder('\\OCP\\IUser')->getMock(); $user ->expects($this->once()) ->method('canChangePassword') @@ -239,6 +240,7 @@ class LoginControllerTest extends TestCase { 'alt_login' => [], 'rememberLoginAllowed' => \OC_Util::rememberLoginAllowed(), 'rememberLoginState' => 0, + 'resetPasswordLink' => false, ], 'guest' ); @@ -255,7 +257,7 @@ class LoginControllerTest extends TestCase { ->method('getSystemValue') ->with('lost_password_link') ->willReturn(false); - $user = $this->createMock('\\OCP\\IUser'); + $user = $this->getMockBuilder('\\OCP\\IUser')->getMock(); $user ->expects($this->once()) ->method('canChangePassword') @@ -277,6 +279,7 @@ class LoginControllerTest extends TestCase { 'alt_login' => [], 'rememberLoginAllowed' => \OC_Util::rememberLoginAllowed(), 'rememberLoginState' => 0, + 'resetPasswordLink' => false, ], 'guest' ); @@ -326,9 +329,9 @@ class LoginControllerTest extends TestCase { public function testLoginWithValidCredentials() { /** @var IUser | \PHPUnit_Framework_MockObject_MockObject $user */ - $user = $this->createMock('\OCP\IUser'); + $user = $this->getMockBuilder('\OCP\IUser')->getMock(); $password = 'secret'; - $indexPageUrl = 'some url'; + $indexPageUrl = \OC_Util::getDefaultPageUrl(); $this->request ->expects($this->exactly(2)) @@ -360,10 +363,6 @@ class LoginControllerTest extends TestCase { ->method('isTwoFactorAuthenticated') ->with($user) ->will($this->returnValue(false)); - $this->urlGenerator->expects($this->once()) - ->method('linkToRoute') - ->with('files.view.index') - ->will($this->returnValue($indexPageUrl)); $expected = new \OCP\AppFramework\Http\RedirectResponse($indexPageUrl); $this->assertEquals($expected, $this->loginController->tryLogin($user, $password, null)); @@ -371,7 +370,7 @@ class LoginControllerTest extends TestCase { public function testLoginWithoutPassedCsrfCheckAndNotLoggedIn() { /** @var IUser | \PHPUnit_Framework_MockObject_MockObject $user */ - $user = $this->createMock('\OCP\IUser'); + $user = $this->getMockBuilder('\OCP\IUser')->getMock(); $user->expects($this->any()) ->method('getUID') ->will($this->returnValue('jane')); @@ -406,7 +405,7 @@ class LoginControllerTest extends TestCase { public function testLoginWithoutPassedCsrfCheckAndLoggedIn() { /** @var IUser | \PHPUnit_Framework_MockObject_MockObject $user */ - $user = $this->createMock('\OCP\IUser'); + $user = $this->getMockBuilder('\OCP\IUser')->getMock(); $user->expects($this->any()) ->method('getUID') ->will($this->returnValue('jane')); @@ -446,7 +445,7 @@ class LoginControllerTest extends TestCase { public function testLoginWithValidCredentialsAndRedirectUrl() { /** @var IUser | \PHPUnit_Framework_MockObject_MockObject $user */ - $user = $this->createMock('\OCP\IUser'); + $user = $this->getMockBuilder('\OCP\IUser')->getMock(); $user->expects($this->any()) ->method('getUID') ->will($this->returnValue('jane')); @@ -493,7 +492,7 @@ class LoginControllerTest extends TestCase { public function testLoginWithTwoFactorEnforced() { /** @var IUser | \PHPUnit_Framework_MockObject_MockObject $user */ - $user = $this->createMock('\OCP\IUser'); + $user = $this->getMockBuilder('\OCP\IUser')->getMock(); $user->expects($this->any()) ->method('getUID') ->will($this->returnValue('john')); @@ -544,7 +543,7 @@ class LoginControllerTest extends TestCase { public function testToNotLeakLoginName() { /** @var IUser | \PHPUnit_Framework_MockObject_MockObject $user */ - $user = $this->createMock('\OCP\IUser'); + $user = $this->getMockBuilder('\OCP\IUser')->getMock(); $user->expects($this->any()) ->method('getUID') ->will($this->returnValue('john')); diff --git a/tests/Core/Templates/TemplatesTest.php b/tests/Core/Templates/TemplatesTest.php index 03565411a13..cd1502fd22c 100644 --- a/tests/Core/Templates/TemplatesTest.php +++ b/tests/Core/Templates/TemplatesTest.php @@ -13,7 +13,7 @@ class TemplatesTest extends \Test\TestCase { public function test404() { $template = \OC::$SERVERROOT . '/core/templates/404.php'; $href = \OC::$server->getURLGenerator()->linkTo('', 'index.php'); - $expectedHtml = "
The specified document has not been found on the server.
\n\n\t\tThe specified document has not been found on the server.
\n\n\t\t