From c3424df1f026854ed8adbfdf8d96da7a6562a8dd Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 24 Jan 2018 17:23:59 +0100 Subject: [PATCH 1/6] Require PHPUnit 6.5 or higher Signed-off-by: Joas Schilling --- .../unit/CalDAV/Publishing/PublisherTest.php | 3 +- apps/dav/tests/unit/bootstrap.php | 4 -- autotest.sh | 6 +-- tests/bootstrap.php | 4 -- tests/lib/Contacts/ContactsMenu/EntryTest.php | 3 +- tests/lib/TestCase.php | 24 ++--------- tests/startsessionlistener.php | 40 +++++-------------- 7 files changed, 19 insertions(+), 65 deletions(-) diff --git a/apps/dav/tests/unit/CalDAV/Publishing/PublisherTest.php b/apps/dav/tests/unit/CalDAV/Publishing/PublisherTest.php index b2ba8ba119..36aa4fa449 100644 --- a/apps/dav/tests/unit/CalDAV/Publishing/PublisherTest.php +++ b/apps/dav/tests/unit/CalDAV/Publishing/PublisherTest.php @@ -25,8 +25,9 @@ namespace OCA\DAV\Tests\unit\CalDAV\Publishing; use OCA\DAV\CalDAV\Publishing\Xml\Publisher; use Sabre\Xml\Writer; +use Test\TestCase; -class PublisherTest extends \PHPUnit_Framework_TestCase { +class PublisherTest extends TestCase { const NS_CALENDARSERVER = 'http://calendarserver.org/ns/'; diff --git a/apps/dav/tests/unit/bootstrap.php b/apps/dav/tests/unit/bootstrap.php index 178bc695b6..a2ad505342 100644 --- a/apps/dav/tests/unit/bootstrap.php +++ b/apps/dav/tests/unit/bootstrap.php @@ -26,10 +26,6 @@ if (!defined('PHPUNIT_RUN')) { require_once __DIR__.'/../../../../lib/base.php'; -if(!class_exists('PHPUnit_Framework_TestCase')) { - require_once('PHPUnit/Autoload.php'); -} - \OC::$composerAutoloader->addPsr4('Test\\', OC::$SERVERROOT . '/tests/lib/', true); \OC_App::loadApp('dav'); diff --git a/autotest.sh b/autotest.sh index da9661f067..7a91b07719 100755 --- a/autotest.sh +++ b/autotest.sh @@ -53,7 +53,7 @@ else fi if ! [ -x "$PHPUNIT" ]; then - echo "phpunit executable not found, please install phpunit version >= 4.8" >&2 + echo "phpunit executable not found, please install phpunit version >= 6.5" >&2 exit 3 fi @@ -68,8 +68,8 @@ PHPUNIT_VERSION=$($PHPUNIT --version | cut -d" " -f2) PHPUNIT_MAJOR_VERSION=$(echo "$PHPUNIT_VERSION" | cut -d"." -f1) PHPUNIT_MINOR_VERSION=$(echo "$PHPUNIT_VERSION" | cut -d"." -f2) -if ! [ "$PHPUNIT_MAJOR_VERSION" -gt 4 -o \( "$PHPUNIT_MAJOR_VERSION" -eq 4 -a "$PHPUNIT_MINOR_VERSION" -ge 8 \) ]; then - echo "phpunit version >= 4.8 required. Version found: $PHPUNIT_VERSION" >&2 +if ! [ "$PHPUNIT_MAJOR_VERSION" -gt 6 -o \( "$PHPUNIT_MAJOR_VERSION" -eq 6 -a "$PHPUNIT_MINOR_VERSION" -ge 5 \) ]; then + echo "phpunit version >= 6.5 required. Version found: $PHPUNIT_VERSION" >&2 exit 4 fi diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 44c42d353e..a1bc26bbf0 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -14,10 +14,6 @@ require_once __DIR__ . '/../lib/base.php'; // load all enabled apps \OC_App::loadApps(); -if (!class_exists('PHPUnit_Framework_TestCase')) { - require_once('PHPUnit/Autoload.php'); -} - OC_Hook::clear(); set_include_path(get_include_path() . PATH_SEPARATOR . '/usr/share/php'); diff --git a/tests/lib/Contacts/ContactsMenu/EntryTest.php b/tests/lib/Contacts/ContactsMenu/EntryTest.php index ddc6cc916d..d5141136a1 100644 --- a/tests/lib/Contacts/ContactsMenu/EntryTest.php +++ b/tests/lib/Contacts/ContactsMenu/EntryTest.php @@ -26,10 +26,9 @@ namespace Tests\Contacts\ContactsMenu; use OC\Contacts\ContactsMenu\Actions\LinkAction; use OC\Contacts\ContactsMenu\Entry; -use OCP\Contacts\ContactsMenu\IAction; use Test\TestCase; -class EntryTest extends \PHPUnit_Framework_TestCase { +class EntryTest extends TestCase { /** @var Entry */ private $entry; diff --git a/tests/lib/TestCase.php b/tests/lib/TestCase.php index 345b2a68e6..9207658051 100644 --- a/tests/lib/TestCase.php +++ b/tests/lib/TestCase.php @@ -33,7 +33,7 @@ use OCP\IDBConnection; use OCP\IL10N; use OCP\Security\ISecureRandom; -abstract class TestCase extends \PHPUnit_Framework_TestCase { +abstract class TestCase extends \PHPUnit\Framework\TestCase { /** @var \OC\Command\QueueBus */ private $commandBus; @@ -46,24 +46,6 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase { /** @var array */ protected $services = []; - /** - * Wrapper to be forward compatible to phpunit 5.4+ - * - * @param string $originalClassName - * @return \PHPUnit_Framework_MockObject_MockObject - */ - protected function createMock($originalClassName) { - if (is_callable('parent::createMock')) { - return parent::createMock($originalClassName); - } - - return $this->getMockBuilder($originalClassName) - ->disableOriginalConstructor() - ->disableOriginalClone() - ->disableArgumentCloning() - ->getMock(); - } - /** * @param string $name * @param mixed $newService @@ -152,7 +134,7 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase { } } - protected function onNotSuccessfulTest($e) { + protected function onNotSuccessfulTest(\Throwable $t) { $this->restoreAllServices(); // restore database connection @@ -162,7 +144,7 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase { }); } - parent::onNotSuccessfulTest($e); + parent::onNotSuccessfulTest($t); } protected function tearDown() { diff --git a/tests/startsessionlistener.php b/tests/startsessionlistener.php index 88544cc6ce..24a72db006 100644 --- a/tests/startsessionlistener.php +++ b/tests/startsessionlistener.php @@ -6,45 +6,25 @@ * See the COPYING-README file. */ +use OC\Session\Memory; +use PHPUnit\Framework\Test; +use PHPUnit\Framework\TestListener; +use PHPUnit\Framework\TestListenerDefaultImplementation; + /** * Starts a new session before each test execution */ -class StartSessionListener implements PHPUnit_Framework_TestListener { +class StartSessionListener implements TestListener { - public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) { - } + use TestListenerDefaultImplementation; - public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) { - } - - public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) { - } - - public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time) { - } - - public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) { - } - - public function startTest(PHPUnit_Framework_Test $test) { - } - - public function endTest(PHPUnit_Framework_Test $test, $time) { + public function endTest(Test $test, $time) { // reopen the session - only allowed for memory session - if (\OC::$server->getSession() instanceof \OC\Session\Memory) { - /** @var $session \OC\Session\Memory */ + if (\OC::$server->getSession() instanceof Memory) { + /** @var $session Memory */ $session = \OC::$server->getSession(); $session->reopen(); } } - public function startTestSuite(PHPUnit_Framework_TestSuite $suite) { - } - - public function endTestSuite(PHPUnit_Framework_TestSuite $suite) { - } - - public function addWarning(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_Warning $e, $time) { - } - } From 870023365c928e6bc3bd39d0d7f9b4d976dad33e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 24 Jan 2018 18:10:16 +0100 Subject: [PATCH 2/6] Fix "Undefined method setExpectedException()" Signed-off-by: Joas Schilling --- .../tests/unit/AppInfo/PluginManagerTest.php | 4 ++-- .../dav/tests/unit/CalDAV/CalDavBackendTest.php | 3 ++- .../unit/Connector/Sabre/FilesPluginTest.php | 3 ++- .../tests/unit/SystemTag/SystemTagNodeTest.php | 4 ++-- apps/theming/tests/IconBuilderTest.php | 13 ++++--------- .../tests/Unit/Activity/ProviderTest.php | 2 +- .../Settings/Activity/SecurityProviderTest.php | 2 +- tests/lib/AppFramework/Db/EntityTest.php | 17 ++++++++++------- tests/lib/AppFramework/Db/MapperTest.php | 16 +++++++--------- tests/lib/AppFramework/Http/DispatcherTest.php | 2 +- .../Middleware/MiddlewareDispatcherTest.php | 6 +++--- .../AppFramework/Middleware/MiddlewareTest.php | 4 ++-- .../Security/SecurityMiddlewareTest.php | 4 ++-- tests/lib/Encryption/DecryptAllTest.php | 1 + .../Files/Storage/Wrapper/EncryptionTest.php | 16 ++++------------ tests/lib/L10N/FactoryTest.php | 2 +- tests/lib/Notification/NotificationTest.php | 4 ++-- tests/lib/Template/CSSResourceLocatorTest.php | 3 ++- tests/lib/User/ManagerTest.php | 2 +- 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 89c972acd2..a4fcef9251 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 0b8978a040..fd04824046 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 800bdfd359..e1c4bc05dc 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 18c774883c..b9a6efdcc2 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 4f5078d4c5..a2a330a2f2 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 a56098556e..17d332691d 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 552548984d..0623779735 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 e1a3d7533b..c9a90da7c5 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 108e4eee28..990391a1de 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 eb08d00e35..95fa3c2a04 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 e71be9c5f1..b2f78c17fe 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 0702874567..038bec2514 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 0d7418673d..274a2810cb 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 06c5e0e2df..c2b7bd1714 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 c184752ff7..5bcff56e37 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 4f31784337..1e5c2ef542 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 eabed27360..5aa24fc762 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 a16cc18cb0..ef3ef4f42c 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 f6a362a503..2ecae3a850 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); } From 24af5c20bd65f8e657bcc495984234088c22e824 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Wed, 24 Jan 2018 20:35:28 +0100 Subject: [PATCH 3/6] Bump docker containers used Signed-off-by: Roeland Jago Douma --- .drone.yml | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/.drone.yml b/.drone.yml index 5f77c3981b..6bcb5d909a 100644 --- a/.drone.yml +++ b/.drone.yml @@ -15,14 +15,14 @@ pipeline: matrix: TESTS: jsunit checkers: - image: nextcloudci/php7.0:php7.0-16 + image: nextcloudci/php7.0:php7.0-19 commands: - ./autotest-checkers.sh when: matrix: TESTS: checkers syntax-php7.0: - image: nextcloudci/php7.0:php7.0-16 + image: nextcloudci/php7.0:php7.0-19 commands: - composer install - ./lib/composer/bin/parallel-lint --exclude lib/composer/jakub-onderka/ --exclude 3rdparty/symfony/polyfill-php70/Resources/stubs/ --exclude 3rdparty/patchwork/utf8/src/Patchwork/Utf8/Bootup/ --exclude 3rdparty/paragonie/random_compat/lib/ --exclude lib/composer/composer/autoload_static.php --exclude 3rdparty/composer/autoload_static.php . @@ -30,7 +30,7 @@ pipeline: matrix: TESTS: syntax-php7.0 syntax-php7.1: - image: nextcloudci/php7.1:php7.1-15 + image: nextcloudci/php7.1:php7.1-16 commands: - composer install - ./lib/composer/bin/parallel-lint --exclude lib/composer/jakub-onderka/ --exclude 3rdparty/symfony/polyfill-php70/Resources/stubs/ --exclude 3rdparty/patchwork/utf8/src/Patchwork/Utf8/Bootup/ --exclude 3rdparty/paragonie/random_compat/lib/ --exclude lib/composer/composer/autoload_static.php --exclude 3rdparty/composer/autoload_static.php . @@ -38,7 +38,7 @@ pipeline: matrix: TESTS: syntax-php7.1 phan: - image: nextcloudci/php7.1:php7.1-15 + image: nextcloudci/php7.1:php7.1-16 commands: - composer install - composer require --dev "phan/phan:dev-master" @@ -139,7 +139,7 @@ pipeline: matrix: TESTS: sqlite-php7.0-webdav-apache nodb-php7.0: - image: nextcloudci/php7.0:php7.0-16 + image: nextcloudci/php7.0:php7.0-19 commands: - NOCOVERAGE=true TEST_SELECTION=NODB ./autotest.sh sqlite when: @@ -147,7 +147,7 @@ pipeline: DB: NODB PHP: "7.0" nodb-php7.1: - image: nextcloudci/php7.1:php7.1-15 + image: nextcloudci/php7.1:php7.1-16 commands: - NOCOVERAGE=true TEST_SELECTION=NODB ./autotest.sh sqlite when: @@ -155,7 +155,7 @@ pipeline: DB: NODB PHP: 7.1 nodb-php7.2: - image: nextcloudci/php7.2:php7.2-9 + image: nextcloudci/php7.2:php7.2-10 commands: - NOCOVERAGE=true TEST_SELECTION=NODB ./autotest.sh sqlite when: @@ -163,7 +163,7 @@ pipeline: DB: NODB PHP: 7.2 sqlite-php7.0: - image: nextcloudci/php7.0:php7.0-16 + image: nextcloudci/php7.0:php7.0-19 commands: - NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh sqlite when: @@ -171,7 +171,7 @@ pipeline: DB: sqlite PHP: "7.0" sqlite-php7.1: - image: nextcloudci/php7.1:php7.1-15 + image: nextcloudci/php7.1:php7.1-16 commands: - NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh sqlite when: @@ -179,7 +179,7 @@ pipeline: DB: sqlite PHP: 7.1 sqlite-php7.2: - image: nextcloudci/php7.2:php7.2-9 + image: nextcloudci/php7.2:php7.2-10 commands: - NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh sqlite when: @@ -187,7 +187,7 @@ pipeline: DB: sqlite PHP: 7.2 mysql-php7.0: - image: nextcloudci/php7.0:php7.0-16 + image: nextcloudci/php7.0:php7.0-19 commands: - NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh mysql when: @@ -195,7 +195,7 @@ pipeline: DB: mysql PHP: "7.0" mysql-php7.1: - image: nextcloudci/php7.1:php7.1-15 + image: nextcloudci/php7.1:php7.1-16 commands: - NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh mysql when: @@ -203,7 +203,7 @@ pipeline: DB: mysql PHP: 7.1 mysql-php7.2: - image: nextcloudci/php7.2:php7.2-9 + image: nextcloudci/php7.2:php7.2-10 commands: - NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh mysql when: @@ -211,7 +211,7 @@ pipeline: DB: mysql PHP: 7.2 mysql5.6-php7.0: - image: nextcloudci/php7.0:php7.0-16 + image: nextcloudci/php7.0:php7.0-19 commands: - NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh mysql when: @@ -219,7 +219,7 @@ pipeline: DB: mysql5.6 PHP: "7.0" mysql5.6-php7.1: - image: nextcloudci/php7.1:php7.1-15 + image: nextcloudci/php7.1:php7.1-16 commands: - NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh mysql when: @@ -227,7 +227,7 @@ pipeline: DB: mysql5.6 PHP: 7.1 mysql5.5-php7.0: - image: nextcloudci/php7.0:php7.0-16 + image: nextcloudci/php7.0:php7.0-19 commands: - NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh mysql when: @@ -235,7 +235,7 @@ pipeline: DB: mysql5.5 PHP: "7.0" mysql5.5-php7.1: - image: nextcloudci/php7.1:php7.1-15 + image: nextcloudci/php7.1:php7.1-16 commands: - NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh mysql when: @@ -243,7 +243,7 @@ pipeline: DB: mysql5.5 PHP: 7.1 postgres-php7.0: - image: nextcloudci/php7.0:php7.0-16 + image: nextcloudci/php7.0:php7.0-19 commands: - sleep 10 # gives the database enough time to initialize - NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh pgsql @@ -252,7 +252,7 @@ pipeline: DB: postgres PHP: "7.0" postgres-php7.1: - image: nextcloudci/php7.1:php7.1-15 + image: nextcloudci/php7.1:php7.1-16 commands: - sleep 10 # gives the database enough time to initialize - NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh pgsql @@ -261,7 +261,7 @@ pipeline: DB: postgres PHP: 7.1 mysqlmb4-php7.0: - image: nextcloudci/php7.0:php7.0-16 + image: nextcloudci/php7.0:php7.0-19 commands: - NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh mysqlmb4 when: @@ -269,7 +269,7 @@ pipeline: DB: mysqlmb4 PHP: "7.0" mysqlmb4-php7.1: - image: nextcloudci/php7.1:php7.1-15 + image: nextcloudci/php7.1:php7.1-16 commands: - NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh mysqlmb4 when: @@ -277,7 +277,7 @@ pipeline: DB: mysqlmb4 PHP: 7.1 mysqlmb4-php7.2: - image: nextcloudci/php7.2:php7.2-9 + image: nextcloudci/php7.2:php7.2-10 commands: - NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh mysqlmb4 when: @@ -571,7 +571,7 @@ pipeline: matrix: TESTS-ACCEPTANCE: login nodb-codecov: - image: nextcloudci/php7.0:php7.0-16 + image: nextcloudci/php7.0:php7.0-19 commands: - phpenmod xdebug - TEST_SELECTION=NODB ./autotest.sh sqlite @@ -582,7 +582,7 @@ pipeline: matrix: TESTS: nodb-codecov db-codecov: - image: nextcloudci/php7.0:php7.0-16 + image: nextcloudci/php7.0:php7.0-19 commands: - phpenmod xdebug - TEST_SELECTION=QUICKDB ./autotest.sh sqlite @@ -593,7 +593,7 @@ pipeline: matrix: TESTS: db-codecov object-store: - image: nextcloudci/php7.0:php7.0-16 + image: nextcloudci/php7.0:php7.0-19 commands: - phpenmod xdebug - TEST_SELECTION=PRIMARY-${OBJECT_STORE} ./autotest.sh sqlite @@ -616,7 +616,7 @@ pipeline: matrix: TEST: memcache-memcached memcache-redis-cluster: - image: nextcloudci/php7.0:php7.0-17 + image: nextcloudci/php7.0:php7.0-19 commands: - phpenmod xdebug - sleep 20 From bf2be08c9f3b6957a3327929a169eb6204e84cd0 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 25 Jan 2018 11:23:12 +0100 Subject: [PATCH 4/6] Fix risky tests without assertions Signed-off-by: Joas Schilling --- .../tests/unit/AppInfo/ApplicationTest.php | 2 +- .../unit/CalDAV/AbstractCalDavBackend.php | 4 +-- apps/dav/tests/unit/CalDAV/CalendarTest.php | 2 +- .../Sabre/CustomPropertiesBackendTest.php | 2 +- .../unit/Connector/Sabre/DirectoryTest.php | 2 +- .../unit/Connector/Sabre/FilesPluginTest.php | 2 ++ apps/encryption/tests/Hooks/UserHooksTest.php | 6 ++--- apps/encryption/tests/RecoveryTest.php | 2 +- .../Service/UserGlobalStoragesServiceTest.php | 26 +++++++++---------- apps/files_sharing/tests/ApiTest.php | 6 ++++- .../tests/External/ScannerTest.php | 6 ++--- apps/files_sharing/tests/LockingTest.php | 2 +- .../Middleware/OCSShareAPIMiddlewareTest.php | 1 + .../tests/BackgroundJob/ExpireTrashTest.php | 2 +- .../tests/Command/ExpireTest.php | 2 +- apps/files_trashbin/tests/StorageTest.php | 1 + .../tests/Command/ExpireTest.php | 2 +- .../Controller/AppConfigControllerTest.php | 4 +-- apps/user_ldap/tests/LDAPProviderTest.php | 8 +++--- .../tests/Check/AbstractStringCheckTest.php | 2 ++ .../tests/Check/RequestTimeTest.php | 1 + .../PasswordConfirmationMiddlewareTest.php | 4 +-- .../Security/SameSiteCookieMiddlewareTest.php | 3 +++ .../Security/SecurityMiddlewareTest.php | 4 +-- .../LoginCredentials/StoreTest.php | 1 + tests/lib/Contacts/ContactsMenu/EntryTest.php | 1 + tests/lib/DB/ConnectionTest.php | 6 +++-- tests/lib/DB/DBSchemaTest.php | 2 +- tests/lib/DB/MDB2SchemaManagerTest.php | 2 +- tests/lib/DB/MigratorTest.php | 10 +++---- tests/lib/DB/MySqlMigrationTest.php | 2 +- .../lib/DB/QueryBuilder/QueryBuilderTest.php | 4 +-- tests/lib/DB/SqliteMigrationTest.php | 2 +- tests/lib/Federation/CloudIdTest.php | 4 +-- .../lib/Files/Cache/Wrapper/CacheJailTest.php | 2 +- tests/lib/Files/PathVerificationTest.php | 4 ++- tests/lib/Files/Storage/LocalTest.php | 1 + tests/lib/Group/Backend.php | 2 ++ tests/lib/Hooks/BasicEmitterTest.php | 18 ++++++------- tests/lib/InfoXmlTest.php | 2 ++ .../Helpers/FileAccessHelperTest.php | 1 + tests/lib/RichObjectStrings/ValidatorTest.php | 1 + .../CSP/ContentSecurityPolicyManagerTest.php | 1 + tests/lib/Share20/ManagerTest.php | 11 ++++++++ .../lib/Support/CrashReport/RegistryTest.php | 1 + 45 files changed, 107 insertions(+), 67 deletions(-) diff --git a/apps/dav/tests/unit/AppInfo/ApplicationTest.php b/apps/dav/tests/unit/AppInfo/ApplicationTest.php index bb6cfe67b4..d4f53d360a 100644 --- a/apps/dav/tests/unit/AppInfo/ApplicationTest.php +++ b/apps/dav/tests/unit/AppInfo/ApplicationTest.php @@ -61,6 +61,6 @@ class ApplicationTest extends TestCase { /** @var IManager|\PHPUnit_Framework_MockObject_MockObject $cm */ $cm = $this->createMock(IManager::class); $app->setupContactsProvider($cm, 'xxx'); - $this->assertTrue(true); + $this->addToAssertionCount(1); } } diff --git a/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php b/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php index 2a01bd425c..310433f091 100644 --- a/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php +++ b/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php @@ -176,7 +176,7 @@ EOD; protected function assertAcl($principal, $privilege, $acl) { foreach($acl as $a) { if ($a['principal'] === $principal && $a['privilege'] === $privilege) { - $this->assertTrue(true); + $this->addToAssertionCount(1); return; } } @@ -190,7 +190,7 @@ EOD; return; } } - $this->assertTrue(true); + $this->addToAssertionCount(1); } protected function assertAccess($shouldHaveAcl, $principal, $privilege, $acl) { diff --git a/apps/dav/tests/unit/CalDAV/CalendarTest.php b/apps/dav/tests/unit/CalDAV/CalendarTest.php index dbdbf0dbaf..f467d46bf6 100644 --- a/apps/dav/tests/unit/CalDAV/CalendarTest.php +++ b/apps/dav/tests/unit/CalDAV/CalendarTest.php @@ -183,7 +183,7 @@ class CalendarTest extends TestCase { ->with(666, $propPatch); } $c->propPatch($propPatch); - $this->assertTrue(true); + $this->addToAssertionCount(1); } /** diff --git a/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php b/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php index cbde8c2ef6..91973eeff5 100644 --- a/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php @@ -174,7 +174,7 @@ class CustomPropertiesBackendTest extends \Test\TestCase { ); // no exception, soft fail - $this->assertTrue(true); + $this->addToAssertionCount(1); } /** diff --git a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php index e72987ef02..968cb54806 100644 --- a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php @@ -345,7 +345,7 @@ class DirectoryTest extends \Test\TestCase { */ public function testMoveSuccess($source, $destination, $updatables, $deletables) { $this->moveTest($source, $destination, $updatables, $deletables); - $this->assertTrue(true); + $this->addToAssertionCount(1); } /** diff --git a/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php index e1c4bc05dc..ea520bca7e 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php @@ -383,6 +383,8 @@ class FilesPluginTest extends TestCase { $propFind, $node ); + + $this->addToAssertionCount(1); } public function testUpdateProps() { diff --git a/apps/encryption/tests/Hooks/UserHooksTest.php b/apps/encryption/tests/Hooks/UserHooksTest.php index f951ddb37f..91005e2746 100644 --- a/apps/encryption/tests/Hooks/UserHooksTest.php +++ b/apps/encryption/tests/Hooks/UserHooksTest.php @@ -110,7 +110,7 @@ class UserHooksTest extends TestCase { $this->sessionMock->expects($this->once()) ->method('clear'); $this->instance->logout(); - $this->assertTrue(true); + $this->addToAssertionCount(1); } public function testPostCreateUser() { @@ -118,7 +118,7 @@ class UserHooksTest extends TestCase { ->method('setupUser'); $this->instance->postCreateUser($this->params); - $this->assertTrue(true); + $this->addToAssertionCount(1); } public function testPostDeleteUser() { @@ -127,7 +127,7 @@ class UserHooksTest extends TestCase { ->with('testUser'); $this->instance->postDeleteUser($this->params); - $this->assertTrue(true); + $this->addToAssertionCount(1); } public function testPrePasswordReset() { diff --git a/apps/encryption/tests/RecoveryTest.php b/apps/encryption/tests/RecoveryTest.php index b83b71737f..0eb9a777ec 100644 --- a/apps/encryption/tests/RecoveryTest.php +++ b/apps/encryption/tests/RecoveryTest.php @@ -213,7 +213,7 @@ class RecoveryTest extends TestCase { $this->cryptMock->expects($this->once()) ->method('decryptPrivateKey'); $this->instance->recoverUsersFiles('password', 'admin'); - $this->assertTrue(true); + $this->addToAssertionCount(1); } public function testRecoverFile() { diff --git a/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php b/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php index 013af9b042..452d8589a3 100644 --- a/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php +++ b/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php @@ -304,66 +304,66 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest { public function testGetStoragesBackendNotVisible() { // we don't test this here - $this->assertTrue(true); + $this->addToAssertionCount(1); } public function testGetStoragesAuthMechanismNotVisible() { // we don't test this here - $this->assertTrue(true); + $this->addToAssertionCount(1); } public function testHooksAddStorage($a = null, $b = null, $c = null) { // we don't test this here - $this->assertTrue(true); + $this->addToAssertionCount(1); } public function testHooksUpdateStorage($a = null, $b = null, $c = null, $d = null, $e = null) { // we don't test this here - $this->assertTrue(true); + $this->addToAssertionCount(1); } public function testHooksRenameMountPoint() { // we don't test this here - $this->assertTrue(true); + $this->addToAssertionCount(1); } public function testHooksDeleteStorage($a = null, $b = null, $c = null) { // we don't test this here - $this->assertTrue(true); + $this->addToAssertionCount(1); } public function testLegacyConfigConversionApplicableAll() { // we don't test this here - $this->assertTrue(true); + $this->addToAssertionCount(1); } public function testLegacyConfigConversionApplicableUserAndGroup() { // we don't test this here - $this->assertTrue(true); + $this->addToAssertionCount(1); } public function testReadLegacyConfigAndGenerateConfigId() { // we don't test this here - $this->assertTrue(true); + $this->addToAssertionCount(1); } public function testReadLegacyConfigNoAuthMechanism() { // we don't test this here - $this->assertTrue(true); + $this->addToAssertionCount(1); } public function testReadLegacyConfigClass() { // we don't test this here - $this->assertTrue(true); + $this->addToAssertionCount(1); } public function testReadEmptyMountPoint() { // we don't test this here - $this->assertTrue(true); + $this->addToAssertionCount(1); } public function testUpdateStorageMountPoint() { // we don't test this here - $this->assertTrue(true); + $this->addToAssertionCount(1); } } diff --git a/apps/files_sharing/tests/ApiTest.php b/apps/files_sharing/tests/ApiTest.php index 8e2b5942d1..6d8e2dd8d8 100644 --- a/apps/files_sharing/tests/ApiTest.php +++ b/apps/files_sharing/tests/ApiTest.php @@ -236,7 +236,7 @@ class ApiTest extends TestCase { $ocs->cleanup(); } - function testEnfoceLinkPassword() { + function testEnforceLinkPassword() { $password = md5(time()); $config = \OC::$server->getConfig(); @@ -288,6 +288,7 @@ class ApiTest extends TestCase { $ocs->cleanup(); $config->setAppValue('core', 'shareapi_enforce_links_password', 'no'); + $this->addToAssertionCount(1); } /** @@ -336,6 +337,8 @@ class ApiTest extends TestCase { // cleanup \OC::$server->getConfig()->setAppValue('core', 'shareapi_exclude_groups', 'no'); \OC::$server->getConfig()->setAppValue('core', 'shareapi_exclude_groups_list', ''); + + $this->addToAssertionCount(1); } @@ -1102,6 +1105,7 @@ class ApiTest extends TestCase { $ocs->cleanup(); $this->shareManager->deleteShare($share1); + $this->addToAssertionCount(1); } /** diff --git a/apps/files_sharing/tests/External/ScannerTest.php b/apps/files_sharing/tests/External/ScannerTest.php index 1ad19d5c80..fe77182e83 100644 --- a/apps/files_sharing/tests/External/ScannerTest.php +++ b/apps/files_sharing/tests/External/ScannerTest.php @@ -58,7 +58,7 @@ class ScannerTest extends TestCase { // Declaration of OCA\Files_Sharing\External\Scanner::*() should be // compatible with OC\Files\Cache\Scanner::*() $this->scanner->scanAll(); - $this->assertTrue(true); + $this->addToAssertionCount(1); } public function testScan() { @@ -70,7 +70,7 @@ class ScannerTest extends TestCase { // Declaration of OCA\Files_Sharing\External\Scanner::*() should be // compatible with OC\Files\Cache\Scanner::*() $this->scanner->scan('test', Scanner::SCAN_RECURSIVE); - $this->assertTrue(true); + $this->addToAssertionCount(1); } public function testScanFile() { @@ -78,6 +78,6 @@ class ScannerTest extends TestCase { // Declaration of OCA\Files_Sharing\External\Scanner::*() should be // compatible with OC\Files\Cache\Scanner::*() $this->scanner->scanFile('test', Scanner::SCAN_RECURSIVE); - $this->assertTrue(true); + $this->addToAssertionCount(1); } } diff --git a/apps/files_sharing/tests/LockingTest.php b/apps/files_sharing/tests/LockingTest.php index 4af5e3e2ce..414e879081 100644 --- a/apps/files_sharing/tests/LockingTest.php +++ b/apps/files_sharing/tests/LockingTest.php @@ -111,6 +111,6 @@ class LockingTest extends TestCase { $recipientView->changeLock('bar.txt', ILockingProvider::LOCK_EXCLUSIVE); $recipientView->unlockFile('bar.txt', ILockingProvider::LOCK_EXCLUSIVE); - $this->assertTrue(true); + $this->addToAssertionCount(1); } } diff --git a/apps/files_sharing/tests/Middleware/OCSShareAPIMiddlewareTest.php b/apps/files_sharing/tests/Middleware/OCSShareAPIMiddlewareTest.php index c260a65725..8cbf03b8b6 100644 --- a/apps/files_sharing/tests/Middleware/OCSShareAPIMiddlewareTest.php +++ b/apps/files_sharing/tests/Middleware/OCSShareAPIMiddlewareTest.php @@ -136,5 +136,6 @@ class OCSShareAPIMiddlewareTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); $this->middleware->afterController($controller, 'foo', $response); + $this->addToAssertionCount(1); } } diff --git a/apps/files_trashbin/tests/BackgroundJob/ExpireTrashTest.php b/apps/files_trashbin/tests/BackgroundJob/ExpireTrashTest.php index 882099efc9..5339d60072 100644 --- a/apps/files_trashbin/tests/BackgroundJob/ExpireTrashTest.php +++ b/apps/files_trashbin/tests/BackgroundJob/ExpireTrashTest.php @@ -39,6 +39,6 @@ class ExpireTrashTest extends \Test\TestCase { /** @var \OC\BackgroundJob\JobList $jobList */ $backgroundJob->execute($jobList); - $this->assertTrue(true); + $this->addToAssertionCount(1); } } diff --git a/apps/files_trashbin/tests/Command/ExpireTest.php b/apps/files_trashbin/tests/Command/ExpireTest.php index bdc8d86794..2076326cf1 100644 --- a/apps/files_trashbin/tests/Command/ExpireTest.php +++ b/apps/files_trashbin/tests/Command/ExpireTest.php @@ -39,6 +39,6 @@ class ExpireTest extends TestCase { $command = new Expire('test'); $command->handle(); - $this->assertTrue(true); + $this->addToAssertionCount(1); } } diff --git a/apps/files_trashbin/tests/StorageTest.php b/apps/files_trashbin/tests/StorageTest.php index 0e23ea6a3b..67e622aa1c 100644 --- a/apps/files_trashbin/tests/StorageTest.php +++ b/apps/files_trashbin/tests/StorageTest.php @@ -593,6 +593,7 @@ class StorageTest extends \Test\TestCase { $this->markTestSkipped('Skipping since the current home storage backend requires the user to logged in'); } else { $this->userView->unlink('test.txt'); + $this->addToAssertionCount(1); } } } diff --git a/apps/files_versions/tests/Command/ExpireTest.php b/apps/files_versions/tests/Command/ExpireTest.php index 3815bc5b75..c56624d026 100644 --- a/apps/files_versions/tests/Command/ExpireTest.php +++ b/apps/files_versions/tests/Command/ExpireTest.php @@ -39,6 +39,6 @@ class ExpireTest extends TestCase { $command = new Expire($this->getUniqueID('test'), ''); $command->handle(); - $this->assertTrue(true); + $this->addToAssertionCount(1); } } diff --git a/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php b/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php index 7f24ef5bcb..223f2c371d 100644 --- a/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php +++ b/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php @@ -318,7 +318,7 @@ class AppConfigControllerTest extends TestCase { public function testVerifyAppId() { $api = $this->getInstance(); $this->invokePrivate($api, 'verifyAppId', ['activity']); - $this->assertTrue(true); + $this->addToAssertionCount(1); } public function dataVerifyAppIdThrows() { @@ -356,7 +356,7 @@ class AppConfigControllerTest extends TestCase { public function testVerifyConfigKey($app, $key) { $api = $this->getInstance(); $this->invokePrivate($api, 'verifyConfigKey', [$app, $key]); - $this->assertTrue(true); + $this->addToAssertionCount(1); } public function dataVerifyConfigKeyThrows() { diff --git a/apps/user_ldap/tests/LDAPProviderTest.php b/apps/user_ldap/tests/LDAPProviderTest.php index f3a27dec2c..8df527e0dd 100644 --- a/apps/user_ldap/tests/LDAPProviderTest.php +++ b/apps/user_ldap/tests/LDAPProviderTest.php @@ -429,7 +429,7 @@ class LDAPProviderTest extends \Test\TestCase { $ldapProvider = $this->getLDAPProvider($server); $ldapProvider->clearCache('existing_user'); - $this->assertTrue(TRUE); + $this->addToAssertionCount(1); } /** @@ -474,7 +474,7 @@ class LDAPProviderTest extends \Test\TestCase { $ldapProvider = $this->getLDAPProvider($server); $ldapProvider->clearGroupCache('existing_group'); - $this->assertTrue(TRUE); + $this->addToAssertionCount(1); } public function testDnExists() { @@ -502,7 +502,7 @@ class LDAPProviderTest extends \Test\TestCase { $ldapProvider = $this->getLDAPProvider($server); $ldapProvider->flagRecord('existing_user'); - $this->assertTrue(TRUE); + $this->addToAssertionCount(1); } public function testUnflagRecord() { @@ -515,7 +515,7 @@ class LDAPProviderTest extends \Test\TestCase { $ldapProvider = $this->getLDAPProvider($server); $ldapProvider->unflagRecord('existing_user'); - $this->assertTrue(TRUE); + $this->addToAssertionCount(1); } /** diff --git a/apps/workflowengine/tests/Check/AbstractStringCheckTest.php b/apps/workflowengine/tests/Check/AbstractStringCheckTest.php index b705187011..70f8f79146 100644 --- a/apps/workflowengine/tests/Check/AbstractStringCheckTest.php +++ b/apps/workflowengine/tests/Check/AbstractStringCheckTest.php @@ -96,6 +96,8 @@ class AbstractStringCheckTest extends \Test\TestCase { /** @var \OCA\WorkflowEngine\Check\AbstractStringCheck $check */ $check->validateCheck($operator, $value); + + $this->addToAssertionCount(1); } public function dataValidateCheckInvalid() { diff --git a/apps/workflowengine/tests/Check/RequestTimeTest.php b/apps/workflowengine/tests/Check/RequestTimeTest.php index 7249f5109f..519b5112f3 100644 --- a/apps/workflowengine/tests/Check/RequestTimeTest.php +++ b/apps/workflowengine/tests/Check/RequestTimeTest.php @@ -129,6 +129,7 @@ class RequestTimeTest extends \Test\TestCase { public function testValidateCheck($operator, $value) { $check = new \OCA\WorkflowEngine\Check\RequestTime($this->getL10NMock(), $this->timeFactory); $check->validateCheck($operator, $value); + $this->addToAssertionCount(1); } public function dataValidateCheckInvalid() { diff --git a/tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php index 2c610736f4..95729e286f 100644 --- a/tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php @@ -89,7 +89,7 @@ class PasswordConfirmationMiddlewareTest extends TestCase { /** * @PasswordConfirmationRequired - * @dataProvider testProvider + * @dataProvider dataProvider */ public function testAnnotation($backend, $lastConfirm, $currentTime, $exception) { $this->reflector->reflect(__CLASS__, __FUNCTION__); @@ -116,7 +116,7 @@ class PasswordConfirmationMiddlewareTest extends TestCase { $this->assertSame($exception, $thrown); } - public function testProvider() { + public function dataProvider() { return [ ['foo', 2000, 4000, true], ['foo', 2000, 3000, false], diff --git a/tests/lib/AppFramework/Middleware/Security/SameSiteCookieMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/SameSiteCookieMiddlewareTest.php index bd1568bcd6..7784f55e84 100644 --- a/tests/lib/AppFramework/Middleware/Security/SameSiteCookieMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/Security/SameSiteCookieMiddlewareTest.php @@ -55,6 +55,7 @@ class SameSiteCookieMiddlewareTest extends TestCase { ->willReturn('/ocs/v2.php'); $this->middleware->beforeController($this->createMock(Controller::class), 'foo'); + $this->addToAssertionCount(1); } public function testBeforeControllerIndexHasAnnotation() { @@ -66,6 +67,7 @@ class SameSiteCookieMiddlewareTest extends TestCase { ->willReturn(true); $this->middleware->beforeController($this->createMock(Controller::class), 'foo'); + $this->addToAssertionCount(1); } public function testBeforeControllerIndexNoAnnotationPassingCheck() { @@ -80,6 +82,7 @@ class SameSiteCookieMiddlewareTest extends TestCase { ->willReturn(true); $this->middleware->beforeController($this->createMock(Controller::class), 'foo'); + $this->addToAssertionCount(1); } public function testBeforeControllerIndexNoAnnotationFailingCheck() { diff --git a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php index 274a2810cb..b68f0cb198 100644 --- a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php @@ -168,7 +168,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { // add assertion if everything should work fine otherwise phpunit will // complain if ($status === 0) { - $this->assertTrue(true); + $this->addToAssertionCount(1); } } @@ -265,7 +265,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { if($shouldFail) { $this->expectException(SecurityException::class); } else { - $this->assertTrue(true); + $this->addToAssertionCount(1); } $this->reader->reflect(__CLASS__, $method); diff --git a/tests/lib/Authentication/LoginCredentials/StoreTest.php b/tests/lib/Authentication/LoginCredentials/StoreTest.php index 9a719339b4..4588eae35f 100644 --- a/tests/lib/Authentication/LoginCredentials/StoreTest.php +++ b/tests/lib/Authentication/LoginCredentials/StoreTest.php @@ -79,6 +79,7 @@ class StoreTest extends TestCase { $session = $this->createMock(ISession::class); $this->store->setSession($session); + $this->addToAssertionCount(1); } public function testGetLoginCredentialsNoTokenProvider() { diff --git a/tests/lib/Contacts/ContactsMenu/EntryTest.php b/tests/lib/Contacts/ContactsMenu/EntryTest.php index d5141136a1..e28248fb0f 100644 --- a/tests/lib/Contacts/ContactsMenu/EntryTest.php +++ b/tests/lib/Contacts/ContactsMenu/EntryTest.php @@ -41,6 +41,7 @@ class EntryTest extends TestCase { public function testSetId() { $this->entry->setId(123); + $this->addToAssertionCount(1); } public function testSetGetFullName() { diff --git a/tests/lib/DB/ConnectionTest.php b/tests/lib/DB/ConnectionTest.php index 2a0cd70f83..3a4a80bdbd 100644 --- a/tests/lib/DB/ConnectionTest.php +++ b/tests/lib/DB/ConnectionTest.php @@ -58,7 +58,7 @@ class ConnectionTest extends \Test\TestCase { public function assertTableExist($table) { if ($this->connection->getDatabasePlatform() instanceof SqlitePlatform) { // sqlite removes the tables after closing the DB - $this->assertTrue(true); + $this->addToAssertionCount(1); } else { $this->assertTrue($this->connection->tableExists($table), 'Table ' . $table . ' exists.'); } @@ -70,7 +70,7 @@ class ConnectionTest extends \Test\TestCase { public function assertTableNotExist($table) { if ($this->connection->getDatabasePlatform() instanceof SqlitePlatform) { // sqlite removes the tables after closing the DB - $this->assertTrue(true); + $this->addToAssertionCount(1); } else { $this->assertFalse($this->connection->tableExists($table), 'Table ' . $table . " doesn't exist."); } @@ -195,5 +195,7 @@ class ConnectionTest extends \Test\TestCase { ], [ 'textfield' => 'foo' ]); + + $this->addToAssertionCount(1); } } diff --git a/tests/lib/DB/DBSchemaTest.php b/tests/lib/DB/DBSchemaTest.php index 8eb7fcf81b..cc6059c163 100644 --- a/tests/lib/DB/DBSchemaTest.php +++ b/tests/lib/DB/DBSchemaTest.php @@ -107,7 +107,7 @@ class DBSchemaTest extends TestCase { $platform = \OC::$server->getDatabaseConnection()->getDatabasePlatform(); if ($platform instanceof SqlitePlatform) { // sqlite removes the tables after closing the DB - $this->assertTrue(true); + $this->addToAssertionCount(1); } else { $this->assertFalse(OC_DB::tableExists($table), 'Table ' . $table . ' exists.'); } diff --git a/tests/lib/DB/MDB2SchemaManagerTest.php b/tests/lib/DB/MDB2SchemaManagerTest.php index 93078b4f72..75572bb36a 100644 --- a/tests/lib/DB/MDB2SchemaManagerTest.php +++ b/tests/lib/DB/MDB2SchemaManagerTest.php @@ -46,7 +46,7 @@ class MDB2SchemaManagerTest extends \Test\TestCase { $connection->executeUpdate('insert into `*PREFIX*table` values (?)', array('123')); $manager->updateDbFromStructure(__DIR__ . '/ts-autoincrement-after.xml'); - $this->assertTrue(true); + $this->addToAssertionCount(1); } } diff --git a/tests/lib/DB/MigratorTest.php b/tests/lib/DB/MigratorTest.php index ea718240c5..9dfed5ecd1 100644 --- a/tests/lib/DB/MigratorTest.php +++ b/tests/lib/DB/MigratorTest.php @@ -132,7 +132,7 @@ class MigratorTest extends \Test\TestCase { $migrator->checkMigrate($endSchema); $migrator->migrate($endSchema); - $this->assertTrue(true); + $this->addToAssertionCount(1); } public function testUpgradeDifferentPrefix() { @@ -151,7 +151,7 @@ class MigratorTest extends \Test\TestCase { $migrator->checkMigrate($endSchema); $migrator->migrate($endSchema); - $this->assertTrue(true); + $this->addToAssertionCount(1); $this->config->setSystemValue('dbtableprefix', $oldTablePrefix); } @@ -169,7 +169,7 @@ class MigratorTest extends \Test\TestCase { $this->connection->insert($this->tableName, array('id' => 2, 'name' => 'qwerty')); $this->fail('Expected duplicate key insert to fail'); } catch (DBALException $e) { - $this->assertTrue(true); + $this->addToAssertionCount(1); } } @@ -191,7 +191,7 @@ class MigratorTest extends \Test\TestCase { $migrator->checkMigrate($endSchema); $migrator->migrate($endSchema); - $this->assertTrue(true); + $this->addToAssertionCount(1); } public function testReservedKeywords() { @@ -213,7 +213,7 @@ class MigratorTest extends \Test\TestCase { $migrator->checkMigrate($endSchema); $migrator->migrate($endSchema); - $this->assertTrue(true); + $this->addToAssertionCount(1); } public function testAddingForeignKey() { diff --git a/tests/lib/DB/MySqlMigrationTest.php b/tests/lib/DB/MySqlMigrationTest.php index cdc7ef4778..3bbe89fe02 100644 --- a/tests/lib/DB/MySqlMigrationTest.php +++ b/tests/lib/DB/MySqlMigrationTest.php @@ -43,7 +43,7 @@ class MySqlMigrationTest extends \Test\TestCase { $manager = new \OC\DB\MDB2SchemaManager($this->connection); $manager->updateDbFromStructure(__DIR__ . '/testschema.xml'); - $this->assertTrue(true); + $this->addToAssertionCount(1); } } diff --git a/tests/lib/DB/QueryBuilder/QueryBuilderTest.php b/tests/lib/DB/QueryBuilder/QueryBuilderTest.php index e264fde6ec..fa1c4add0a 100644 --- a/tests/lib/DB/QueryBuilder/QueryBuilderTest.php +++ b/tests/lib/DB/QueryBuilder/QueryBuilderTest.php @@ -1137,7 +1137,7 @@ class QueryBuilderTest extends \Test\TestCase { $qB->getLastInsertId(); $this->fail('getLastInsertId() should throw an exception, when being called before insert()'); } catch (\BadMethodCallException $e) { - $this->assertTrue(true); + $this->addToAssertionCount(1); } $qB->insert('properties') @@ -1163,7 +1163,7 @@ class QueryBuilderTest extends \Test\TestCase { $qB->getLastInsertId(); $this->fail('getLastInsertId() should throw an exception, when being called after delete()'); } catch (\BadMethodCallException $e) { - $this->assertTrue(true); + $this->addToAssertionCount(1); } } diff --git a/tests/lib/DB/SqliteMigrationTest.php b/tests/lib/DB/SqliteMigrationTest.php index 76002e1afc..4712fc6d70 100644 --- a/tests/lib/DB/SqliteMigrationTest.php +++ b/tests/lib/DB/SqliteMigrationTest.php @@ -43,7 +43,7 @@ class SqliteMigrationTest extends \Test\TestCase { $manager = new \OC\DB\MDB2SchemaManager($this->connection); $manager->updateDbFromStructure(__DIR__ . '/testschema.xml'); - $this->assertTrue(true); + $this->addToAssertionCount(1); } } diff --git a/tests/lib/Federation/CloudIdTest.php b/tests/lib/Federation/CloudIdTest.php index 7a6e841fb3..feb4108efe 100644 --- a/tests/lib/Federation/CloudIdTest.php +++ b/tests/lib/Federation/CloudIdTest.php @@ -25,7 +25,7 @@ use OC\Federation\CloudId; use Test\TestCase; class CloudIdTest extends TestCase { - public function testGetDisplayCloudIdProvider() { + public function dataGetDisplayCloudId() { return [ ['test@example.com', 'test@example.com'], ['test@http://example.com', 'test@example.com'], @@ -34,7 +34,7 @@ class CloudIdTest extends TestCase { } /** - * @dataProvider testGetDisplayCloudIdProvider + * @dataProvider dataGetDisplayCloudId * * @param string $id * @param string $display diff --git a/tests/lib/Files/Cache/Wrapper/CacheJailTest.php b/tests/lib/Files/Cache/Wrapper/CacheJailTest.php index f26e3a59f1..365049c1cc 100644 --- a/tests/lib/Files/Cache/Wrapper/CacheJailTest.php +++ b/tests/lib/Files/Cache/Wrapper/CacheJailTest.php @@ -79,7 +79,7 @@ class CacheJailTest extends CacheTest { function testGetIncomplete() { //not supported - $this->assertTrue(true); + $this->addToAssertionCount(1); } function testMoveFromJail() { diff --git a/tests/lib/Files/PathVerificationTest.php b/tests/lib/Files/PathVerificationTest.php index c1cebe975f..7e0b7dd265 100644 --- a/tests/lib/Files/PathVerificationTest.php +++ b/tests/lib/Files/PathVerificationTest.php @@ -87,6 +87,8 @@ class PathVerificationTest extends \Test\TestCase { if (!$connection->supports4ByteText()) { $this->expectException(InvalidPathException::class); $this->expectExceptionMessage('File name contains at least one invalid character'); + } else { + $this->addToAssertionCount(1); } $this->view->verifyPath('', $fileName); @@ -161,7 +163,7 @@ class PathVerificationTest extends \Test\TestCase { self::invokePrivate($storage, 'verifyPosixPath', [$fileName]); // nothing thrown - $this->assertTrue(true); + $this->addToAssertionCount(1); } public function providesValidPosixPaths() { diff --git a/tests/lib/Files/Storage/LocalTest.php b/tests/lib/Files/Storage/LocalTest.php index 89dd2f0786..f17933413a 100644 --- a/tests/lib/Files/Storage/LocalTest.php +++ b/tests/lib/Files/Storage/LocalTest.php @@ -106,6 +106,7 @@ class LocalTest extends Storage { $storage = new \OC\Files\Storage\Local(['datadir' => $subDir1]); $storage->file_put_contents('sym/foo', 'bar'); + $this->addToAssertionCount(1); } } diff --git a/tests/lib/Group/Backend.php b/tests/lib/Group/Backend.php index eb17e9bded..f702d94b2b 100644 --- a/tests/lib/Group/Backend.php +++ b/tests/lib/Group/Backend.php @@ -157,5 +157,7 @@ abstract class Backend extends \Test\TestCase { $this->backend->createGroup($group); $this->backend->createGroup($group); + + $this->addToAssertionCount(1); } } diff --git a/tests/lib/Hooks/BasicEmitterTest.php b/tests/lib/Hooks/BasicEmitterTest.php index 2e6bd8100e..7b71bb8259 100644 --- a/tests/lib/Hooks/BasicEmitterTest.php +++ b/tests/lib/Hooks/BasicEmitterTest.php @@ -157,7 +157,7 @@ class BasicEmitterTest extends \Test\TestCase { $this->emitter->removeListener('Test', 'test', $listener); $this->emitter->emitEvent('Test', 'test'); - $this->assertTrue(true); + $this->addToAssertionCount(1); } public function testRemoveWildcardListener() { @@ -172,7 +172,7 @@ class BasicEmitterTest extends \Test\TestCase { $this->emitter->removeListener('Test', 'test'); $this->emitter->emitEvent('Test', 'test'); - $this->assertTrue(true); + $this->addToAssertionCount(1); } public function testRemoveWildcardMethod() { @@ -185,7 +185,7 @@ class BasicEmitterTest extends \Test\TestCase { $this->emitter->emitEvent('Test', 'test'); $this->emitter->emitEvent('Test', 'foo'); - $this->assertTrue(true); + $this->addToAssertionCount(1); } public function testRemoveWildcardScope() { @@ -198,7 +198,7 @@ class BasicEmitterTest extends \Test\TestCase { $this->emitter->emitEvent('Test', 'test'); $this->emitter->emitEvent('Bar', 'test'); - $this->assertTrue(true); + $this->addToAssertionCount(1); } public function testRemoveWildcardScopeAndMethod() { @@ -213,7 +213,7 @@ class BasicEmitterTest extends \Test\TestCase { $this->emitter->emitEvent('Test', 'foo'); $this->emitter->emitEvent('Bar', 'foo'); - $this->assertTrue(true); + $this->addToAssertionCount(1); } /** @@ -231,7 +231,7 @@ class BasicEmitterTest extends \Test\TestCase { $this->emitter->removeListener('Test', 'test', $listener1); $this->emitter->emitEvent('Test', 'test'); - $this->assertTrue(true); + $this->addToAssertionCount(1); } /** @@ -246,7 +246,7 @@ class BasicEmitterTest extends \Test\TestCase { $this->emitter->removeListener('Test', 'foo', $listener); $this->emitter->emitEvent('Test', 'test'); - $this->assertTrue(true); + $this->addToAssertionCount(1); } /** @@ -261,7 +261,7 @@ class BasicEmitterTest extends \Test\TestCase { $this->emitter->removeListener('Bar', 'test', $listener); $this->emitter->emitEvent('Test', 'test'); - $this->assertTrue(true); + $this->addToAssertionCount(1); } /** @@ -275,6 +275,6 @@ class BasicEmitterTest extends \Test\TestCase { $this->emitter->removeListener('Bar', 'test', $listener); $this->emitter->emitEvent('Test', 'test'); - $this->assertTrue(true); + $this->addToAssertionCount(1); } } diff --git a/tests/lib/InfoXmlTest.php b/tests/lib/InfoXmlTest.php index 18391a20c0..3d740cd39d 100644 --- a/tests/lib/InfoXmlTest.php +++ b/tests/lib/InfoXmlTest.php @@ -67,8 +67,10 @@ class InfoXmlTest extends TestCase { $applicationClassName = \OCP\AppFramework\App::buildAppNamespace($app) . '\\AppInfo\\Application'; if (class_exists($applicationClassName)) { $application = new $applicationClassName(); + $this->addToAssertionCount(1); } else { $application = new \OCP\AppFramework\App($app); + $this->addToAssertionCount(1); } if (isset($appInfo['background-jobs'])) { diff --git a/tests/lib/IntegrityCheck/Helpers/FileAccessHelperTest.php b/tests/lib/IntegrityCheck/Helpers/FileAccessHelperTest.php index de4aeec78c..4e581c0f2e 100644 --- a/tests/lib/IntegrityCheck/Helpers/FileAccessHelperTest.php +++ b/tests/lib/IntegrityCheck/Helpers/FileAccessHelperTest.php @@ -64,5 +64,6 @@ class FileAccessHelperTest extends TestCase { public function testAssertDirectoryExists() { $this->fileAccessHelper->assertDirectoryExists(\OC::$server->getTempManager()->getTemporaryFolder('/testfolder/')); + $this->addToAssertionCount(1); } } diff --git a/tests/lib/RichObjectStrings/ValidatorTest.php b/tests/lib/RichObjectStrings/ValidatorTest.php index f18d1bdd90..0c344248f7 100644 --- a/tests/lib/RichObjectStrings/ValidatorTest.php +++ b/tests/lib/RichObjectStrings/ValidatorTest.php @@ -49,6 +49,7 @@ class ValidatorTest extends TestCase { 'path' => 'path/to/test.txt', ], ]); + $this->addToAssertionCount(2); } } diff --git a/tests/lib/Security/CSP/ContentSecurityPolicyManagerTest.php b/tests/lib/Security/CSP/ContentSecurityPolicyManagerTest.php index f0fb1610d9..25c9257144 100644 --- a/tests/lib/Security/CSP/ContentSecurityPolicyManagerTest.php +++ b/tests/lib/Security/CSP/ContentSecurityPolicyManagerTest.php @@ -35,6 +35,7 @@ class ContentSecurityPolicyManagerTest extends \Test\TestCase { public function testAddDefaultPolicy() { $this->contentSecurityPolicyManager->addDefaultPolicy(new \OCP\AppFramework\Http\ContentSecurityPolicy()); + $this->addToAssertionCount(1); } public function testGetDefaultPolicyWithPolicies() { diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php index d52cb48e47..cc98223d4b 100644 --- a/tests/lib/Share20/ManagerTest.php +++ b/tests/lib/Share20/ManagerTest.php @@ -779,6 +779,7 @@ class ManagerTest extends \Test\TestCase { 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()); @@ -1008,6 +1009,7 @@ class ManagerTest extends \Test\TestCase { ->willReturn([]); self::invokePrivate($this->manager, 'userCreateChecks', [$share]); + $this->addToAssertionCount(1); } /** @@ -1143,6 +1145,7 @@ class ManagerTest extends \Test\TestCase { ->willReturn([$share2]); self::invokePrivate($this->manager, 'userCreateChecks', [$share]); + $this->addToAssertionCount(1); } /** @@ -1237,6 +1240,7 @@ class ManagerTest extends \Test\TestCase { ])); self::invokePrivate($this->manager, 'groupCreateChecks', [$share]); + $this->addToAssertionCount(1); } /** @@ -1292,6 +1296,7 @@ class ManagerTest extends \Test\TestCase { ])); self::invokePrivate($this->manager, 'groupCreateChecks', [$share]); + $this->addToAssertionCount(1); } /** @@ -1360,6 +1365,7 @@ class ManagerTest extends \Test\TestCase { ])); self::invokePrivate($this->manager, 'linkCreateChecks', [$share]); + $this->addToAssertionCount(1); } public function testLinkCreateChecksReadOnly() { @@ -1375,6 +1381,7 @@ class ManagerTest extends \Test\TestCase { ])); self::invokePrivate($this->manager, 'linkCreateChecks', [$share]); + $this->addToAssertionCount(1); } /** @@ -1407,12 +1414,14 @@ class ManagerTest extends \Test\TestCase { $this->mountManager->method('findIn')->with('path')->willReturn([$mount]); self::invokePrivate($this->manager, 'pathCreateChecks', [$path]); + $this->addToAssertionCount(1); } public function testPathCreateChecksContainsNoFolder() { $path = $this->createMock(File::class); self::invokePrivate($this->manager, 'pathCreateChecks', [$path]); + $this->addToAssertionCount(1); } public function dataIsSharingDisabledForUser() { @@ -2744,6 +2753,7 @@ class ManagerTest extends \Test\TestCase { $this->defaultProvider->method('move')->with($share, 'recipient')->will($this->returnArgument(0)); $this->manager->moveShare($share, 'recipient'); + $this->addToAssertionCount(1); } /** @@ -2801,6 +2811,7 @@ class ManagerTest extends \Test\TestCase { $this->defaultProvider->method('move')->with($share, 'recipient')->will($this->returnArgument(0)); $this->manager->moveShare($share, 'recipient'); + $this->addToAssertionCount(1); } /** diff --git a/tests/lib/Support/CrashReport/RegistryTest.php b/tests/lib/Support/CrashReport/RegistryTest.php index b73bf2737e..ba225ec133 100644 --- a/tests/lib/Support/CrashReport/RegistryTest.php +++ b/tests/lib/Support/CrashReport/RegistryTest.php @@ -47,6 +47,7 @@ class RegistryTest extends TestCase { $exception = new Exception('test'); $this->registry->delegateReport($exception); + $this->addToAssertionCount(1); } public function testDelegateToAll() { From 3917a54113c80420e9a27f23845ea4381c2b0109 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 25 Jan 2018 11:32:27 +0100 Subject: [PATCH 5/6] Class "ProgressBar" is declared "final" and cannot be mocked. Signed-off-by: Joas Schilling --- apps/encryption/tests/Crypto/EncryptAllTest.php | 6 ++++-- tests/lib/Encryption/DecryptAllTest.php | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/encryption/tests/Crypto/EncryptAllTest.php b/apps/encryption/tests/Crypto/EncryptAllTest.php index 0d894ab6fd..a39bf7befb 100644 --- a/apps/encryption/tests/Crypto/EncryptAllTest.php +++ b/apps/encryption/tests/Crypto/EncryptAllTest.php @@ -335,8 +335,10 @@ class EncryptAllTest extends TestCase { $encryptAll->expects($this->at(1))->method('encryptFile')->with('/user1/files/bar'); $encryptAll->expects($this->at(2))->method('encryptFile')->with('/user1/files/foo/subfile'); - $progressBar = $this->getMockBuilder(ProgressBar::class) - ->disableOriginalConstructor()->getMock(); + $this->outputInterface->expects($this->any()) + ->method('getFormatter') + ->willReturn($this->createMock(OutputFormatterInterface::class)); + $progressBar = new ProgressBar($this->outputInterface); $this->invokePrivate($encryptAll, 'encryptUsersFiles', ['user1', $progressBar, '']); diff --git a/tests/lib/Encryption/DecryptAllTest.php b/tests/lib/Encryption/DecryptAllTest.php index c2b7bd1714..59c24fb3c1 100644 --- a/tests/lib/Encryption/DecryptAllTest.php +++ b/tests/lib/Encryption/DecryptAllTest.php @@ -301,8 +301,11 @@ class DecryptAllTest extends TestCase { ->method('decryptFile') ->with('/user1/files/foo/subfile'); - $progressBar = $this->getMockBuilder(ProgressBar::class) - ->disableOriginalConstructor()->getMock(); + $output = $this->createMock(OutputInterface::class); + $output->expects($this->any()) + ->method('getFormatter') + ->willReturn($this->createMock(OutputFormatterInterface::class)); + $progressBar = new ProgressBar($output); $this->invokePrivate($instance, 'decryptUsersFiles', ['user1', $progressBar, '']); From 4718d2b80d88170f3814d3f7795bda9557ef12ac Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Thu, 25 Jan 2018 13:40:57 +0100 Subject: [PATCH 6/6] Update memcached image Signed-off-by: Morris Jobke --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 6bcb5d909a..a22258128c 100644 --- a/.drone.yml +++ b/.drone.yml @@ -604,7 +604,7 @@ pipeline: matrix: TESTS: object-store memcache-memcached: - image: nextcloudci/php7.0-memcached:php7.0-memcached-8 + image: nextcloudci/php7.0-memcached:php7.0-memcached-9 commands: - phpenmod xdebug - service memcached restart