summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/dav/tests/unit/AppInfo/PluginManagerTest.php4
-rw-r--r--apps/dav/tests/unit/CalDAV/CalDavBackendTest.php3
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php3
-rw-r--r--apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php4
-rw-r--r--apps/theming/tests/IconBuilderTest.php13
-rw-r--r--apps/twofactor_backupcodes/tests/Unit/Activity/ProviderTest.php2
-rw-r--r--tests/Settings/Activity/SecurityProviderTest.php2
-rw-r--r--tests/lib/AppFramework/Db/EntityTest.php17
-rw-r--r--tests/lib/AppFramework/Db/MapperTest.php16
-rw-r--r--tests/lib/AppFramework/Http/DispatcherTest.php2
-rw-r--r--tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php6
-rw-r--r--tests/lib/AppFramework/Middleware/MiddlewareTest.php4
-rw-r--r--tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php4
-rw-r--r--tests/lib/Encryption/DecryptAllTest.php1
-rw-r--r--tests/lib/Files/Storage/Wrapper/EncryptionTest.php16
-rw-r--r--tests/lib/L10N/FactoryTest.php2
-rw-r--r--tests/lib/Notification/NotificationTest.php4
-rw-r--r--tests/lib/Template/CSSResourceLocatorTest.php3
-rw-r--r--tests/lib/User/ManagerTest.php2
19 files changed, 50 insertions, 58 deletions
diff --git a/apps/dav/tests/unit/AppInfo/PluginManagerTest.php b/apps/dav/tests/unit/AppInfo/PluginManagerTest.php
index 89c972acd26..a4fcef92511 100644
--- a/apps/dav/tests/unit/AppInfo/PluginManagerTest.php
+++ b/apps/dav/tests/unit/AppInfo/PluginManagerTest.php
@@ -22,8 +22,8 @@
namespace OCA\DAV\Tests\unit\AppInfo;
+use OC\App\AppManager;
use Test\TestCase;
-use OCP\App\IAppManager;
use OC\ServerContainer;
use OCA\DAV\AppInfo\PluginManager;
@@ -37,7 +37,7 @@ class PluginManagerTest extends TestCase {
$server = $this->createMock(ServerContainer::class);
- $appManager = $this->createMock(IAppManager::class);
+ $appManager = $this->createMock(AppManager::class);
$appManager->method('getInstalledApps')
->willReturn(['adavapp', 'adavapp2']);
diff --git a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php
index 0b8978a0409..fd048240467 100644
--- a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php
+++ b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php
@@ -36,6 +36,7 @@ use OCP\IL10N;
use Sabre\DAV\PropPatch;
use Sabre\DAV\Xml\Property\Href;
use Sabre\DAVACL\IACL;
+use Sabre\DAV\Exception\NotFound;
/**
* Class CalDavBackendTest
@@ -526,7 +527,7 @@ EOD;
$calendar->setPublishStatus(false);
$this->assertEquals(false, $calendar->getPublishStatus());
- $this->setExpectedException('Sabre\DAV\Exception\NotFound');
+ $this->expectException(NotFound::class);
$this->backend->getPublicCalendar($publicCalendarURI);
}
diff --git a/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php
index 800bdfd3598..e1c4bc05dc1 100644
--- a/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php
@@ -29,6 +29,7 @@
namespace OCA\DAV\Tests\unit\Connector\Sabre;
use OC\User\User;
+use OCA\DAV\Connector\Sabre\Directory;
use OCA\DAV\Connector\Sabre\File;
use OCA\DAV\Connector\Sabre\FilesPlugin;
use OCA\DAV\Connector\Sabre\Node;
@@ -319,7 +320,7 @@ class FilesPluginTest extends TestCase {
}
public function testGetPropertiesForRootDirectory() {
- /** @var \OCA\DAV\Connector\Sabre\Directory | \PHPUnit_Framework_MockObject_MockObject $node */
+ /** @var \OCA\DAV\Connector\Sabre\Directory|\PHPUnit_Framework_MockObject_MockObject $node */
$node = $this->getMockBuilder(Directory::class)
->disableOriginalConstructor()
->getMock();
diff --git a/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php b/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php
index 18c774883c0..b9a6efdcc22 100644
--- a/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php
+++ b/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php
@@ -251,7 +251,7 @@ class SystemTagNodeTest extends \Test\TestCase {
->method('deleteTags')
->with('1');
if (!$isAdmin) {
- $this->setExpectedException(Forbidden::class);
+ $this->expectException(Forbidden::class);
}
$this->getTagNode($isAdmin, $tag)->delete();
}
@@ -282,7 +282,7 @@ class SystemTagNodeTest extends \Test\TestCase {
$this->tagManager->expects($this->never())
->method('deleteTags');
- $this->setExpectedException($expectedException);
+ $this->expectException($expectedException);
$this->getTagNode(false, $tag)->delete();
}
diff --git a/apps/theming/tests/IconBuilderTest.php b/apps/theming/tests/IconBuilderTest.php
index 4f5078d4c56..a2a330a2f24 100644
--- a/apps/theming/tests/IconBuilderTest.php
+++ b/apps/theming/tests/IconBuilderTest.php
@@ -34,6 +34,7 @@ use OCP\Files\IAppData;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use OCP\IConfig;
+use PHPUnit\Framework\Error\Warning;
use Test\TestCase;
class IconBuilderTest extends TestCase {
@@ -172,11 +173,9 @@ class IconBuilderTest extends TestCase {
// cloud be something like $expectedIcon->compareImages($icon, Imagick::METRIC_MEANABSOLUTEERROR)[1])
}
- /**
- * @expectedException \PHPUnit_Framework_Error_Warning
- */
public function testGetFaviconNotFound() {
$this->checkImagick();
+ $this->expectException(Warning::class);
$util = $this->getMockBuilder(Util::class)->disableOriginalConstructor()->getMock();
$iconBuilder = new IconBuilder($this->themingDefaults, $util);
$this->themingDefaults->expects($this->once())
@@ -188,11 +187,9 @@ class IconBuilderTest extends TestCase {
$this->assertFalse($iconBuilder->getFavicon('noapp'));
}
- /**
- * @expectedException \PHPUnit_Framework_Error_Warning
- */
public function testGetTouchIconNotFound() {
$this->checkImagick();
+ $this->expectException(Warning::class);
$util = $this->getMockBuilder(Util::class)->disableOriginalConstructor()->getMock();
$iconBuilder = new IconBuilder($this->themingDefaults, $util);
$util->expects($this->once())
@@ -201,11 +198,9 @@ class IconBuilderTest extends TestCase {
$this->assertFalse($iconBuilder->getTouchIcon('noapp'));
}
- /**
- * @expectedException \PHPUnit_Framework_Error_Warning
- */
public function testColorSvgNotFound() {
$this->checkImagick();
+ $this->expectException(Warning::class);
$util = $this->getMockBuilder(Util::class)->disableOriginalConstructor()->getMock();
$iconBuilder = new IconBuilder($this->themingDefaults, $util);
$util->expects($this->once())
diff --git a/apps/twofactor_backupcodes/tests/Unit/Activity/ProviderTest.php b/apps/twofactor_backupcodes/tests/Unit/Activity/ProviderTest.php
index a56098556e5..17d332691d2 100644
--- a/apps/twofactor_backupcodes/tests/Unit/Activity/ProviderTest.php
+++ b/apps/twofactor_backupcodes/tests/Unit/Activity/ProviderTest.php
@@ -62,7 +62,7 @@ class ProviderTest extends TestCase {
$event->expects($this->once())
->method('getApp')
->willReturn('comments');
- $this->setExpectedException(InvalidArgumentException::class);
+ $this->expectException(InvalidArgumentException::class);
$this->provider->parse($lang, $event);
}
diff --git a/tests/Settings/Activity/SecurityProviderTest.php b/tests/Settings/Activity/SecurityProviderTest.php
index 552548984d7..0623779735b 100644
--- a/tests/Settings/Activity/SecurityProviderTest.php
+++ b/tests/Settings/Activity/SecurityProviderTest.php
@@ -62,7 +62,7 @@ class SecurityProviderTest extends TestCase {
$event->expects($this->once())
->method('getType')
->willReturn('comments');
- $this->setExpectedException(InvalidArgumentException::class);
+ $this->expectException(InvalidArgumentException::class);
$this->provider->parse($lang, $event);
}
diff --git a/tests/lib/AppFramework/Db/EntityTest.php b/tests/lib/AppFramework/Db/EntityTest.php
index e1a3d7533be..c9a90da7c59 100644
--- a/tests/lib/AppFramework/Db/EntityTest.php
+++ b/tests/lib/AppFramework/Db/EntityTest.php
@@ -46,7 +46,7 @@ class TestEntity extends Entity {
protected $preName;
public function __construct($name=null){
- $this->addType('testId', 'integer');
+ $this->addType('testId', 'integer');
$this->name = $name;
}
};
@@ -119,23 +119,26 @@ class EntityTest extends \Test\TestCase {
}
+ /**
+ * @expectedException \BadFunctionCallException
+ */
public function testCallShouldOnlyWorkForGetterSetter(){
- $this->setExpectedException('\BadFunctionCallException');
-
$this->entity->something();
}
+ /**
+ * @expectedException \BadFunctionCallException
+ */
public function testGetterShouldFailIfAttributeNotDefined(){
- $this->setExpectedException('\BadFunctionCallException');
-
$this->entity->getTest();
}
+ /**
+ * @expectedException \BadFunctionCallException
+ */
public function testSetterShouldFailIfAttributeNotDefined(){
- $this->setExpectedException('\BadFunctionCallException');
-
$this->entity->setTest();
}
diff --git a/tests/lib/AppFramework/Db/MapperTest.php b/tests/lib/AppFramework/Db/MapperTest.php
index 108e4eee28e..990391a1de1 100644
--- a/tests/lib/AppFramework/Db/MapperTest.php
+++ b/tests/lib/AppFramework/Db/MapperTest.php
@@ -24,6 +24,8 @@
namespace Test\AppFramework\Db;
+use OCP\AppFramework\Db\DoesNotExistException;
+use OCP\AppFramework\Db\MultipleObjectsReturnedException;
use \OCP\IDBConnection;
use \OCP\AppFramework\Db\Entity;
use \OCP\AppFramework\Db\Mapper;
@@ -95,8 +97,7 @@ class MapperTest extends MapperTestUtility {
$params = array('jo');
$rows = array();
$this->setMapperResult($sql, $params, $rows);
- $this->setExpectedException(
- '\OCP\AppFramework\Db\DoesNotExistException');
+ $this->expectException(DoesNotExistException::class);
$this->mapper->find($sql, $params);
}
@@ -105,8 +106,7 @@ class MapperTest extends MapperTestUtility {
$params = array('jo');
$rows = array();
$this->setMapperResult($sql, $params, $rows, null, null, true);
- $this->setExpectedException(
- '\OCP\AppFramework\Db\DoesNotExistException');
+ $this->expectException(DoesNotExistException::class);
$this->mapper->findOneEntity($sql, $params);
}
@@ -117,8 +117,7 @@ class MapperTest extends MapperTestUtility {
array('jo'), array('ho')
);
$this->setMapperResult($sql, $params, $rows, null, null, true);
- $this->setExpectedException(
- '\OCP\AppFramework\Db\MultipleObjectsReturnedException');
+ $this->expectException(MultipleObjectsReturnedException::class);
$this->mapper->find($sql, $params);
}
@@ -129,8 +128,7 @@ class MapperTest extends MapperTestUtility {
array('jo'), array('ho')
);
$this->setMapperResult($sql, $params, $rows, null, null, true);
- $this->setExpectedException(
- '\OCP\AppFramework\Db\MultipleObjectsReturnedException');
+ $this->expectException(MultipleObjectsReturnedException::class);
$this->mapper->findOneEntity($sql, $params);
}
@@ -223,7 +221,7 @@ class MapperTest extends MapperTestUtility {
$entity->setPreName($params[0]);
$entity->setEmail($params[1]);
- $this->setExpectedException('InvalidArgumentException');
+ $this->expectException(\InvalidArgumentException::class);
$this->mapper->update($entity);
}
diff --git a/tests/lib/AppFramework/Http/DispatcherTest.php b/tests/lib/AppFramework/Http/DispatcherTest.php
index eb08d00e358..95fa3c2a047 100644
--- a/tests/lib/AppFramework/Http/DispatcherTest.php
+++ b/tests/lib/AppFramework/Http/DispatcherTest.php
@@ -267,7 +267,7 @@ class DispatcherTest extends \Test\TestCase {
$responseHeaders = array('hell' => 'yeah');
$this->setMiddlewareExpectations($out, $httpHeaders, $responseHeaders, true, false);
- $this->setExpectedException('\Exception');
+ $this->expectException(\Exception::class);
$response = $this->dispatcher->dispatch($this->controller,
$this->controllerMethod);
diff --git a/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php b/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php
index e71be9c5f16..b2f78c17fe6 100644
--- a/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php
+++ b/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php
@@ -177,7 +177,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase {
$this->dispatcher->registerMiddleware($m1);
$this->dispatcher->registerMiddleware($m2);
- $this->setExpectedException('\Exception');
+ $this->expectException(\Exception::class);
$this->dispatcher->beforeController($this->controller, $this->method);
$this->dispatcher->afterException($this->controller, $this->method, $this->exception);
}
@@ -206,7 +206,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase {
public function testAfterExceptionCorrectArguments(){
$m1 = $this->getMiddleware();
- $this->setExpectedException('\Exception');
+ $this->expectException(\Exception::class);
$this->dispatcher->beforeController($this->controller, $this->method);
$this->dispatcher->afterException($this->controller, $this->method, $this->exception);
@@ -253,7 +253,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase {
$m1 = $this->getMiddleware();
$m2 = $this->getMiddleware();
- $this->setExpectedException('\Exception');
+ $this->expectException(\Exception::class);
$this->dispatcher->beforeController($this->controller, $this->method);
$this->dispatcher->afterException($this->controller, $this->method, $this->exception);
diff --git a/tests/lib/AppFramework/Middleware/MiddlewareTest.php b/tests/lib/AppFramework/Middleware/MiddlewareTest.php
index 07028745676..038bec25148 100644
--- a/tests/lib/AppFramework/Middleware/MiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/MiddlewareTest.php
@@ -75,8 +75,8 @@ class MiddlewareTest extends \Test\TestCase {
public function testAfterExceptionRaiseAgainWhenUnhandled() {
- $this->setExpectedException('Exception');
- $afterEx = $this->middleware->afterException($this->controller, null, $this->exception);
+ $this->expectException(\Exception::class);
+ $this->middleware->afterException($this->controller, null, $this->exception);
}
diff --git a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php
index 0d7418673dd..274a2810cba 100644
--- a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php
@@ -263,7 +263,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
$sec = $this->getMiddleware($isLoggedIn, $isAdminUser);
if($shouldFail) {
- $this->setExpectedException('\OC\AppFramework\Middleware\Security\Exceptions\SecurityException');
+ $this->expectException(SecurityException::class);
} else {
$this->assertTrue(true);
}
@@ -454,7 +454,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
public function testAfterExceptionNotCaughtThrowsItAgain(){
$ex = new \Exception();
- $this->setExpectedException('\Exception');
+ $this->expectException(\Exception::class);
$this->middleware->afterException($this->controller, 'test', $ex);
}
diff --git a/tests/lib/Encryption/DecryptAllTest.php b/tests/lib/Encryption/DecryptAllTest.php
index 06c5e0e2df8..c2b7bd17149 100644
--- a/tests/lib/Encryption/DecryptAllTest.php
+++ b/tests/lib/Encryption/DecryptAllTest.php
@@ -34,6 +34,7 @@ use OCP\UserInterface;
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\ConsoleOutputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase;
diff --git a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
index c184752ff7e..5bcff56e373 100644
--- a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
+++ b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
@@ -719,9 +719,7 @@ class EncryptionTest extends Storage {
}
public function testCopyBetweenStorageMinimumEncryptedVersion() {
- $storage2 = $this->getMockBuilder(Storage::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $storage2 = $this->createMock(\OC\Files\Storage\Storage::class);
$sourceInternalPath = $targetInternalPath = 'file.txt';
$preserveMtime = $isRename = false;
@@ -768,9 +766,7 @@ class EncryptionTest extends Storage {
* @param bool $expectedEncrypted
*/
public function testCopyBetweenStorage($encryptionEnabled, $mountPointEncryptionEnabled, $expectedEncrypted) {
- $storage2 = $this->getMockBuilder(Storage::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $storage2 = $this->createMock(\OC\Files\Storage\Storage::class);
$sourceInternalPath = $targetInternalPath = 'file.txt';
$preserveMtime = $isRename = false;
@@ -830,13 +826,9 @@ class EncryptionTest extends Storage {
*/
public function testCopyBetweenStorageVersions($sourceInternalPath, $targetInternalPath, $copyResult, $encrypted) {
- $sourceStorage = $this->getMockBuilder(Storage::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $sourceStorage = $this->createMock(\OC\Files\Storage\Storage::class);
- $targetStorage = $this->getMockBuilder(Storage::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $targetStorage = $this->createMock(\OC\Files\Storage\Storage::class);
$cache = $this->getMockBuilder('\OC\Files\Cache\Cache')
->disableOriginalConstructor()->getMock();
diff --git a/tests/lib/L10N/FactoryTest.php b/tests/lib/L10N/FactoryTest.php
index 4f31784337a..1e5c2ef5421 100644
--- a/tests/lib/L10N/FactoryTest.php
+++ b/tests/lib/L10N/FactoryTest.php
@@ -392,7 +392,7 @@ class FactoryTest extends TestCase {
->willReturn($header);
if ($expected instanceof LanguageNotFoundException) {
- $this->setExpectedException(LanguageNotFoundException::class);
+ $this->expectException(LanguageNotFoundException::class);
self::invokePrivate($factory, 'getLanguageFromRequest', [$app]);
} else {
$this->assertSame($expected, self::invokePrivate($factory, 'getLanguageFromRequest', [$app]), 'Asserting returned language');
diff --git a/tests/lib/Notification/NotificationTest.php b/tests/lib/Notification/NotificationTest.php
index eabed273608..5aa24fc762a 100644
--- a/tests/lib/Notification/NotificationTest.php
+++ b/tests/lib/Notification/NotificationTest.php
@@ -466,7 +466,7 @@ class NotificationTest extends TestCase {
$this->assertSame($this->notification, $this->notification->addAction($action));
- $this->setExpectedException('\InvalidArgumentException');
+ $this->expectException(\InvalidArgumentException::class);
$this->notification->addAction($action);
}
@@ -512,7 +512,7 @@ class NotificationTest extends TestCase {
$this->assertSame($this->notification, $this->notification->addParsedAction($action));
- $this->setExpectedException('\InvalidArgumentException');
+ $this->expectException(\InvalidArgumentException::class);
$this->notification->addParsedAction($action);
}
diff --git a/tests/lib/Template/CSSResourceLocatorTest.php b/tests/lib/Template/CSSResourceLocatorTest.php
index a16cc18cb0a..ef3ef4f42c8 100644
--- a/tests/lib/Template/CSSResourceLocatorTest.php
+++ b/tests/lib/Template/CSSResourceLocatorTest.php
@@ -24,6 +24,7 @@
namespace Test\Template;
use OC\Files\AppData\Factory;
+use OCP\Files\IAppData;
use OCP\ILogger;
use OCP\IURLGenerator;
use OCP\IConfig;
@@ -37,7 +38,7 @@ class CSSResourceLocatorTest extends \Test\TestCase {
protected $appData;
/** @var IURLGenerator|\PHPUnit_Framework_MockObject_MockObject */
protected $urlGenerator;
- /** @var SystemConfig|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
protected $config;
/** @var ThemingDefaults|\PHPUnit_Framework_MockObject_MockObject */
protected $themingDefaults;
diff --git a/tests/lib/User/ManagerTest.php b/tests/lib/User/ManagerTest.php
index f6a362a5031..2ecae3a8500 100644
--- a/tests/lib/User/ManagerTest.php
+++ b/tests/lib/User/ManagerTest.php
@@ -329,7 +329,7 @@ class ManagerTest extends TestCase {
$manager = new \OC\User\Manager($this->config);
$manager->registerBackend($backend);
- $this->setExpectedException(\InvalidArgumentException::class, $exception);
+ $this->expectException(\InvalidArgumentException::class, $exception);
$manager->createUser($uid, $password);
}